<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBoss cache. Concurrency issue
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/aaauser">Anton K</a> in <i>JBoss Cache</i> - <a href="http://community.jboss.org/message/636461#636461">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p style="margin-bottom: 1em; font-size: 14px; background-color: #ffffff; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">I'm using <em>JBossCache 'Malagueta' 3.2.0.GA</em></p><p style="margin-bottom: 1em; font-size: 14px; background-color: #ffffff; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">I faced with strange issue in production environment, sometimes writes to jboss are lost. I tried to reproduce this situation with simple java application</p><pre class="lang-java prettyprint" style="margin-bottom: 10px; font-size: 14px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: #000000; padding: 5px;"><code style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span class="kwd" style="color: #00008b;">public</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">static</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">void</span><span class="pln"> testCache</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="typ" style="color: #2b91af;">Cache</span><span class="pln"> cache </span><span class="pun">=</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">new</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">DefaultCacheFactory</span><span class="pun">().</span><span class="pln">createCache</span><span class="pun">(</span><span class="kwd" style="color: #00008b;">false</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160; cache</span><span class="pun">.</span><span class="pln">create</span><span class="pun">();</span><span class="pln"><br/>&#160;&#160;&#160; cache</span><span class="pun">.</span><span class="pln">start</span><span class="pun">();</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">final</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">Node</span><span class="pln"> node </span><span class="pun">=</span><span class="pln"> cache</span><span class="pun">.</span><span class="pln">getRoot</span><span class="pun">().</span><span class="pln">addChild</span><span class="pun">(</span><span class="typ" style="color: #2b91af;">Fqn</span><span class="pun">.</span><span class="pln">fromString</span><span class="pun">(</span><span class="str" style="color: #800000;">"/child1"</span><span class="pun">));</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">int</span><span class="pln"> threadsCount </span><span class="pun">=</span><span class="pln"> </span><span class="lit" style="color: #800000;">20</span><span class="pun">;</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">final</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">CyclicBarrier</span><span class="pln"> b </span><span class="pun">=</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">new</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">CyclicBarrier</span><span class="pun">(</span><span class="pln">threadsCount</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd" style="color: #00008b;">int</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit" style="color: #800000;">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> threadsCount</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">final</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">long</span><span class="pln"> j </span><span class="pun">=</span><span class="pln"> i</span><span class="pun">;</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">new</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">Thread</span><span class="pun">(</span><span class="kwd" style="color: #00008b;">new</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">Runnable</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="lit" style="color: #800000;">@Override</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">public</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">void</span><span class="pln"> run</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">try</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; b</span><span class="pun">.</span><span class="pln">await</span><span class="pun">();</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="typ" style="color: #2b91af;">String</span><span class="pln"> name </span><span class="pun">=</span><span class="pln"> </span><span class="typ" style="color: #2b91af;">RandomGenerator</span><span class="pun">.</span><span class="pln">getRandomName</span><span class="pun">(</span><span class="lit" style="color: #800000;">4</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; node</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="pln">j</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="typ" style="color: #2b91af;">String</span><span class="pln"> nameFromCache </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ" style="color: #2b91af;">String</span><span class="pun">)</span><span class="pln"> node</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">j</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="kwd" style="color: #00008b;">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">name</span><span class="pun">.</span><span class="pln">equals</span><span class="pun">(</span><span class="pln">nameFromCache</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="typ" style="color: #2b91af;">System</span><span class="pun">.</span><span class="pln">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str" style="color: #800000;">"error"</span><span class="pun">);</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="pun">}</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="pun">}</span><span class="pln"> </span><span class="kwd" style="color: #00008b;">catch</span><span class="pln"> </span><span class="pun">(</span><span class="typ" style="color: #2b91af;">Exception</span><span class="pln"> e</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e</span><span class="pun">.</span><span class="pln">printStackTrace</span><span class="pun">();</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="pun">}</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="pun">}</span><span class="pln"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="pun">}).</span><span class="pln">start</span><span class="pun">();</span><span class="pln"><br/>&#160;&#160;&#160; </span><span class="pun">}</span><span class="pln"><br/></span><span class="pun">}</span><span class="pln"><br/></span></code></pre><p style="margin-bottom: 1em; font-size: 14px; background-color: #ffffff; color: #000000; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">From time to time, this test output "error", which i run from <code style="padding-top: 1px; padding-right: 5px; padding-bottom: 1px; padding-left: 5px; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">static void mai</code>. 1 of 3 runs return "error" msg, node simply return "null".&#160; I can't reproduce it on every machine</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/636461#636461">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Cache at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2052">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>