Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java wrappers.proto broken since 3.0.0 following GeneratedMessage versionning? #2017

Closed
ltkn opened this issue Aug 26, 2016 · 7 comments
Closed

Comments

@ltkn
Copy link

ltkn commented Aug 26, 2016

Hi,

I can't use Int32Value on proto3 since 3.0.0 (was working fine on 3.0.0-beta-4).
possibly related to 2e30301 and the versionning of GeneratedMessage.

broken code below

Int32Value extends GeneratedMessageV3 but SingleFieldBuilder extends GeneratedMessage

 private com.google.protobuf.SingleFieldBuilder<
          com.google.protobuf.Int32Value, com.google.protobuf.Int32Value.Builder, com.google.protobuf.Int32ValueOrBuilder> 
          getDurationMinutesFieldBuilder() {
        if (durationMinutesBuilder_ == null) {
          durationMinutesBuilder_ = new com.google.protobuf.SingleFieldBuilder<
              com.google.protobuf.Int32Value, com.google.protobuf.Int32Value.Builder, com.google.protobuf.Int32ValueOrBuilder>(
                  getDurationMinutes(),
                  getParentForChildren(),
                  isClean());
          durationMinutes_ = null;
        }
        return durationMinutesBuilder_;
      }

thanks

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Aug 26, 2016

Old generated code won't work with protobuf 3.0.0 runtime. I think you just need to update your genreated code by running the latest protoc.

@ltkn
Copy link
Author

ltkn commented Aug 27, 2016

I did regenerate the code, but then the code doesn't compile anymore for the reasons mentionned earlier, we're using https://github.com/xolstice/protobuf-maven-plugin for code generation.

Let me know if you believe I'm not doing it correclty. thanks.

@ltkn
Copy link
Author

ltkn commented Sep 3, 2016

Could you please label it as a bug? thanks.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 6, 2016

Int32Value is part of protobuf library itself (included in protobuf-java.jar maven artifact), so if you have the correct dependency, you shouldn't need to compile it from source. This seems to me a problem in your build setup.

@Helcaraxan
Copy link

I am facing the same problem (although with other types than Int32Value).

Proto files following syntax = "proto2" (and not possible to upgrade to "proto3"). All code regenerated with "protoc" compiled from the v3.0.2 tag.

The SingleFieldBuilder class should extend GeneratedMessageV3 as stated in the initial issue report but it extends GeneratedMessage instead.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 19, 2016

If you have regenerated the code using the latest protoc, it should not have "SingleFieldBuilder" in the generated code, but instead "SingleFieldBuilderV3". I still think the problem is the use of an out-dated protoc somewhere in your build config.

@ltkn
Copy link
Author

ltkn commented Oct 29, 2016

It was a maven dependency issue in our case, problem fixed.

If someone has the same problem you might want to check that you're using all proto deps in the same versions (including those inherited from parent poms)

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants