[
https://issues.apache.org/jira/browse/AVRO-3371?focusedWorklogId=721294&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-721294
]
ASF GitHub Bot logged work on AVRO-3371:
----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Feb/22 00:33
Start Date: 05/Feb/22 00:33
Worklog Time Spent: 10m
Work Description: radai-rosenblatt opened a new pull request #1521:
URL: https://github.com/apache/avro/pull/1521
this is to be able to load resources by absolute path on windows
…
Make sure you have checked _all_ steps below.
### Jira
- [ ] My PR addresses the following [Avro
Jira](https://issues.apache.org/jira/browse/AVRO/) issues and references them
in the PR title. For example, "AVRO-1234: My Avro PR"
- https://issues.apache.org/jira/browse/AVRO-3371
- In case you are adding a dependency, check if the license complies with
the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
### Tests
- [ ] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason:
fixes 3 existing unit tests to pass on windows:
TestIDLProtocolMojo.testSetCompilerVelocityAdditionalTools
TestProtocolMojo.testSetCompilerVelocityAdditionalTools
TestSchemaMojo.testSetCompilerVelocityAdditionalTools
### Commits
- [ ] My commits all reference Jira issues in their subject lines. In
addition, my commits follow the guidelines from "[How to write a good git
commit message](https://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
### Documentation
- [ ] In case of new functionality, my PR adds documentation that describes
how to use it.
- All the public functions and the classes in the PR contain Javadoc that
explain what it does
--
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: 721294)
Remaining Estimate: 0h
Time Spent: 10m
> 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
> Time Spent: 10m
> 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)