maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r1057209 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-core/src/main/java/org/apache/maven/
Date Mon, 10 Jan 2011 14:14:28 GMT
Author: bentmann
Date: Mon Jan 10 14:14:28 2011
New Revision: 1057209

URL: http://svn.apache.org/viewvc?rev=1057209&view=rev
Log:
o Fixed exception handling for repo metadata to properly report edge cases of inaccessible
files

Modified:
    maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
    maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java

Modified: maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java?rev=1057209&r1=1057208&r2=1057209&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
(original)
+++ maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java
Mon Jan 10 14:14:28 2011
@@ -20,7 +20,6 @@ package org.apache.maven.repository.inte
  */
 
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -212,17 +211,13 @@ public class DefaultVersionRangeResolver
         FileInputStream fis = null;
         try
         {
-            if ( metadata != null && metadata.getFile() != null )
+            if ( metadata != null && metadata.getFile() != null && metadata.getFile().exists()
)
             {
                 fis = new FileInputStream( metadata.getFile() );
                 org.apache.maven.artifact.repository.metadata.Metadata m = new MetadataXpp3Reader().read(
fis, false );
                 versioning = m.getVersioning();
             }
         }
-        catch ( FileNotFoundException e )
-        {
-            // tolerable
-        }
         catch ( Exception e )
         {
             invalidMetadata( session, metadata, repository, e );

Modified: maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java?rev=1057209&r1=1057208&r2=1057209&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
(original)
+++ maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
Mon Jan 10 14:14:28 2011
@@ -21,7 +21,6 @@ package org.apache.maven.repository.inte
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -281,7 +280,7 @@ public class DefaultVersionResolver
         FileInputStream fis = null;
         try
         {
-            if ( metadata != null && metadata.getFile() != null )
+            if ( metadata != null && metadata.getFile() != null && metadata.getFile().exists()
)
             {
                 fis = new FileInputStream( metadata.getFile() );
                 org.apache.maven.artifact.repository.metadata.Metadata m = new MetadataXpp3Reader().read(
fis, false );
@@ -309,10 +308,6 @@ public class DefaultVersionResolver
                 }
             }
         }
-        catch ( FileNotFoundException e )
-        {
-            // tolerable
-        }
         catch ( Exception e )
         {
             invalidMetadata( session, metadata, repository, e );

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java?rev=1057209&r1=1057208&r2=1057209&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java
Mon Jan 10 14:14:28 2011
@@ -19,6 +19,8 @@ package org.apache.maven;
  * under the License.
  */
 
+import java.io.FileNotFoundException;
+
 import org.codehaus.plexus.logging.Logger;
 import org.sonatype.aether.AbstractRepositoryListener;
 import org.sonatype.aether.RepositoryEvent;
@@ -74,6 +76,8 @@ class LoggingRepositoryListener
     @Override
     public void metadataInvalid( RepositoryEvent event )
     {
+        Exception exception = event.getException();
+
         StringBuilder buffer = new StringBuilder( 256 );
         buffer.append( "The metadata " );
         if ( event.getMetadata().getFile() != null )
@@ -84,16 +88,25 @@ class LoggingRepositoryListener
         {
             buffer.append( event.getMetadata() );
         }
-        buffer.append( " is invalid" );
-        if ( event.getException() != null )
+
+        if ( exception instanceof FileNotFoundException )
+        {
+            buffer.append( " is inaccessible" );
+        }
+        else
+        {
+            buffer.append( " is invalid" );
+        }
+
+        if ( exception != null )
         {
             buffer.append( ": " );
-            buffer.append( event.getException().getMessage() );
+            buffer.append( exception.getMessage() );
         }
 
         if ( logger.isDebugEnabled() )
         {
-            logger.warn( buffer.toString(), event.getException() );
+            logger.warn( buffer.toString(), exception );
         }
         else
         {



Mime
View raw message