mirror of
https://github.com/apache/maven.git
synced 2025-03-08 17:49:15 +00:00
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 @@
|
||||
*/
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -212,17 +211,13 @@ private Versioning readVersions( RepositorySystemSession session, Metadata metad
|
||||
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 @@
|
||||
|
||||
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 @@ private Versioning readVersions( RepositorySystemSession session, Metadata metad
|
||||
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 @@ private Versioning readVersions( RepositorySystemSession session, Metadata metad
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
// tolerable
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
invalidMetadata( session, metadata, repository, e );
|
||||
|
@ -19,6 +19,8 @@
|
||||
* 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 @@ else if ( logger.isDebugEnabled() )
|
||||
@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 @@ public void metadataInvalid( RepositoryEvent event )
|
||||
{
|
||||
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…
x
Reference in New Issue
Block a user