Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C86218A3B for ; Wed, 29 Apr 2015 12:33:42 +0000 (UTC) Received: (qmail 41177 invoked by uid 500); 29 Apr 2015 12:33:40 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 41148 invoked by uid 500); 29 Apr 2015 12:33:40 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 41116 invoked by uid 99); 29 Apr 2015 12:33:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 12:33:40 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of root@apache.org designates 54.164.171.186 as permitted sender) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 12:33:36 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 8DEAE4544F for ; Wed, 29 Apr 2015 12:32:28 +0000 (UTC) Received: (qmail 35952 invoked by uid 99); 29 Apr 2015 12:32:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 12:32:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 088FAE083A; Wed, 29 Apr 2015 12:32:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Wed, 29 Apr 2015 12:33:08 -0000 Message-Id: In-Reply-To: <4eff1b4d060d48db95a0fc4bcd8af1a0@git.apache.org> References: <4eff1b4d060d48db95a0fc4bcd8af1a0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [43/50] incubator-ignite git commit: # ignite-sprint-4 added test X-Virus-Checked: Checked by ClamAV on apache.org # ignite-sprint-4 added test Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7d9df3d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7d9df3d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7d9df3d4 Branch: refs/heads/ignite-500 Commit: 7d9df3d43a3bfe89021784654ae4e0283c54af94 Parents: acc731c Author: sboikov Authored: Wed Apr 29 09:30:49 2015 +0300 Committer: sboikov Committed: Wed Apr 29 09:31:35 2015 +0300 ---------------------------------------------------------------------- .../distributed/GridCacheLockAbstractTest.java | 70 ++++++++++++++++++++ 1 file changed, 70 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d9df3d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java index 257f88a..72a64a1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.*; import javax.cache.*; import java.util.*; import java.util.concurrent.*; +import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -494,4 +495,73 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { fut1.get(); fut2.get(); } + + /** + * @throws Throwable If failed. + */ + public void testLockReentrancy() throws Throwable { + fail("https://issues.apache.org/jira/browse/IGNITE-835"); + + for (int i = 10; i < 100; i++) { + log.info("Key: " + i); + + final int i0 = i; + + final Lock lock = cache1.lock(i); + + lock.lockInterruptibly(); + + try { + final AtomicReference err = new AtomicReference<>(); + + Thread t = new Thread(new Runnable() { + @Override public void run() { + try { + assert !lock.tryLock(); + assert !lock.tryLock(100, TimeUnit.MILLISECONDS); + + assert !cache1.lock(i0).tryLock(); + assert !cache1.lock(i0).tryLock(100, TimeUnit.MILLISECONDS); + } + catch (Throwable e) { + err.set(e); + } + } + }); + + t.start(); + t.join(); + + if (err.get() != null) + throw err.get(); + + lock.lock(); + lock.unlock(); + + t = new Thread(new Runnable() { + @Override public void run() { + try { + assert !lock.tryLock(); + assert !lock.tryLock(100, TimeUnit.MILLISECONDS); + + assert !cache1.lock(i0).tryLock(); + assert !cache1.lock(i0).tryLock(100, TimeUnit.MILLISECONDS); + } + catch (Throwable e) { + err.set(e); + } + } + }); + + t.start(); + t.join(); + + if (err.get() != null) + throw err.get(); + } + finally { + lock.unlock(); + } + } + } }