You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2011/02/15 20:39:01 UTC

svn commit: r1071027 - /maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java

Author: bentmann
Date: Tue Feb 15 19:39:01 2011
New Revision: 1071027

URL: http://svn.apache.org/viewvc?rev=1071027&view=rev
Log:
o Improved robustness against incompatible event spies

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java?rev=1071027&r1=1071026&r2=1071027&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java Tue Feb 15 19:39:01 2011
@@ -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,16 +131,26 @@ 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 );
         }
     }