Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 47CC3200B0F for ; Thu, 2 Jun 2016 18:31:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 46878160A5E; Thu, 2 Jun 2016 16:31:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 77FC8160A3E for ; Thu, 2 Jun 2016 18:31:43 +0200 (CEST) Received: (qmail 98348 invoked by uid 500); 2 Jun 2016 16:31:42 -0000 Mailing-List: contact commits-help@commonsrdf.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commonsrdf.incubator.apache.org Delivered-To: mailing list commits@commonsrdf.incubator.apache.org Received: (qmail 98294 invoked by uid 99); 2 Jun 2016 16:31:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 16:31:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2FEED180591 for ; Thu, 2 Jun 2016 16:31:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id RX-KC0uAs7u8 for ; Thu, 2 Jun 2016 16:31:39 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 76A185F247 for ; Thu, 2 Jun 2016 16:31:39 +0000 (UTC) Received: (qmail 96674 invoked by uid 99); 2 Jun 2016 16:31:38 -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; Thu, 02 Jun 2016 16:31:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7B54DE040E; Thu, 2 Jun 2016 16:31:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: stain@apache.org To: commits@commonsrdf.incubator.apache.org Date: Thu, 02 Jun 2016 16:31:41 -0000 Message-Id: In-Reply-To: <443e20e125384a86912cc45fedc99020@git.apache.org> References: <443e20e125384a86912cc45fedc99020@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/46] incubator-commonsrdf git commit: COMMONSRDF-8 use ConcurrentHashMap in test archived-at: Thu, 02 Jun 2016 16:31:44 -0000 COMMONSRDF-8 use ConcurrentHashMap in test ..and .parallel().forEach() not for speed, but because it triggered a bug Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/d4a9c95b Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/d4a9c95b Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/d4a9c95b Branch: refs/heads/quad Commit: d4a9c95bf0752ffe2de09132c5ae3c39c3809f83 Parents: e1203fd Author: Stian Soiland-Reyes Authored: Fri Apr 10 10:10:26 2015 +0100 Committer: Stian Soiland-Reyes Committed: Sat Mar 12 18:28:17 2016 +0000 ---------------------------------------------------------------------- .../org/apache/commons/rdf/api/AbstractGraphTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d4a9c95b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java index d6a5f9d..a301654 100644 --- a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java +++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import org.junit.Assume; import org.junit.Before; @@ -294,10 +295,11 @@ public abstract class AbstractGraphTest { IRI name = factory.createIRI("http://xmlns.com/foaf/0.1/name"); - final Map whoIsWho = new HashMap<>(); - System.out.println(g3.getTriples(null, name, null).count()); - // NOTE: sequential as our HashMap is not thread-safe - g3.getTriples(null, name, null).sequential().forEach( t -> + final Map whoIsWho = new ConcurrentHashMap<>(); + // ConcurrentHashMap as we will try parallel forEach below, + // which should not give inconsistent results (it does with a + // HashMap!) + g3.getTriples(null, name, null).parallel().forEach( t -> whoIsWho.put( t.getObject().ntriplesString(), t.getSubject())); assertEquals(4, whoIsWho.size()); // and contains 4 unique values @@ -357,7 +359,7 @@ public abstract class AbstractGraphTest { protected static void copyTriples(Graph source, Graph target) { // unordered() as we don't need to preserve triple order - // sequential() as we don't require target Graph to be thread-safe + // sequential() as we don't (currently) require target Graph to be thread-safe source.getTriples().unordered().sequential().forEach(t -> target.add(t)); }