amaechler commented on code in PR #18770:
URL: https://github.com/apache/druid/pull/18770#discussion_r2550580267


##########
extensions-core/protobuf-extensions/src/test/java/org/apache/druid/data/input/protobuf/FileBasedProtobufBytesDecoderTest.java:
##########
@@ -68,6 +69,16 @@ public void testMoreComplexProtoFile()
     assertEquals("prototest.ProtoNestedEvent", 
decoder.getDescriptor().getFullName());
   }
 
+  @Test
+  public void tesDescriptorUrl()

Review Comment:
   ```suggestion
     public void testDescriptorUrl()
   ```



##########
extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/FileBasedProtobufBytesDecoder.java:
##########
@@ -56,9 +58,27 @@ public String getDescriptorFilePath()
   @Override
   protected DescriptorProtos.FileDescriptorSet loadFileDescriptorSet()
   {
-    try (InputStream fin = 
this.getClass().getClassLoader().getResourceAsStream(descriptorFilePath)) {
+    InputStream fin;
+    try {
+      fin = 
this.getClass().getClassLoader().getResourceAsStream(descriptorFilePath);
       if (fin == null) {
-        throw new ParseException(descriptorFilePath, "Descriptor not found in 
class path [%s]", descriptorFilePath);
+        URL url;
+        try {
+          url = new URL(descriptorFilePath);
+        }
+        catch (MalformedURLException e) {
+          throw new ParseException(
+              descriptorFilePath,
+              e,
+              "Descriptor not found in class path or malformed URL: [%s]", 
descriptorFilePath
+              );
+        }
+        try {
+          fin = url.openConnection().getInputStream();
+        }

Review Comment:
   Do we need some resource handling for this inputstream in case 
`DescriptorProtos.FileDescriptorSet.parseFrom` fails below and properly close 
the stream again? Maybe just by refactoring a bit and then doing `try (fin = 
url.openConnection().getInputStream()) {` ...



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to