[
https://issues.jboss.org/browse/SHRINKWRAP-380?page=com.atlassian.jira.pl...
]
Samuel Santos updated SHRINKWRAP-380:
-------------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request:
https://github.com/shrinkwrap/resolver/pull/14
Hi Karel,
For the former, {{new File("target/profile-repository").delete();}} was not
deleting the directory, but was also not throwing an {{IOException}}, sorry I missed it.
Solution, update file deletion in {{FileUtil#removeDirectory()}} from:
{code}
if (!entry.delete()) {
throw new IOException("Could not delete directory " +
directory.getAbsolutePath());
}
{code}
to (don't ask!):
{code}
if (!entry.delete()) {
System.gc();
Thread.sleep(10);
if (!entry.delete()) {
throw new IOException("Could not delete file " +
entry.getAbsolutePath());
}
}
{code}
For the later, using {{File.separator}} will not do it either.
The method {{ResourceUtil#temporaryFile()}} is always called with a path parameter using
the character '/' as the separator (e.g.
org/jboss/shrinkwrap/profiles/settings3.xml).
{code}
System.out.println(resourceName); // Outputs org/jboss/shrinkwrap/profiles/settings3.xml
resourceName = resourceName.replaceAll("/".equals(File.separator) ?
"/" : "\\\\", "-").replaceAll(File.pathSeparator,
"-").replaceAll("\\s", "-");
System.out.println(resourceName); // Outputs org/jboss/shrinkwrap/profiles/settings3.xml
{code}
In order to make sure that it does work in all cases I've changed it to:
{code}
System.out.println(resourceName); // Outputs org/jboss/shrinkwrap/profiles/settings3.xml
resourceName = resourceName.replaceAll("/",
"-").replaceAll("\\\\", "-").replaceAll(File.pathSeparator,
"-").replaceAll("\\s", "-");
System.out.println(resourceName); // Outputs org-jboss-shrinkwrap-profiles-settings3.xml
{code}
Integration tests with errors on Windows caused by File separator
-----------------------------------------------------------------
Key: SHRINKWRAP-380
URL:
https://issues.jboss.org/browse/SHRINKWRAP-380
Project: ShrinkWrap
Issue Type: Bug
Components: ext-resolver
Reporter: Samuel Santos
Assignee: Samuel Santos
Line 43 of ArtifactDependenciesUnitTestCase.java outputs the following error:
{noformat}
testPomBasedArtifactLocatedInClassPath(org.jboss.shrinkwrap.resolver.impl.maven.ArtifactDependenciesUnitTestCase)
Time elapsed: 0.034 sec <<< ERROR!
java.io.IOException: Could not delete directory
f:\projects\GitHub\resolver\impl-maven\target\profile-repository\org\jboss\shrinkwrap\test\test-dependency\1.0.0
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:48)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at org.jboss.shrinkwrap.resolver.util.FileUtil.removeDirectory(FileUtil.java:45)
at
org.jboss.shrinkwrap.resolver.impl.maven.ArtifactDependenciesUnitTestCase.cleanup(ArtifactDependenciesUnitTestCase.java:43)
{noformat}
Changing the line from:
{code}
FileUtil.removeDirectory(new File("target/profile-repository"));
{code}
to:
{code}
new File("target/profile-repository").delete();
{code}
fixes it.
Line 75 of ResourceUtil.java outputs the following error:
{noformat}
testPomBasedArtifactLocatedInClassPath(org.jboss.shrinkwrap.resolver.impl.maven.ArtifactDependenciesUnitTestCase)
Time elapsed: 0.17 sec <<< ERROR!
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
at java.util.regex.Pattern.error(Pattern.java:1924)
at java.util.regex.Pattern.compile(Pattern.java:1671)
at java.util.regex.Pattern.<init>(Pattern.java:1337)
at java.util.regex.Pattern.compile(Pattern.java:1022)
at java.lang.String.replaceAll(String.java:2210)
at
org.jboss.shrinkwrap.resolver.impl.maven.util.ResourceUtil.temporaryFile(ResourceUtil.java:75)
at
org.jboss.shrinkwrap.resolver.impl.maven.util.ResourceUtil.getLocalResourcePathFromResourceName(ResourceUtil.java:51)
at
org.jboss.shrinkwrap.resolver.impl.maven.util.ResourceUtil.resolvePathByQualifier(ResourceUtil.java:62)
at
org.jboss.shrinkwrap.resolver.impl.maven.MavenDependencyResolverImpl.configureFrom(MavenDependencyResolverImpl.java:28)
at
org.jboss.shrinkwrap.resolver.impl.maven.ArtifactDependenciesUnitTestCase.testPomBasedArtifactLocatedInClassPath(ArtifactDependenciesUnitTestCase.java:89)
{noformat}
Changing the line from:
{code}
File localResource = new File(tmpDir, resourceName.replaceAll(File.separator,
"-").replaceAll(File.pathSeparator, "-").replaceAll("\\s",
"-"));
{code}
to:
{code}
File localResource = new File(tmpDir, resourceName.replaceAll("/",
"-").replaceAll(File.pathSeparator, "-").replaceAll("\\s",
"-"));
{code}
fixes it.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira