You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/09/15 21:51:52 UTC

svn commit: r1703280 - in /maven/shared/trunk/maven-shared-utils/src: main/java/org/apache/maven/shared/utils/io/Java7Support.java test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java

Author: tibordigana
Date: Tue Sep 15 19:51:52 2015
New Revision: 1703280

URL: http://svn.apache.org/r1703280
Log:
[MSHARED-435] createSymbolicLink() ClassCastException

Modified:
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java
    maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java?rev=1703280&r1=1703279&r2=1703280&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java Tue Sep 15 19:51:52 2015
@@ -165,7 +165,20 @@ public class Java7Support
         catch ( InvocationTargetException e )
         {
             final Throwable targetException = e.getTargetException();
-            throw (IOException) targetException;
+            if ( targetException instanceof IOException )
+            {
+                throw (IOException) targetException;
+            }
+            else if ( targetException instanceof RuntimeException )
+            {
+                // java.lang.UnsupportedOperationException: Symbolic links not supported on this operating system
+                // java.lang.SecurityException: denies certain permissions see Javadoc
+                throw ( RuntimeException ) targetException;
+            }
+            else
+            {
+                throw new IOException( targetException.getClass() + ": " + targetException.getLocalizedMessage() );
+            }
         }
 
     }

Modified: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java?rev=1703280&r1=1703279&r2=1703280&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/Java7SupportTest.java Tue Sep 15 19:51:52 2015
@@ -25,6 +25,9 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assume.assumeThat;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
 
 public class Java7SupportTest
 {
@@ -39,11 +42,12 @@ public class Java7SupportTest
             assertFalse( Java7Support.isSymLink( file ) );
         }
     }
+
     @Test
     public void createAndReadSymlink()
         throws Exception
     {
-
+        assumeThat( System.getProperty( "os.name" ), is( not( "Windows XP" ) ) );
         File file = new File( "target/fzz" );
         if ( Java7Support.isAtLeastJava7() )
         {