<HTML >
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</HEAD>
<BODY lang=EN-US link=blue vlink=purple>
<DIV>
<div class=Section1>
<p class=MsoNormal>Hi,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>We have hit the exception mentioned in the subject in one of
our applications. We are using JDK 6 and Logback 0.9.14. Here is the
stacktrace:<o:p></o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Caused
by: java.lang.IllegalMonitorStateException<br>
at
java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:363)<br>
at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1253)<br>
at
java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:745)<br>
at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:64)<br>
at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)<br>
at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)<br>
at
ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:439)<br>
at ch.qos.logback.classic.Logger.filterAndLog_1(Logger.java:411)<br>
at ch.qos.logback.classic.Logger.debug(Logger.java:504)</span><o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I have checked the code and it seems to me this can only
happen if the readLock.lock() method throws an exception:<o:p></o:p></p>
<pre><strong><span style='font-family:"Courier New"'>public</span></strong> <strong><span
style='font-family:"Courier New"'>int</span></strong> appendLoopOnAppenders(E e) {<o:p></o:p></pre><pre><a
name=56></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#56">56</a> <strong><span
style='font-family:"Courier New"'>int</span></strong> size = 0;<o:p></o:p></pre><pre><a
name=57></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#57">57</a> <strong><span
style='font-family:"Courier New"'>try</span></strong> {<o:p></o:p></pre><pre><a
name=58></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#58">58</a> r.lock();<o:p></o:p></pre><pre><a
name=59></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#59">59</a> <strong><span
style='font-family:"Courier New"'>for</span></strong> (Appender<E> appender : appenderList) {<o:p></o:p></pre><pre><a
name=60></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#60">60</a> appender.doAppend(e);<o:p></o:p></pre><pre><a
name=61></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#61">61</a> size++;<o:p></o:p></pre><pre><a
name=62></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#62">62</a> }<o:p></o:p></pre><pre><a
name=63></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#63">63</a> } <strong><span
style='font-family:"Courier New"'>finally</span></strong> {<o:p></o:p></pre><pre><a
name=64></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#64">64</a> r.unlock();<o:p></o:p></pre><pre><a
name=65></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#65">65</a> }<o:p></o:p></pre><pre><a
name=66></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#66">66</a> <strong><span
style='font-family:"Courier New"'>return</span></strong> size;<o:p></o:p></pre><pre><a
name=67></a><a
href="http://logback.qos.ch/xref/ch/qos/logback/core/spi/AppenderAttachableImpl.html#67">67</a> }<o:p></o:p></pre>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>if r.lock() in line 58 throws an exception for some reason
than in the finally block the unlock will throw also an exception which will
hide the original one. I cannot see any other reason why the unlock would throw
this exception in this scenario. I am not yet able to reproduce it, but I thought
this exception worth a mail. The only suggestion I have for now is to move the
r.lock() call out of the try block, because if that is the bad guy, than we
would have the original exception propagated.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>If I have more information on this issue I will update this
thread.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Regards,<o:p></o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:black'>Zoltan Szel<br>
</span><b><span style='font-size:7.5pt;font-family:"Arial","sans-serif";
color:black'>Morgan Stanley | IDEAS PRACTICE AREAS<br>
</span></b><span style='font-size:7.5pt;font-family:"Arial","sans-serif";
color:black'>Lechner Odon fasor 8 | Floor 07<br>
Budapest, 1095<br>
Phone: +36 1 881-3978<br>
<a href="mailto:Zoli.Szel@MorganStanley.com"><span style='color:blue'>Zoli.Szel@MorganStanley.com</span></a></span><o:p></o:p></p>
</div>
</DIV>
<DIV>
<HR>
</DIV>
<P CLASS="BulletedList" STYLE="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0in; mso-list: none; tab-stops: .5in"><SPAN STYLE="FONT-SIZE: 8pt; COLOR: gray; mso-bidi-font-family: Arial"><FONT FACE="Arial" COLOR="gray" SIZE="1">NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.</FONT></SPAN></P>
<DIV>
</DIV></BODY></HTML>