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 65647200D2A for ; Sat, 28 Oct 2017 19:35:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 640FB160BE1; Sat, 28 Oct 2017 17:35:34 +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 5A9DF160BDC for ; Sat, 28 Oct 2017 19:35:33 +0200 (CEST) Received: (qmail 26762 invoked by uid 500); 28 Oct 2017 17:35:32 -0000 Mailing-List: contact dev-help@netbeans.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@netbeans.incubator.apache.org Delivered-To: mailing list dev@netbeans.incubator.apache.org Received: (qmail 26751 invoked by uid 99); 28 Oct 2017 17:35:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Oct 2017 17:35:32 +0000 From: GitBox To: dev@netbeans.apache.org Subject: [GitHub] matthiasblaesing closed pull request #200: Module review project ant Message-ID: <150921213174.15334.1491029621014498166.gitbox@gitbox.apache.org> archived-at: Sat, 28 Oct 2017 17:35:34 -0000 matthiasblaesing closed pull request #200: Module review project ant URL: https://github.com/apache/incubator-netbeans/pull/200 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/openide.util/src/org/openide/util/EditableProperties.java b/openide.util/src/org/openide/util/EditableProperties.java index 4ef396b4d..42c24c92d 100644 --- a/openide.util/src/org/openide/util/EditableProperties.java +++ b/openide.util/src/org/openide/util/EditableProperties.java @@ -83,7 +83,9 @@ for (Item _i : original.items) { Item i = (Item) _i.clone(); items.add(i); - itemIndex.put(i.getKey(), i); + if(i.getKey() != null) { + itemIndex.put(i.getKey(), i); + } } } } @@ -832,7 +834,7 @@ public SetImpl() {} } public int size() { - return state.items.size(); + return state.itemIndex.size(); } } diff --git a/openide.util/test/unit/src/org/openide/util/EditablePropertiesTest.java b/openide.util/test/unit/src/org/openide/util/EditablePropertiesTest.java index 65ce2ccf4..55b1b4a86 100644 --- a/openide.util/test/unit/src/org/openide/util/EditablePropertiesTest.java +++ b/openide.util/test/unit/src/org/openide/util/EditablePropertiesTest.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import org.netbeans.junit.NbTestCase; @@ -357,6 +358,30 @@ public void testNonLatinComments() throws Exception { assertEquals("Reading and re-writing non-Latin chars in comments works", expected, getAsString(p)); } + // Test consistency of size of the property list for different view of it + public void testConsistentSize() throws Exception { + EditableProperties testProperties = loadTestProperties(); + // Enumerate entries manually + int count = 0; + for(Entry entry: testProperties.entrySet()) { + count++; + } + assertEquals(testProperties.size(), count); + assertEquals(testProperties.size(), testProperties.entrySet().size()); + assertEquals(testProperties.size(), testProperties.keySet().size()); + } + + // This test ensures, that the copy constructor or EditableProperties.State + // does not introduce NULL keys. These NULL keys are observable from the + // outside by an increased number of elements. + public void testCopyWithIndependentComments() throws Exception { + EditableProperties testProperties = loadTestProperties(); + EditableProperties test2Properties = testProperties.cloneProperties(); + int originalSize = testProperties.size(); + assertTrue(testProperties.containsKey("key1")); + testProperties.setProperty("key1", "XXX"); + assertEquals(originalSize, testProperties.size()); + } // helper methods: diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/build-impl.xsl b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/build-impl.xsl index ab277e944..141b26d13 100644 --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/build-impl.xsl +++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/build-impl.xsl @@ -1,4 +1,24 @@ + + + + diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/project-modified.xml b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/project-modified.xml index 95c2d97a6..96052bc70 100644 --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/project-modified.xml +++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/project-modified.xml @@ -1,4 +1,24 @@ + test diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/test.txt b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/data/test.txt deleted file mode 100644 index e69de29bb..000000000 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services