java.lang.NegativeArraySizeException

QuickFIX/J JIRA | Alexander Piskarev | 7 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hi, OpenFAST team. While decoding new version of reference data from Eurex T7 4.0 with RDDFastTemplates-1.1.xml ([http://www.eurexchange.com/blob/2732742/809e0a1d9dc6cb9dae4126affe1c9395/data/Eurex-Market---Reference-Data-Interfaces---XML-FAST-Templates---FIXML-schema-files.zip]) with openfast-1.1.2 I have found some decoding errors including NegativeArraySizeException. Using following small test I could reproduce it. {code:java} public static void main(String[] args) throws IOException { MessageTemplateLoader templateLoader = new XMLMessageTemplateLoader(); List<MessageTemplate> templates = new ArrayList<>(); MessageTemplate[] hardcodedTemplates = templateLoader.load(new ByteArrayInputStream("<template id=\"120\" name=\"FastReset\"></template>".getBytes())); templates.addAll(Arrays.asList(hardcodedTemplates)); try (InputStream templateSource = Main.class.getClassLoader().getResourceAsStream("RDDFastTemplates-1.1.xml")) { templates.addAll(Arrays.asList(templateLoader.load(templateSource))); } try (InputStream fastEncodedStream = Main.class.getClassLoader().getResourceAsStream("fastdata.bin")) { MessageInputStream messageIn = new MessageInputStream(fastEncodedStream); messageIn.getContext().setTraceEnabled(true); for (MessageTemplate mt : templates) { messageIn.registerTemplate(Integer.valueOf(mt.getId()), mt); } Message message = null; do { message = messageIn.readMessage(); System.out.println(message); } while (message != null); } } {code} {noformat} Exception in thread "main" java.lang.NegativeArraySizeException at org.openfast.ByteUtil.combine(ByteUtil.java:125) at org.openfast.util.Util.applyDifference(Util.java:82) at org.openfast.template.operator.DeltaStringOperatorCodec.decodeValue(DeltaStringOperatorCodec.java:77) at org.openfast.template.Scalar.decodeValue(Scalar.java:174) at org.openfast.template.Scalar.decode(Scalar.java:234) at org.openfast.template.Group.decodeFieldValues(Group.java:293) at org.openfast.template.Group.decodeFieldValues(Group.java:256) at org.openfast.template.Group.decode(Group.java:223) at org.openfast.template.Sequence.decode(Sequence.java:206) at org.openfast.template.Group.decodeFieldValues(Group.java:293) at org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126) at org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:95) at org.openfast.MessageInputStream.readMessage(MessageInputStream.java:70) at local.Main.main(Main.java:38) {noformat} Could you please have a look.

    QuickFIX/J JIRA | 7 months ago | Alexander Piskarev
    java.lang.NegativeArraySizeException

    Root Cause Analysis

    1. java.lang.NegativeArraySizeException

      No message provided

      at org.openfast.ByteUtil.combine()
    2. org.openfast
      ByteUtil.combine
      1. org.openfast.ByteUtil.combine(ByteUtil.java:125)
      1 frame
    3. org.openfast.util
      Util.applyDifference
      1. org.openfast.util.Util.applyDifference(Util.java:82)
      1 frame
    4. org.openfast.template
      MessageTemplate.decode
      1. org.openfast.template.operator.DeltaStringOperatorCodec.decodeValue(DeltaStringOperatorCodec.java:77)
      2. org.openfast.template.Scalar.decodeValue(Scalar.java:174)
      3. org.openfast.template.Scalar.decode(Scalar.java:234)
      4. org.openfast.template.Group.decodeFieldValues(Group.java:293)
      5. org.openfast.template.Group.decodeFieldValues(Group.java:256)
      6. org.openfast.template.Group.decode(Group.java:223)
      7. org.openfast.template.Sequence.decode(Sequence.java:206)
      8. org.openfast.template.Group.decodeFieldValues(Group.java:293)
      9. org.openfast.template.MessageTemplate.decode(MessageTemplate.java:126)
      9 frames
    5. org.openfast.codec
      FastDecoder.readMessage
      1. org.openfast.codec.FastDecoder.readMessage(FastDecoder.java:95)
      1 frame
    6. org.openfast
      MessageInputStream.readMessage
      1. org.openfast.MessageInputStream.readMessage(MessageInputStream.java:70)
      1 frame
    7. local
      Main.main
      1. local.Main.main(Main.java:38)
      1 frame