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 ) catch ( Exception e )
{ {
String msg = "Failed to initialize spy " + eventSpy.getClass().getName() + ": " + e.getMessage(); logError( "initialize", e, eventSpy );
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
} }
else catch ( LinkageError e )
{ {
logger.warn( msg ); logError( "initialize", e, eventSpy );
}
} }
} }
} }
@ -112,15 +108,11 @@ public class EventSpyDispatcher
} }
catch ( Exception e ) catch ( Exception e )
{ {
String msg = "Failed to forward event to spy " + eventSpy.getClass().getName() + ": " + e.getMessage(); logError( "notify", e, eventSpy );
if ( logger.isDebugEnabled() )
{
logger.warn( msg, e );
} }
else catch ( LinkageError e )
{ {
logger.warn( msg ); logError( "notify", e, eventSpy );
}
} }
} }
} }
@ -139,7 +131,19 @@ public class EventSpyDispatcher
} }
catch ( Exception e ) catch ( Exception e )
{ {
String msg = "Failed to close spy " + eventSpy.getClass().getName() + ": " + e.getMessage(); 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() ) if ( logger.isDebugEnabled() )
{ {
logger.warn( msg, e ); logger.warn( msg, e );
@ -149,7 +153,5 @@ public class EventSpyDispatcher
logger.warn( msg ); logger.warn( msg );
} }
} }
}
}
} }