logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r686149 - in /logging/log4j/trunk/src/main/java/org/apache/log4j: config/ helpers/ jmx/ net/ spi/ xml/
Date Fri, 15 Aug 2008 05:53:56 GMT
Author: carnold
Date: Thu Aug 14 22:53:55 2008
New Revision: 686149

URL: http://svn.apache.org/viewvc?rev=686149&view=rev
Log:
Bug 44157: InterruptedIOException ignored by log4j

Modified:
    logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertyGetter.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertySetter.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/Loader.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/OptionConverter.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/Agent.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketNode.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/net/TelnetAppender.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LoggingEvent.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/xml/DOMConfigurator.java

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertyGetter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertyGetter.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertyGetter.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertyGetter.java Thu Aug
14 22:53:55 2008
@@ -17,11 +17,17 @@
 
 package org.apache.log4j.config;
 
-import java.beans.*;
-import java.lang.reflect.*;
 import org.apache.log4j.Priority;
 import org.apache.log4j.helpers.LogLog;
 
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.InterruptedIOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 
 /**
    Used for inferring configuration information for a log4j's component.
@@ -77,8 +83,16 @@
 	if (result != null) {
 	  callback.foundProperty(obj, prefix, name, result);
 	}
-      } catch (Exception ex) {
-	LogLog.warn("Failed to get value of property " + name);
+      } catch (IllegalAccessException ex) {
+	    LogLog.warn("Failed to get value of property " + name);
+      } catch (InvocationTargetException ex) {
+        if (ex.getTargetException() instanceof InterruptedException
+                || ex.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }
+        LogLog.warn("Failed to get value of property " + name);
+      } catch (RuntimeException ex) {
+	    LogLog.warn("Failed to get value of property " + name);
       }
     }
   }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertySetter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertySetter.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertySetter.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/config/PropertySetter.java Thu Aug
14 22:53:55 2008
@@ -19,17 +19,23 @@
 
 package org.apache.log4j.config;
 
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.lang.reflect.*;
-import java.util.*;
-import org.apache.log4j.*;
+import org.apache.log4j.Appender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Priority;
 import org.apache.log4j.helpers.LogLog;
 import org.apache.log4j.helpers.OptionConverter;
 import org.apache.log4j.spi.OptionHandler;
 
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.InterruptedIOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.Properties;
+
 /**
    General purpose Object property setter. Clients repeatedly invokes
    {@link #setProperty setProperty(name,value)} in order to invoke setters
@@ -142,7 +148,17 @@
             setter.setProperties(properties, prefix + key + ".");
             try {
                 prop.getWriteMethod().invoke(this.obj, new Object[] { opt });
-            } catch(Exception ex) {
+            } catch(IllegalAccessException ex) {
+                LogLog.warn("Failed to set property [" + key +
+                            "] to value \"" + value + "\". ", ex);
+            } catch(InvocationTargetException ex) {
+                if (ex.getTargetException() instanceof InterruptedException
+                        || ex.getTargetException() instanceof InterruptedIOException) {
+                    Thread.currentThread().interrupt();
+                }
+                LogLog.warn("Failed to set property [" + key +
+                            "] to value \"" + value + "\". ", ex);
+            } catch(RuntimeException ex) {
                 LogLog.warn("Failed to set property [" + key +
                             "] to value \"" + value + "\". ", ex);
             }
@@ -226,7 +242,15 @@
     LogLog.debug("Setting property [" + name + "] to [" +arg+"].");
     try {
       setter.invoke(obj, new Object[]  { arg });
-    } catch (Exception ex) {
+    } catch (IllegalAccessException ex) {
+      throw new PropertySetterException(ex);
+    } catch (InvocationTargetException ex) {
+        if (ex.getTargetException() instanceof InterruptedException
+                || ex.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }        
+        throw new PropertySetterException(ex);
+    } catch (RuntimeException ex) {
       throw new PropertySetterException(ex);
     }
   }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/Loader.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/Loader.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/Loader.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/Loader.java Thu Aug 14 22:53:55
2008
@@ -21,6 +21,7 @@
 import java.lang.IllegalAccessException;
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
+import java.io.InterruptedIOException;
 
 
 /**
@@ -112,8 +113,19 @@
   	    return url;
   	  }
   	}
+    } catch(IllegalAccessException t) {
+        LogLog.warn(TSTR, t);
+    } catch(InvocationTargetException t) {
+        if (t.getTargetException() instanceof InterruptedException
+                || t.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }
+        LogLog.warn(TSTR, t);
     } catch(Throwable t) {
-  	LogLog.warn(TSTR, t);
+      //
+      //  can't be InterruptedException or InterruptedIOException
+      //    since not declared, must be error or RuntimeError.
+      LogLog.warn(TSTR, t);
     }
     
     // Last ditch attempt: get the resource from the class path. It
@@ -171,13 +183,19 @@
       return Class.forName(clazz);
     } else {
       try {
-	return getTCL().loadClass(clazz);
-      } catch(Throwable e) {
-	// we reached here because tcl was null or because of a
-	// security exception, or because clazz could not be loaded...
-	// In any case we now try one more time
-	return Class.forName(clazz);
+	    return getTCL().loadClass(clazz);
+      }
+      // we reached here because tcl was null or because of a
+      // security exception, or because clazz could not be loaded...
+      // In any case we now try one more time
+      catch(InvocationTargetException e) {
+          if (e.getTargetException() instanceof InterruptedException
+                  || e.getTargetException() instanceof InterruptedIOException) {
+              Thread.currentThread().interrupt();
+          }
+      } catch(Throwable t) {
       }
     }
-  } 
+    return Class.forName(clazz);
+  }
 }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/OptionConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/OptionConverter.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/OptionConverter.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/OptionConverter.java Thu Aug
14 22:53:55 2008
@@ -19,6 +19,9 @@
 
 import java.util.Properties;
 import java.net.URL;
+import java.io.InterruptedIOException;
+import java.lang.reflect.InvocationTargetException;
+
 import org.apache.log4j.Level;
 import org.apache.log4j.spi.Configurator;
 import org.apache.log4j.spi.LoggerRepository;
@@ -231,6 +234,10 @@
       LogLog.warn("custom level class [" + clazz + "]"
         + " does not have a class function toLevel(String, Level)", e);
     } catch(java.lang.reflect.InvocationTargetException e) {
+        if (e.getTargetException() instanceof InterruptedException
+                || e.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }
       LogLog.warn("custom level class [" + clazz + "]"
 		   + " could not be instantiated", e);
     } catch(ClassCastException e) {
@@ -239,7 +246,7 @@
     } catch(IllegalAccessException e) {
       LogLog.warn("class ["+clazz+
 		   "] cannot be instantiated due to access restrictions", e);
-    } catch(Exception e) {
+    } catch(RuntimeException e) {
       LogLog.warn("class ["+clazz+"], level ["+levelName+
 		   "] conversion failed.", e);
     }
@@ -328,8 +335,14 @@
 	  return defaultValue;
 	}
 	return classObj.newInstance();
-      } catch (Exception e) {
-	LogLog.error("Could not instantiate class [" + className + "].", e);
+      } catch (ClassNotFoundException e) {
+	    LogLog.error("Could not instantiate class [" + className + "].", e);
+      } catch (IllegalAccessException e) {
+	    LogLog.error("Could not instantiate class [" + className + "].", e);
+      } catch (InstantiationException e) {
+        LogLog.error("Could not instantiate class [" + className + "].", e);
+      } catch (RuntimeException e) {
+	    LogLog.error("Could not instantiate class [" + className + "].", e);
       }
     }
     return defaultValue;

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/Agent.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/Agent.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/Agent.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/Agent.java Thu Aug 14 22:53:55
2008
@@ -24,6 +24,7 @@
 import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 import java.lang.reflect.InvocationTargetException;
+import java.io.InterruptedIOException;
 
 
 /**
@@ -87,6 +88,10 @@
           if (cause instanceof RuntimeException) {
               throw (RuntimeException) cause;
           } else if (cause != null) {
+              if (cause instanceof InterruptedException
+                      || cause instanceof InterruptedIOException) {
+                  Thread.currentThread().interrupt();
+              }
               throw new RuntimeException(cause.toString());
           } else {
               throw new RuntimeException();

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java Thu Aug
14 22:53:55 2008
@@ -50,6 +50,7 @@
 import java.lang.reflect.Method;
 import java.util.Hashtable;
 import java.util.Vector;
+import java.io.InterruptedIOException;
 
 public class AppenderDynamicMBean extends AbstractDynamicMBean {
 
@@ -252,6 +253,10 @@
       } catch(IllegalAccessException e) {
 	    return null;
       } catch(InvocationTargetException e) {
+          if (e.getTargetException() instanceof InterruptedException
+                  || e.getTargetException() instanceof InterruptedIOException) {
+              Thread.currentThread().interrupt();
+          }
 	    return null;
       } catch(RuntimeException e) {
 	    return null;
@@ -308,7 +313,11 @@
 	mu.writeMethod.invoke(appender,  o);
 
       } catch(InvocationTargetException e) {
-	    cat.error("FIXME", e);
+        if (e.getTargetException() instanceof InterruptedException
+                || e.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }
+        cat.error("FIXME", e);
       } catch(IllegalAccessException e) {
 	    cat.error("FIXME", e);
       } catch(RuntimeException e) {

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java Thu Aug
14 22:53:55 2008
@@ -46,6 +46,7 @@
 import java.beans.BeanInfo;
 import java.beans.PropertyDescriptor;
 import java.beans.IntrospectionException;
+import java.io.InterruptedIOException;
 
 public class LayoutDynamicMBean extends AbstractDynamicMBean {
 
@@ -190,6 +191,10 @@
       try {
 	return mu.readMethod.invoke(layout, null);
       } catch(InvocationTargetException e) {
+          if (e.getTargetException() instanceof InterruptedException
+                  || e.getTargetException() instanceof InterruptedIOException) {
+              Thread.currentThread().interrupt();
+          }
 	    return null;
       } catch(IllegalAccessException e) {
 	    return null;
@@ -248,6 +253,10 @@
 	mu.writeMethod.invoke(layout,  o);
 
       } catch(InvocationTargetException e) {
+          if (e.getTargetException() instanceof InterruptedException
+                  || e.getTargetException() instanceof InterruptedIOException) {
+              Thread.currentThread().interrupt();
+          }
 	    cat.error("FIXME", e);
       } catch(IllegalAccessException e) {
 	    cat.error("FIXME", e);

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java Thu Aug
14 22:53:55 2008
@@ -372,6 +372,7 @@
           monitorThread.join();
         }
         catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
           // do nothing?
         }
         

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketNode.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketNode.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketNode.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketNode.java Thu Aug 14 22:53:55
2008
@@ -55,8 +55,12 @@
     try {
       ois = new ObjectInputStream(
                          new BufferedInputStream(socket.getInputStream()));
-    }
-    catch(Exception e) {
+    } catch(InterruptedIOException e) {
+      Thread.currentThread().interrupt();
+      logger.error("Could not open ObjectInputStream to "+socket, e);
+    } catch(IOException e) {
+      logger.error("Could not open ObjectInputStream to "+socket, e);
+    } catch(RuntimeException e) {
       logger.error("Could not open ObjectInputStream to "+socket, e);
     }
   }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/net/TelnetAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/net/TelnetAppender.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/net/TelnetAppender.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/net/TelnetAppender.java Thu Aug 14
22:53:55 2008
@@ -106,6 +106,7 @@
         try {
             sh.join();
         } catch(InterruptedException ex) {
+            Thread.currentThread().interrupt();
         }
     }
   }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java Thu Aug 14 22:53:55
2008
@@ -24,7 +24,9 @@
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.io.InterruptedIOException;
 import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 
 /**
    The internal representation of caller location information.
@@ -99,7 +101,9 @@
           getMethodNameMethod = stackTraceElementClass.getMethod("getMethodName", noArgs);
           getFileNameMethod = stackTraceElementClass.getMethod("getFileName", noArgs);
           getLineNumberMethod = stackTraceElementClass.getMethod("getLineNumber", noArgs);
-      } catch(Exception ex) {
+      } catch(ClassNotFoundException ex) {
+          LogLog.debug("LocationInfo will use pre-JDK 1.4 methods to determine location.");
+      } catch(NoSuchMethodException ex) {
           LogLog.debug("LocationInfo will use pre-JDK 1.4 methods to determine location.");
       }
   }
@@ -167,7 +171,15 @@
                   prevClass = thisClass;
               }
               return;
-          } catch(Exception ex) {
+          } catch(IllegalAccessException ex) {
+              LogLog.debug("LocationInfo failed using JDK 1.4 methods", ex);
+          } catch(InvocationTargetException ex) {
+              if (ex.getTargetException() instanceof InterruptedException
+                      || ex.getTargetException() instanceof InterruptedIOException) {
+                  Thread.currentThread().interrupt();
+              }
+              LogLog.debug("LocationInfo failed using JDK 1.4 methods", ex);
+          } catch(RuntimeException ex) {
               LogLog.debug("LocationInfo failed using JDK 1.4 methods", ex);
           }
       }

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LoggingEvent.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LoggingEvent.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LoggingEvent.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LoggingEvent.java Thu Aug 14 22:53:55
2008
@@ -27,6 +27,7 @@
 
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.InterruptedIOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Collections;
@@ -439,7 +440,11 @@
 	level = (Level) m.invoke(null,  PARAM_ARRAY);
       }
     } catch(InvocationTargetException e) {
-	LogLog.warn("Level deserialization failed, reverting to default.", e);
+        if (e.getTargetException() instanceof InterruptedException
+                || e.getTargetException() instanceof InterruptedIOException) {
+            Thread.currentThread().interrupt();
+        }
+    LogLog.warn("Level deserialization failed, reverting to default.", e);
 	level = Level.toLevel(p);
     } catch(NoSuchMethodException e) {
 	LogLog.warn("Level deserialization failed, reverting to default.", e);

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/xml/DOMConfigurator.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/xml/DOMConfigurator.java?rev=686149&r1=686148&r2=686149&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/xml/DOMConfigurator.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/xml/DOMConfigurator.java Thu Aug 14
22:53:55 2008
@@ -52,6 +52,7 @@
 import java.io.InterruptedIOException;
 import java.io.Reader;
 import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.util.Hashtable;
 import java.util.Properties;
@@ -403,10 +404,18 @@
 	 Method getInstanceMethod = clazz.getMethod("getLogger", 
 						    ONE_STRING_PARAM);
 	 cat = (Logger) getInstanceMethod.invoke(null, new Object[] {catName});
+       } catch (InvocationTargetException oops) {
+          if (oops.getTargetException() instanceof InterruptedException
+                  || oops.getTargetException() instanceof InterruptedIOException) {
+              Thread.currentThread().interrupt();
+          }
+          LogLog.error("Could not retrieve category ["+catName+
+		      "]. Reported error follows.", oops);
+	      return;
        } catch (Exception oops) {
-	 LogLog.error("Could not retrieve category ["+catName+
+	      LogLog.error("Could not retrieve category ["+catName+
 		      "]. Reported error follows.", oops);
-	 return;
+	      return;
        }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message