[ 
https://issues.apache.org/jira/browse/AVRO-3095?focusedWorklogId=660775&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-660775
 ]

ASF GitHub Bot logged work on AVRO-3095:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Oct/21 08:43
            Start Date: 06/Oct/21 08:43
    Worklog Time Spent: 10m 
      Work Description: martin-g commented on a change in pull request #1157:
URL: https://github.com/apache/avro/pull/1157#discussion_r723016811



##########
File path: 
lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
##########
@@ -150,12 +164,15 @@ public class Idl implements Closeable {
         throw error(key+" values must be textual: "+n, token);
     return values;
   }
-  
+
   private URL findFile(String importFile) throws IOException {
-    File file = new File(this.inputDir, importFile);
+    URI uri = this.inputDir.resolve(importFile);
+    File file = "file".equals(uri.getScheme()) ? new File(uri.getPath()) : 
null;
     URL result = null;
-    if (file.exists())
-      result = file.toURL();
+    if (file != null && file.exists())
+      result = file.toURI().toURL();
+    else if("classpath".equals(uri.getScheme()))
+      result = this.resourceLoader.getResource(uri.getPath().substring(1));
     else if (this.resourceLoader != null)

Review comment:
       The check here suggests that `this.resourceLoader` could be `null`. It 
seems now line 175 could lead to NullPointerException.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 660775)
    Time Spent: 20m  (was: 10m)

> Unable to resolve relative imports in resources
> -----------------------------------------------
>
>                 Key: AVRO-3095
>                 URL: https://issues.apache.org/jira/browse/AVRO-3095
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.10.2
>            Reporter: Anatoly Kupriyanov
>            Assignee: Anatoly Kupriyanov
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.11.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> If an imported avdl file is inside a classpath resource, then relative 
> imports don't work. Example:
> these files should be packaged inside .jar and be on the classpath:
> {code}
> // OnTheClasspath.avdl
> protocol OnTheClasspath {
>   import idl "folder/relativePath.avdl";
> }
> // folder/relativePath.avdl
> @namespace("org.on.the.classpath")
> protocol OnTheClasspathDependency {
>       import idl "../nestedtypes.avdl";
> }
> // nestedtypes.avdl
> @namespace("org.on.the.classpath")
> protocol OnTheClasspathTypes {
>   record NestedType {
>   }
> }
> {code}
> In this scenario {{import idl "../nestedtypes.avdl"}} fails.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to