rouzwawi / grpc-kotlin

gRPC with Kotlin Coroutines
https://gitter.im/gRPC-Kotlin/Lobby
Apache License 2.0
219 stars 22 forks source link

enum with same name causes compile failure #39

Closed rscorer closed 5 years ago

rscorer commented 5 years ago

This message compiles using java grpc compiler, and causes a failure using grpcKotlin

message Iso3166 {
    message Alpha2 {
        enum Country {
            UNKNOWN = 0;
            AF = 1;
        }
    }
    message Alpha3 {
        enum Country {
            UNKNOWN = 0;
            AF = 1;
        }
    }
    message Name {
        enum Country {
            UNKNOWN = 0;
            AF = 1;
        }
    }
}   
> protoc: stdout: . stderr: java.lang.IllegalArgumentException: Multiple entries with same key: .protos.Iso3166.Country=io.systems.adtech.protos.null.Iso3166.Country and .protos.Iso3166.Country=io.systems.adtech.protos.null.Iso3166.Country
        at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:136)
        at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:100)
        at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:86)
        at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:300)
        at com.salesforce.jprotoc.ProtoTypeMap.of(ProtoTypeMap.java:69)
        at io.rouz.grpc.kotlin.GrpcKotlinGenerator.generateFiles(GrpcKotlinGenerator.java:67)
        at com.salesforce.jprotoc.ProtocPlugin.lambda$generate$1(ProtocPlugin.java:81)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
        at java.util.Collections$2.tryAdvance(Collections.java:4717)
        at java.util.Collections$2.forEachRemaining(Collections.java:4725)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
        at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at com.salesforce.jprotoc.ProtocPlugin.generate(ProtocPlugin.java:86)
        at com.salesforce.jprotoc.ProtocPlugin.generate(ProtocPlugin.java:45)
        at com.salesforce.jprotoc.ProtocPlugin.generate(ProtocPlugin.java:37)
        at io.rouz.grpc.kotlin.GrpcKotlinGenerator.main(GrpcKotlinGenerator.java:61)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
  --grpckotlin_out: protoc-gen-grpckotlin: Plugin failed with status code 1.

If I rename the three enum Country so that they are different, then it compiles using grpcKotlin

rouzwawi commented 5 years ago

Hi!

This looks like an old bug that existed in jProtoc (https://github.com/salesforce/grpc-java-contrib/issues/98). I see now that I haven't released a new version of grpc-kotlin since that upgrade, sorry for that. I'll make push a new release now, this bug should then go away if you upgrade to 0.1.1.

rscorer commented 5 years ago

Hi,

Thanks for the quick reply - that sounds perfect :smile:

Thanks!! I'll upgrade to 0.1.1

rouzwawi commented 5 years ago

The new version should be available in Maven Central now

rscorer commented 5 years ago

It is, and its fixed the issue, thanks!