mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
parent
c6aaf58ff0
commit
7a1851ddc7
3 changed files with 12 additions and 2 deletions
|
@ -189,7 +189,7 @@ public class Event implements Cloneable, Serializable {
|
|||
}
|
||||
|
||||
public Map toMap() {
|
||||
return this.data;
|
||||
return Cloner.deep(this.data);
|
||||
}
|
||||
|
||||
public Event overwrite(Event e) {
|
||||
|
|
|
@ -245,7 +245,7 @@ public class JrubyEventExtLibrary implements Library {
|
|||
@JRubyMethod(name = "to_hash")
|
||||
public IRubyObject ruby_to_hash(ThreadContext context) throws IOException
|
||||
{
|
||||
return Rubyfier.deep(context.runtime, this.event.toMap());
|
||||
return Rubyfier.deep(context.runtime, this.event.getData());
|
||||
}
|
||||
|
||||
@JRubyMethod(name = "to_hash_with_metadata")
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
|
||||
|
||||
|
@ -104,6 +105,15 @@ public class EventTest {
|
|||
assertJsonEquals(f.toJson(), e.toJson());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToMap() throws Exception {
|
||||
Event e = new Event();
|
||||
Map original = e.getData();
|
||||
Map clone = e.toMap();
|
||||
assertFalse(original == clone);
|
||||
assertEquals(original, clone);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppend() throws Exception {
|
||||
Map data1 = new HashMap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue