jihoonson commented on a change in pull request #8623: Consolidate and bump the
protobuf version
URL: https://github.com/apache/druid/pull/8623#discussion_r398204731
##########
File path:
extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/ProtobufInputRowParser.java
##########
@@ -127,49 +127,59 @@ void initDescriptor()
private Descriptor getDescriptor(String descriptorFilePath)
{
- InputStream fin;
-
- fin =
this.getClass().getClassLoader().getResourceAsStream(descriptorFilePath);
+ InputStream fin =
this.getClass().getClassLoader().getResourceAsStream(descriptorFilePath);
if (fin == null) {
- URL url;
try {
- url = new URL(descriptorFilePath);
+ final URL url = new URL(descriptorFilePath);
+ fin = url.openConnection().getInputStream();
}
catch (MalformedURLException e) {
throw new ParseException(e, "Descriptor not found in class path or
malformed URL:" + descriptorFilePath);
}
- try {
- fin = url.openConnection().getInputStream();
- }
catch (IOException e) {
- throw new ParseException(e, "Cannot read descriptor file: " + url);
+ throw new ParseException(e, "Cannot read descriptor file: " +
descriptorFilePath);
}
}
- DynamicSchema dynamicSchema;
+ final DescriptorProtos.FileDescriptorProto schema;
try {
- dynamicSchema = DynamicSchema.parseFrom(fin);
- }
- catch (Descriptors.DescriptorValidationException e) {
- throw new ParseException(e, "Invalid descriptor file: " +
descriptorFilePath);
+ final DescriptorProtos.FileDescriptorSet set =
DescriptorProtos.FileDescriptorSet.parseFrom(fin);
+ schema = set.getFile(0);
Review comment:
Should we check the set size?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]