Return-Path: X-Original-To: apmail-gora-dev-archive@www.apache.org Delivered-To: apmail-gora-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6E24C18A04 for ; Fri, 28 Aug 2015 20:13:46 +0000 (UTC) Received: (qmail 53083 invoked by uid 500); 28 Aug 2015 20:13:46 -0000 Delivered-To: apmail-gora-dev-archive@gora.apache.org Received: (qmail 53045 invoked by uid 500); 28 Aug 2015 20:13:46 -0000 Mailing-List: contact dev-help@gora.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@gora.apache.org Delivered-To: mailing list dev@gora.apache.org Received: (qmail 53030 invoked by uid 99); 28 Aug 2015 20:13:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Aug 2015 20:13:46 +0000 Date: Fri, 28 Aug 2015 20:13:46 +0000 (UTC) From: "Lewis John McGibbney (JIRA)" To: dev@gora.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GORA-228) java.util.ConcurrentModificationException when using MemStore for concurrent tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GORA-228?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D147204= 94#comment-14720494 ]=20 Lewis John McGibbney commented on GORA-228: ------------------------------------------- Thank you [~icebergx5] and [~cguzel] > java.util.ConcurrentModificationException when using MemStore for concurr= ent tests > -------------------------------------------------------------------------= --------- > > Key: GORA-228 > URL: https://issues.apache.org/jira/browse/GORA-228 > Project: Apache Gora > Issue Type: Sub-task > Components: gora-core > Affects Versions: 0.3 > Reporter: Lewis John McGibbney > Assignee: Yasin K=C4=B1l=C4=B1n=C3=A7 > Fix For: 0.7 > > Attachments: GORA-228.patch, GORA-228v2.patch > > > Finally, a multithreaded test in [3] fails with the following > {code} > java.util.ConcurrentModificationException > =09at java.util.TreeMap$NavigableSubMap$SubMapIterator.nextEntry(TreeMap.= java:1594) > =09at java.util.TreeMap$NavigableSubMap$SubMapKeyIterator.next(TreeMap.ja= va:1655) > =09at org.apache.gora.memory.store.MemStore$MemResult.nextInner(MemStore.= java:81) > =09at org.apache.gora.query.impl.ResultBase.next(ResultBase.java:112) > =09at org.apache.nutch.storage.TestGoraStorage.readWrite(TestGoraStorage.= java:74) > =09at org.apache.nutch.storage.TestGoraStorage.access$100(TestGoraStorage= .java:41) > =09at org.apache.nutch.storage.TestGoraStorage$1.call(TestGoraStorage.jav= a:107) > =09at org.apache.nutch.storage.TestGoraStorage$1.call(TestGoraStorage.jav= a:102) > =09at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) > =09at java.util.concurrent.FutureTask.run(FutureTask.java:166) > =09at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecuto= r.java:1110) > =09at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecut= or.java:603) > =09at java.lang.Thread.run(Thread.java:722) > {code} > I believe that the final failure is due to to the use of TreeMap [5] as a= private object in MemStore. TreeMap implementations are not synchronized. = If multiple threads access a map concurrently, and at least one of the thre= ads modifies the map structurally, it must be synchronized externally. (A s= tructural modification is any operation that adds or deletes one or more ma= ppings; merely changing the value associated with an existing key is not a = structural modification.) This is typically accomplished by synchronizing o= n some object that naturally encapsulates the map. If no such object exists= , the map should be "wrapped" using the Collections.synchronizedSortedMap m= ethod. This is best done at creation time, to prevent accidental unsynchron= ized access to the map e.g. > SortedMap m =3D Collections.synchronizedSortedMap(new TreeMap(...)); > N.B. The NOTE on TreeMap's come right from the Oracle JavaDoc. > [3] http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/n= utch/storage/TestGoraStorage.java?view=3Dmarkup > [4] http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/n= utch/util/AbstractNutchTest.java?view=3Dmarkup > [5] http://docs.oracle.com/javase/6/docs/api/java/util/TreeMap.html -- This message was sent by Atlassian JIRA (v6.3.4#6332)