NPE decoding an unusual'ish string pattern

17 views
Skip to first unread message

Andre Mermegas

unread,
Nov 20, 2015, 10:45:21 AM11/20/15
to Chronicle
Getting NPE here, is it me somehow or somewhere in stack?

string is along the lines of this "FIX.4.4:12345678_client1->FOO/MINI1-1234567891234-12"

JUnit example
https://github.com/andmer/test/blob/master/WireTextBug.java

Andre Mermegas

unread,
Nov 20, 2015, 10:57:45 AM11/20/15
to Chronicle
seems like maybe its just the size.
Is there a 31 char max?

Rob Austin

unread,
Nov 20, 2015, 11:00:34 AM11/20/15
to java-ch...@googlegroups.com
when I ran your code i got this (  the fix to this will be in the next snapshot shortly ) - By the way, I realise that this is/maybe just the first issue.


java.lang.NullPointerException
at net.openhft.chronicle.core.util.StringUtils.isEqual(StringUtils.java:67)
at net.openhft.chronicle.bytes.Bytes.isEqual(Bytes.java:415)
at net.openhft.chronicle.bytes.util.UTF8StringInterner.intern(UTF8StringInterner.java:48)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.text(BinaryWire.java:1404)
at net.openhft.chronicle.wire.ValueIn.text(ValueIn.java:48)
at WireTextBug$Bug.readMarshallable(WireTextBug.java:70)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.marshallable(BinaryWire.java:1964)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.object0(BinaryWire.java:2136)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.object(BinaryWire.java:2108)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.object(BinaryWire.java:2207)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.object0(BinaryWire.java:2158)
at net.openhft.chronicle.wire.BinaryWire$BinaryValueIn.object(BinaryWire.java:2108)
at net.openhft.chronicle.wire.ValueIn.object(ValueIn.java:256)
at WireTextBug.testText(WireTextBug.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)


so have change this 

@ForceInline
public static boolean isEqual(CharSequence s, CharSequence cs) {

if (s == null) return false;
if (s.length() != cs.length()) return false;
for (int i = 0; i < cs.length(); i++)
if (s.charAt(i) != cs.charAt(i))
return false;
return true;
}

this this 

@ForceInline
public static boolean isEqual(CharSequence s, CharSequence cs) {
if (s == cs)
return true;
if (s == null) return false;
if (s.length() != cs.length()) return false;
for (int i = 0; i < cs.length(); i++)
if (s.charAt(i) != cs.charAt(i))
return false;
return true;
}

by adding
    if (s == cs)
return true;




--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rob Austin

unread,
Nov 20, 2015, 11:05:34 AM11/20/15
to java-ch...@googlegroups.com
correction to this 

@ForceInline
public static boolean isEqual(CharSequence s, CharSequence cs) {
if (s == cs)
return true;
if (s == null) return false;
    if (cs == null) return false;

if (s.length() != cs.length()) return false;
for (int i = 0; i < cs.length(); i++)
if (s.charAt(i) != cs.charAt(i))
return false;
return true;
}
I missed out the

    if (cs == null) return false;

in the last email

now when I run your test I get :

b = Bug{clOrdID='FIX.4.4:12345678_client1->FOO/MINI1-1234567891234-12'}
b2 = Bug{clOrdID='FIX.4.4:12345678_client1->FOO/MINI1-1234567891234-12'}
 

Rob Austin

unread,
Nov 20, 2015, 11:09:13 AM11/20/15
to java-ch...@googlegroups.com
once the build has completed — give it 30 mins, you can pick up this fix in the latest snapshot

<dependency>
    <groupId>net.openhft</groupId>
    <artifactId>chronicle-core</artifactId>
<version>1.1.6-SNAPSHOT</version>
</dependency>

it will be released ( hopefully ) in the next few weeks.

Rob

Andre Mermegas

unread,
Nov 20, 2015, 11:11:52 AM11/20/15
to Chronicle
Thanks Rob!

Rob Austin

unread,
Nov 20, 2015, 11:20:51 AM11/20/15
to java-ch...@googlegroups.com
I was doing some other releases so released this one as well… 

just make sure that the following dependency is in your project ( as wire will try to bring in the older version )

<dependency>
    <groupId>net.openhft</groupId>
    <artifactId>chronicle-core</artifactId>
<version>1.1.6</version>
</dependency>
Rob

Rob Austin

unread,
Nov 20, 2015, 1:17:38 PM11/20/15
to java-ch...@googlegroups.com
Andre Mermegas 

If you want a low latency fix engine we have one available under our enterprise licence.

Rob

On 20 Nov 2015, at 15:57, Andre Mermegas <and...@gmail.com> wrote:

Andre Mermegas

unread,
Nov 20, 2015, 2:07:25 PM11/20/15
to Chronicle
thanks, will consider it when I get back to engine.
Reply all
Reply to author
Forward
0 new messages