scalapb / ScalaPB

Protocol buffer compiler for Scala.
https://scalapb.github.io/
Apache License 2.0
1.3k stars 281 forks source link

java.lang.ArrayIndexOutOfBoundsException #482

Closed vishrantgupta closed 6 years ago

vishrantgupta commented 6 years ago
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.Arrays$ArrayList.get(Arrays.java:3841)
    at java.util.Collections$UnmodifiableList.get(Collections.java:1309)
    at com.trueaccord.scalapb.GeneratedEnum$class.javaValueDescriptor(GeneratedMessageCompanion.scala:26)
thesamet commented 6 years ago

@vishrantgupta can you provide instructions on how to reproduce this exception - an example of a proto file and a code that triggers this exception?

Based on the class name com.trueaccord you are using an older version of ScalaPB, can you check if this still occurs on the latest version?

vishrantgupta commented 6 years ago

@thesamet that is true, my company was using older version of ScalaPB to generate Scala files. This issue arises when I was trying to print the default values of ENUM types.

thesamet commented 6 years ago

You are most likely observing issue #225 which has been resolved a while ago. Are you able to upgrade to the latest version?

vishrantgupta commented 6 years ago

No that will be a big change. But will give it a try.

thesamet commented 6 years ago

The issue happens when you are trying to print an unrecognized enum. An unrecognized enum can occur when the sending system sends an enum value that is not supported by the system that parses it. A possible workaround, if you are unable to upgrade, would be clear the value before you print.

Upgrade tips for v0.7 are here https://scalapb.github.io/migrating.html#migrating-to-scalapb-07x

I'll be closing this issue for now, however if this issue persists on the newest version, please feel free to file a new bug.