Cannot resolve method 'merge(String, Builder)' on JsonFormat after upgrading protobuf-java-util from 3.25.3 -> 4.26.0

25 views Asked by At

We are currently using the following Maven dependency:

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <version>3.25.3</version>
        </dependency>

We tried upgrading to version 4.26.0 but are receiving compilation issues now. This code worked fine in the 3.X version:

Selection.Builder selectionBuilder = Selection.newBuilder();
JsonFormat.parser().ignoringUnknownFields().merge(selectionJson, selectionBuilder);

... while it doesn't work anymore in the 4.X version. The compilation error is:

 no suitable method found for merge(java.lang.String,com.tomtom.orbis.pcs.contentselections.v1.Selection.Builder)
[ERROR]     method com.google.protobuf.util.JsonFormat.Parser.merge(java.lang.String,com.google.protobuf.Message.Builder) is not applicable
[ERROR]       (argument mismatch; com.tomtom.orbis.pcs.contentselections.v1.Selection.Builder cannot be converted to com.google.protobuf.Message.Builder)
[ERROR]     method com.google.protobuf.util.JsonFormat.Parser.merge(java.io.Reader,com.google.protobuf.Message.Builder) is not applicable
[ERROR]       (argument mismatch; java.lang.String cannot be converted to java.io.Reader)

So I wanted to see what changed between 3.X -> 4.X, but I can't even find a tag on https://github.com/protocolbuffers/protobuf that corresponds to the version that I got from https://central.sonatype.com/

Any ideas what's causing this compilation error? Jochen

0

There are 0 answers