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

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

                Author: ASF GitHub Bot
            Created on: 07/Feb/22 19:05
            Start Date: 07/Feb/22 19:05
    Worklog Time Spent: 10m 
      Work Description: RyanSkraba merged pull request #1521:
URL: https://github.com/apache/avro/pull/1521


   


-- 
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: 722190)
    Time Spent: 0.5h  (was: 20m)

> velocity fails to find file by absolute path on windows
> -------------------------------------------------------
>
>                 Key: AVRO-3371
>                 URL: https://issues.apache.org/jira/browse/AVRO-3371
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.11.0
>            Reporter: radai rosenblatt
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> when building master on windows, I get the following failure in the 
> avro-maven-plugin java module:
> {code:java}
> [INFO] Running org.apache.avro.mojo.TestIDLProtocolMojo
> [ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.2 s 
> <<< FAILURE! - in org.apache.avro.mojo.TestIDLProtocolMojo
> [ERROR] 
> org.apache.avro.mojo.TestIDLProtocolMojo.testSetCompilerVelocityAdditionalTools
>   Time elapsed: 0.06 s  <<< ERROR!
> java.lang.RuntimeException: 
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find 
> resource 
> 'C:\Users\radai\work\avro\lang\java\maven-plugin/src/test/resources/templates/enum.vm'
>         at 
> org.apache.avro.compiler.specific.SpecificCompiler.renderTemplate(SpecificCompiler.java:551)
>         at 
> org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:629)
>         at 
> org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:538)
>         at 
> org.apache.avro.mojo.IDLProtocolMojo.doCompile(IDLProtocolMojo.java:107)
>         at 
> org.apache.avro.mojo.AbstractAvroMojo.compileFiles(AbstractAvroMojo.java:281)
>         at 
> org.apache.avro.mojo.AbstractAvroMojo.execute(AbstractAvroMojo.java:231)
>         at 
> org.apache.avro.mojo.TestIDLProtocolMojo.testSetCompilerVelocityAdditionalTools(TestIDLProtocolMojo.java:68)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at junit.framework.TestCase.runTest(TestCase.java:177)
>         at junit.framework.TestCase.runBare(TestCase.java:142)
>         at junit.framework.TestResult$1.protect(TestResult.java:122)
>         at junit.framework.TestResult.runProtected(TestResult.java:142)
>         at junit.framework.TestResult.run(TestResult.java:125)
>         at junit.framework.TestCase.run(TestCase.java:130)
>         at junit.framework.TestSuite.runTest(TestSuite.java:241)
>         at junit.framework.TestSuite.run(TestSuite.java:236)
>         at 
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
>         at org.junit.runners.Suite.runChild(Suite.java:128)
>         at org.junit.runners.Suite.runChild(Suite.java:27)
>         at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
>         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
>         at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
>         at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
>         at org.junit.runners.Suite.runChild(Suite.java:128)
>         at org.junit.runners.Suite.runChild(Suite.java:27)
>         at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
>         at 
> org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:405)
>         at 
> org.apache.maven.surefire.junitcore.pc.InvokerStrategy.schedule(InvokerStrategy.java:54)
>         at 
> org.apache.maven.surefire.junitcore.pc.Scheduler.schedule(Scheduler.java:362)
>         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
>         at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
>         at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
>         at 
> org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder$PC$1.run(ParallelComputerBuilder.java:590)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCore.run(JUnitCore.java:55)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:137)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:107)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:83)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:75)
>         at 
> org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:157)
>         at 
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
>         at 
> org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
>         at 
> org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
>         at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
> Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to 
> find resource 
> 'C:\Users\radai\work\avro\lang\java\maven-plugin/src/test/resources/templates/enum.vm'
>         at 
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:465)
>         at 
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:346)
>         at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1677)
>         at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1656)
>         at 
> org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:314)
>         at 
> org.apache.avro.compiler.specific.SpecificCompiler.renderTemplate(SpecificCompiler.java:549)
>         ... 50 more {code}
> this fails 2 other tests in the same module as well:
> {code:java}
> [ERROR] Errors:
> [ERROR]   TestIDLProtocolMojo.testSetCompilerVelocityAdditionalTools:68 ▒ 
> Runtime org.ap...
> [ERROR]   TestProtocolMojo.testSetCompilerVelocityAdditionalTools:59 ▒ 
> Runtime org.apach...
> [ERROR]   TestSchemaMojo.testSetCompilerVelocityAdditionalTools:59 ▒ Runtime 
> org.apache.... {code}
> the root issue as far as i can tell seems to be this velocity configuration 
> in SpecificCompiler:
> {code:java}
> private void initializeVelocity() {
>    ...
>    velocityEngine.addProperty("resource.loader.file.path", "/, .");
>    ...
> } {code}
> which defines 2 "root paths": "/" and "."
> however, under windows and given a path of the form "C:/<whatever>" this will 
> try looking for either "/C:/<whatever>" or "./C:/<whatever>" - both are 
> "wrong" for a windows absolute path.
> relevant code is in 
> org.apache.velocity.runtime.resource.loader.FileResourceLoader.getFile():
> {code:java}
> private File getFile(String path, String template) {
>    File file = null; 
>    if("".equals(path)) {
>       file = new File( template );   <---- NEVER TAKEN
>    } else {
>       if (template.startsWith("/")) {
>          template = template.substring(1);
>       }
>       file = new File ( path, template );
>    }
>    return file;
> }{code}
> quickest fix i can think of is add "" as a 3rd possible root to velocity 
> config in class SpecificCompiler



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to