forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Cloner to properly clone ruby strings
Currently, any invocation of clone, including pipeline->pipeline comms and the clone filter won't actually clone the string data, just the structure. We may be missing other value types too. This is a start however. Fixes elastic#9652 Fixes elastic#9653
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.logstash; | ||
|
||
import org.jruby.RubyString; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ClonerTest { | ||
@Test | ||
public void testRubyStringCloning() { | ||
String javaString = "fooBar"; | ||
RubyString original = RubyString.newString(RubyUtil.RUBY, javaString); | ||
|
||
RubyString result = Cloner.deep(original); | ||
// Check object identity | ||
assertTrue(result != original); | ||
|
||
// Check different underlying bytes | ||
assertTrue(result.getByteList() != original.getByteList()); | ||
|
||
// Check string equality | ||
assertEquals(result, original); | ||
|
||
assertEquals(javaString, result.asJavaString()); | ||
} | ||
} |