mirror of https://github.com/apache/maven.git
o Fixed exception handling for repo metadata to properly report edge cases of inaccessible files
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1057209 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e60779cbb
commit
34146f5e76
|
@ -20,7 +20,6 @@ package org.apache.maven.repository.internal;
|
|||
*/
|
||||
|
||||
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 );
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.maven.repository.internal;
|
|||
|
||||
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 );
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue