[jboss-user] [JBoss Cache] - JBoss cache. Concurrency issue

Anton K do-not-reply at jboss.com
Mon Nov 14 12:26:44 EST 2011


Anton K [http://community.jboss.org/people/aaauser] created the discussion

"JBoss cache. Concurrency issue"

To view the discussion, visit: http://community.jboss.org/message/636461#636461

--------------------------------------------------------------
I'm using +JBossCache 'Malagueta' 3.2.0.GA+
I faced with strange issue in production environment, sometimes writes to jboss are lost. I tried to reproduce this situation with simple java application
public static void testCache() {
    Cache cache = new DefaultCacheFactory().createCache(false);
    cache.create();
    cache.start();
    final Node node = cache.getRoot().addChild(Fqn.fromString("/child1"));
    int threadsCount = 20;
    final CyclicBarrier b = new CyclicBarrier(threadsCount);
    for (int i = 0; i < threadsCount; i++) {
        final long j = i;
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    b.await();
                    String name = RandomGenerator.getRandomName(4);
                    node.put(j, name);
                    String nameFromCache = (String) node.get(j);
                    if (!name.equals(nameFromCache)) {
                        System.out.println("error");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}

>From time to time, this test output "error", which i run from static void mai. 1 of 3 runs return "error" msg, node simply return "null".  I can't reproduce it on every machine
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/636461#636461]

Start a new discussion in JBoss Cache at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2052]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111114/96e06d31/attachment.html 


More information about the jboss-user mailing list