Thank you Andy. This bug was not necessarily an easy one to catch.
I write crappy code and within a few days a smart person fixes it. Hey, I could get used to this but I don't think people would put up with it for long though. :-)
At 12:27 AM 6/21/2003 +0100, you wrote:
Hi,
The following patch seems to fix the problem of LogManager.shutdown() hanging.
Regards
Andy
Index: src/java/org/apache/log4j/Category.java
===================================================================
RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/Category.java,v
retrieving revision 1.74
diff -u -r1.74 Category.java
--- src/java/org/apache/log4j/Category.java 3 Jun 2003
20:30:56 -0000 1.74
+++ src/java/org/apache/log4j/Category.java 20 Jun 2003
22:04:37 -0000
@@ -485,6 +485,7 @@
} else {
result = aai.getAllAppenders();
}
+ lock.releaseReadLock();
return result;
}
On Thu, 19 Jun 2003 01:58:22 +0100 "Andy McBride" <[EMAIL PROTECTED]> wrote: > The following test class seems to hang at > LogManager.shutdown() when run with the jar produced by > the > current cvs build (1.3alpha 18/06/03). This does not > occur > with the released 1.2.8 jar. > > Further investigation points towards a deadlock in > ReaderWriterLock. Printing out the existing debug lines > in > ReaderWriterLock to sysout produces the following output > when run with the test class and config below: > > Only tried on win2k pro. with jdk: > > java version "1.4.0" > Java(TM) 2 Runtime Environment, Standard Edition (build > 1.4.0-b92) > Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode) > > > > ReaderWriterLock: Asking for write lock > ReaderWriterLock: Got write lock > ReaderWriterLock: About to release write lock > piblicID: [null] > systemId: [dummy://log4j.dtd] > log4j: Threshold ="null". > ReaderWriterLock: Asking for write lock > ReaderWriterLock: Got write lock > ReaderWriterLock: About to release write lock > log4j: Class name: [org.apache.log4j.ConsoleAppender] > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > log4j: xml.DOMConfigurator - Handling nested <layout> > for > appender CONSOLE > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > log4j: config.PropertySetter - Found setter method for > property [layout] in class org.apache.log4j. > ConsoleAppender > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > log4j: xml.DOMConfigurator - Will instantiate instance > of > class [org.apache.log4j.SimpleLayout] > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > log4j: config.PropertySetter - Set child component of > type > [org.apache.log4j.SimpleLayout] for [org > .apache.log4j.ConsoleAppender]. > ReaderWriterLock: About to release read lock > log4j: Adding appender named [CONSOLE] to category > [root]. > ReaderWriterLock: Asking for write lock > ReaderWriterLock: Got write lock > ReaderWriterLock: About to release write lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > DEBUG - Test debug message > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > INFO - Test info message > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > WARN - Test warn message > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ERROR - Test error message > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: About to release read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > FATAL - Test fatal message > java.lang.Exception: Test Exception > at com.jade.logtest.Tester2.<init>(Tester2.java:16) > at com.jade.logtest.Tester2.main(Tester2.java:26) > ReaderWriterLock: About to release read lock > Tester2: logging finished > Tester2: shutting down log4j: > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: Asking for read lock > ReaderWriterLock: Got read lock > ReaderWriterLock: Asking for write lock > > <<<!--- hangs here ---!>>> > > > test class: > > package com.jade.logtest; > > import org.apache.log4j.LogManager; > import org.apache.log4j.Logger; > > public class Tester2 > { > private Logger log = Logger.getLogger(Tester2.class); > > public Tester2() > { > log.debug("Test debug message"); > log.info("Test info message"); > log.warn("Test warn message"); > log.error("Test error message"); > log.fatal("Test fatal message", new Exception("Test > Exception")); > System.out.println("Tester2: logging finished"); > > System.out.println("Tester2: shutting down log4j:"); > LogManager.shutdown(); > System.out.println("Tester2: log4j has been > shutdown"); > } > > public static void main(String[] args) > { > new Tester2(); > } > } > > > > test config: > > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> > > <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" > debug="true"> > > <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> > <layout class="org.apache.log4j.SimpleLayout"/> > </appender> > > <root> > <appender-ref ref="CONSOLE"/> > </root> > > </log4j:configuration> > > > > I'm posting this to the dev list to see if somebody can > confirm i'm not being stupid. If so i can log it as a > bug > if required. > > Regards > > Andy > The information contained in this e-mail is intended only > for the person or > entity to which it is addressed and may contain > confidential and/or > privileged material. If You are not the intended > recipient of this e-mail, > the use of this information or any disclosure, copying or > distribution is > Prohibited and may be unlawful. If you received this in > error, please > contact the sender and delete the material from any > computer. The views > expressed in this e-mail may not necessarily be the views > of The PCMS Group > plc and should not be taken as authority to carry out any > instruction > contained. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] >
The information contained in this e-mail is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If You are not the intended recipient of this e-mail, the use of this information or any disclosure, copying or distribution is Prohibited and may be unlawful. If you received this in error, please contact the sender and delete the material from any computer. The views expressed in this e-mail may not necessarily be the views of The PCMS Group plc and should not be taken as authority to carry out any instruction contained.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
Ceki For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]