o Improved robustness against incompatible event spies

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1071027 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-02-15 19:39:01 +00:00
parent a0584affae
commit ad9b6eba2a
1 changed files with 29 additions and 27 deletions

View File

@ -85,15 +85,11 @@ public class EventSpyDispatcher
}
catch ( Exception e )
{
String msg = "Failed to initialize spy " + eventSpy.getClass().getName() + ": " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
}
else
{
logger.warn( msg );
}
logError( "initialize", e, eventSpy );
}
catch ( LinkageError e )
{
logError( "initialize", e, eventSpy );
}
}
}
@ -112,15 +108,11 @@ public class EventSpyDispatcher
}
catch ( Exception e )
{
String msg = "Failed to forward event to spy " + eventSpy.getClass().getName() + ": " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
}
else
{
logger.warn( msg );
}
logError( "notify", e, eventSpy );
}
catch ( LinkageError e )
{
logError( "notify", e, eventSpy );
}
}
}
@ -139,17 +131,27 @@ public class EventSpyDispatcher
}
catch ( Exception e )
{
String msg = "Failed to close spy " + eventSpy.getClass().getName() + ": " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
}
else
{
logger.warn( msg );
}
logError( "close", e, eventSpy );
}
catch ( LinkageError e )
{
logError( "close", e, eventSpy );
}
}
}
private void logError( String action, Throwable e, EventSpy spy )
{
String msg = "Failed to " + action + " spy " + spy.getClass().getName() + ": " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
}
else
{
logger.warn( msg );
}
}
}