xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

Handling deserializing new Values on enums with UNKNOWN_ENUM_VALUE_(enumName)_(newValue) #105

Open nbergaoui opened 2 years ago

nbergaoui commented 2 years ago

Hi all , We are using the proto version 3.0.0 and your plugin to generate deserialization classes from our protobuf files . Here is the version used :

org.xolstice.maven.plugins
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>0.5.0</version>
          <configuration>
              <protocArtifact>com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}</protocArtifact>
          </configuration>

Now when we look at our proto file it looks like that :

enum TypeCreneauProto { UNKNOWN_TYPE_CRENEAU_PROTO = 0; JOURNEE = 1; MATINEE = 2; APRES_MIDI = 3; DEBUT_MATINEE = 4; FIN_MATINEE = 5; DEBUT_APRES_MIDI = 6; FIN_APRES_MIDI = 7; AU_PLUS_TOT = 8; }

When we receive a value 9 , well it is supposed to put the value to the default one ie : UNKNOWN_TYPE_CRENEAU_PROTO , but it still creates a new value non exiting on our enum

UNKNOWN_ENUM_VALUE_TypeCreneauProto_9

this causes us trouble when serialising back to other formats . Why does it bevave this way ? It looks like a bug as what is annouced it that it get to the default value ( set to 0 on the top of the enum ) The field is optionnal ( no mention for the "optional" tag as we are using proto 3.0.0

Can you please get back to me on this issue ? Thanks