On Thu, 2005-07-14 at 13:02 +0200, Mark Wielaard wrote:
> Hi,
> 
> On Wed, 2005-07-13 at 21:54 +0200, Guilhem Lavaux wrote:
> > 2005-07-13  Guilhem Lavaux  <[EMAIL PROTECTED]>
> > 
> >         * java/util/logging/Logger.java
> >         (resetLogger): Remove all handlers from the handler list.
> > 
> >         * java/util/logging/LogManager.java
> >         (reset): Call resetLogger() too.
> >         (readConfiguration): Call reset() and use the system class
> >     loader to resolve classes.
> 

Hi Mark,

> Better would be to have a mechanism for defining the class loader to
> load the handlers (or use the Thread context class loader to do it). But
> this is probably the best we can do given the current interface. And it
> seems compatible with other implementations.
> 

Yes. That was the problem I met. However as I've pointed out in sun's
bug database, Sun has chosen to use the system class loader. I think we
must add this in our javadoc.

> > --- java/util/logging/LogManager.java   2 Jul 2005 20:32:44 -0000       1.14
> > +++ java/util/logging/LogManager.java   13 Jul 2005 18:43:41 -0000
> > @@ -443,6 +443,7 @@
> >           {
> >             logger = (Logger) ref.get();
> >  
> > +           logger.resetLogger();
> >             if (logger == null)
> >               iter.remove();
> >             else if (logger != rootLogger)
> 
> logger can be null here since it comes from a WeakReference, so put the
> resetLogger() call in the else branch.
> 
Done. Thanks.


> > This patch fixes this PR (against kaffe):
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=307983
> 
> Could this be turned into a mauve test that calls readConfiguration() to
> test that everything works?
> 

Yes. I'll add it asap.

> Please commit this with the fixlet pointed out above.
> 
> Thanks,
> 
> Mark

New patch attached, change log unchanged.

Guilhem.


Index: java/util/logging/LogManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/logging/LogManager.java,v
retrieving revision 1.14
diff -u -r1.14 LogManager.java
--- java/util/logging/LogManager.java	2 Jul 2005 20:32:44 -0000	1.14
+++ java/util/logging/LogManager.java	14 Jul 2005 13:05:41 -0000
@@ -446,11 +446,15 @@
 	    if (logger == null)
 	      iter.remove();
 	    else if (logger != rootLogger)
-	      logger.setLevel(null);
+	      {
+	        logger.resetLogger();
+	        logger.setLevel(null);
+	      }
 	  }
       }
 
     rootLogger.setLevel(Level.INFO);
+    rootLogger.resetLogger();
   }
 
   /**
@@ -513,6 +517,7 @@
     checkAccess();
     newProperties = new Properties();
     newProperties.load(inputStream);
+    reset();
     this.properties = newProperties;
     keys = newProperties.propertyNames();
 
@@ -534,7 +539,7 @@
 		String handlerName = tokenizer.nextToken();
 		try
 		  {
-		    Class handlerClass = Class.forName(handlerName);
+		    Class handlerClass = ClassLoader.getSystemClassLoader().loadClass(handlerName);
 		    getLogger("").addHandler((Handler) handlerClass
 		                             .newInstance());
 		  }
Index: java/util/logging/Logger.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/logging/Logger.java,v
retrieving revision 1.9
diff -u -r1.9 Logger.java
--- java/util/logging/Logger.java	2 Jul 2005 20:32:44 -0000	1.9
+++ java/util/logging/Logger.java	14 Jul 2005 13:05:42 -0000
@@ -1177,4 +1177,17 @@
     return stackTrace[index];
   }
   
+  /**
+   * Reset and close handlers attached to this logger. This function is package
+   * private because it must only be avaiable to the LogManager.
+   */
+  void resetLogger()
+  {
+    for (int i = 0; i < handlers.length; i++)
+      {
+        handlers[i].close();
+        handlerList.remove(handlers[i]);
+      }
+    handlers = getHandlers();
+  }
 }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to