Skip to content

Commit

Permalink
Merge pull request square#3051 from chriscizek/proto5-support
Browse files Browse the repository at this point in the history
Fix support for protobuf 3.5+
  • Loading branch information
JakeWharton authored Mar 19, 2019
2 parents bad7f77 + 083bf24 commit 46dc939
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 662 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

<!-- Converter Dependencies -->
<gson.version>2.8.2</gson.version>
<protobuf.version>3.0.0</protobuf.version>
<protobuf.version>3.5.0</protobuf.version>
<jackson.version>2.9.8</jackson.version>
<wire.version>2.2.0</wire.version>
<simplexml.version>2.7.1</simplexml.version>
Expand Down
24 changes: 24 additions & 0 deletions retrofit-converters/protobuf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,31 @@
</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<executions>
<execution>
<phase>generate-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<protoTestSourceRoot>src/test/protos</protoTestSourceRoot>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ final class ProtoResponseBodyConverter<T extends MessageLite>

@Override public T convert(ResponseBody value) throws IOException {
try {
return parser.parseFrom(value.byteStream(), registry);
return registry == null ? parser.parseFrom(value.byteStream())
: parser.parseFrom(value.byteStream(), registry);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e); // Despite extending IOException, this is data mismatch.
} finally {
Expand Down
4 changes: 0 additions & 4 deletions retrofit-converters/protobuf/src/test/gen-protos.sh

This file was deleted.

Loading

0 comments on commit 46dc939

Please sign in to comment.