[shrinkwrap-issues] [JBoss JIRA] (SHRINKRES-217) FileUtil.fileFromClassLoaderResource() creates non-unique temporary file

Falko M. (JIRA) issues at jboss.org
Fri Feb 6 14:05:49 EST 2015


    [ https://issues.jboss.org/browse/SHRINKRES-217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038339#comment-13038339 ] 

Falko M. edited comment on SHRINKRES-217 at 2/6/15 2:05 PM:
------------------------------------------------------------

Thinking about the approach in general, I am asking myself: Why can't you just use {{new File(url.toURI())}}(?)

Edit: Just forget this comment, I wasn't reading the source code properly.


was (Author: famod):
Thinking about the approach in general, I am asking myself: Why can't you just use {{new File(url.toURI())}}(?)

> FileUtil.fileFromClassLoaderResource() creates non-unique temporary file
> ------------------------------------------------------------------------
>
>                 Key: SHRINKRES-217
>                 URL: https://issues.jboss.org/browse/SHRINKRES-217
>             Project: ShrinkWrap Resolvers
>          Issue Type: Bug
>          Components: maven
>    Affects Versions: 2.0.2
>            Reporter: Falko M.
>
> {{org.jboss.shrinkwrap.resolver.impl.maven.util.FileUtil}} copies a classpath file to the system temp directory (defined by {{java.io.tmpdir}}) to be able to work with it as a plain file.
> The problem is that the file name is used *as is*.
> Now imagine multiple maven-surefire processes running Tests using the same classpath resource. They all and up trying to write a file with the same name in a (more or less) global temporary directory.
> Because of this we have seen multiple build failures on or Jenkins CI machine which uses {{-T...}} and {{-DforkCount=...}} liberally like this one:
> {noformat}Caused by: org.jboss.shrinkwrap.resolver.api.InvalidConfigurationFileException: Found 1 problems while building POM model from /tmp/someproject-main-continuous-1.1.1/META-INF-maven-com.somecompany.someproject-middleware-common-test-pom.xml
> 1/ [FATAL] Non-readable POM /tmp/someproject-main-continuous-1.1.1/META-INF-maven-com.somecompany.someproject-middleware-common-test-pom.xml: no more data available - expected end tags </version></dependency></dependencies></project> to close start tag <version> from line 75 and start tag <dependency> from line 77 and start tag <dependencies> from line 48 and start tag <project> from line 2, parser stopped on TEXT seen ...<dependency>\n            <gro... @78:17 @ /tmp/someproject-main-continuous-1.1.1/META-INF-maven-com.somecompany.someproject-middleware-common-test-pom.xml{noformat}
> Solution:
> Instead of:
> {{File tmpDir = new File(SecurityActions.getProperty("java.io.tmpdir"));}}
> use:
> {{java.io.File.createTempFile(...)}}
> which generates a file name that will most likely be "unique" for a certain time.



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the shrinkwrap-issues mailing list