You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2017/08/24 11:10:52 UTC

ant-ivy git commit: use collections instead of arrays; optimise their use

Repository: ant-ivy
Updated Branches:
  refs/heads/master 14313cffe -> 90c42ec03


use collections instead of arrays; optimise their use

Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/90c42ec0
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/90c42ec0
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/90c42ec0

Branch: refs/heads/master
Commit: 90c42ec03e34dc63fb0b62bae4e8e7671c47cb31
Parents: 14313cf
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Thu Aug 24 13:02:31 2017 +0200
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Thu Aug 24 13:02:31 2017 +0200

----------------------------------------------------------------------
 .../org/apache/ivy/core/IvyPatternHelper.java   | 14 ++--
 .../core/module/descriptor/Configuration.java   | 25 +++----
 .../apache/ivy/core/report/ResolveReport.java   |  6 +-
 .../parser/xml/XmlModuleDescriptorParser.java   | 24 +++----
 .../parser/xml/XmlModuleDescriptorUpdater.java  |  6 +-
 .../org/apache/ivy/plugins/version/Match.java   | 30 ++++-----
 .../util/extendable/ExtendableItemHelper.java   | 21 ++++--
 .../apache/ivy/core/resolve/ResolveTest.java    | 70 ++++++++------------
 .../xml/XmlModuleDescriptorParserTest.java      |  4 +-
 9 files changed, 102 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/core/IvyPatternHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/IvyPatternHelper.java b/src/java/org/apache/ivy/core/IvyPatternHelper.java
index 613d7ac..268be30 100644
--- a/src/java/org/apache/ivy/core/IvyPatternHelper.java
+++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java
@@ -163,7 +163,7 @@ public final class IvyPatternHelper {
             tokens.put(ORIGINAL_ARTIFACTNAME_KEY, new OriginalArtifactNameValue(origin));
         }
 
-        return substituteTokens(pattern, tokens);
+        return substituteTokens(pattern, tokens, false);
     }
 
     // CheckStyle:ParameterNumber ON
@@ -218,9 +218,15 @@ public final class IvyPatternHelper {
         }
     }
 
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static String substituteTokens(String pattern, Map tokens) {
-        Map<String, Object> tokensCopy = new HashMap<>(tokens);
+    // This is a cludge to reconcile different values passed to the method
+    public static String substituteTokens(String pattern, Map<String, String> tokens) {
+        Map<String, Object> tokensCopy = new HashMap<>();
+        tokensCopy.putAll(tokens);
+        return substituteTokens(pattern, tokensCopy, true);
+    }
+
+    private static String substituteTokens(String pattern, Map<String, Object> tokens, boolean external) {
+        Map<String, Object> tokensCopy = external ? tokens : new HashMap<>(tokens);
         if (tokensCopy.containsKey(ORGANISATION_KEY) && !tokensCopy.containsKey(ORGANISATION_KEY2)) {
             tokensCopy.put(ORGANISATION_KEY2, tokensCopy.get(ORGANISATION_KEY));
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
index 56d96c4..d5ff9c7 100644
--- a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
+++ b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java
@@ -20,6 +20,7 @@ package org.apache.ivy.core.module.descriptor;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
@@ -74,7 +75,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
 
     private String description;
 
-    private String[] extendsFrom;
+    private Set<String> extendsFrom;
 
     private Visibility visibility;
 
@@ -95,9 +96,9 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
     }
 
     public Configuration(Configuration source, ModuleRevisionId sourceModule) {
-        this(source.getAttributes(), source.getQualifiedExtraAttributes(), source.getName(), source
-                .getVisibility(), source.getDescription(), source.getExtends(), source
-                .isTransitive(), source.getDeprecated(), sourceModule);
+        this(source.getAttributes(), source.getQualifiedExtraAttributes(), source.getName(),
+                source.getVisibility(), source.getDescription(), source.getExtends(),
+                source.isTransitive(), source.getDeprecated(), sourceModule);
     }
 
     /**
@@ -122,7 +123,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
     }
 
     private Configuration(Map<String, String> attributes, Map<String, String> extraAttributes,
-            String name, Visibility visibility, String description, String[] ext,
+            String name, Visibility visibility, String description, String[] exts,
             boolean transitive, String deprecated, ModuleRevisionId sourceModule) {
         super(attributes, extraAttributes);
 
@@ -135,12 +136,12 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
         this.name = name;
         this.visibility = visibility;
         this.description = description;
-        if (ext == null) {
-            extendsFrom = new String[0];
+        if (exts == null) {
+            extendsFrom = Collections.emptySet();
         } else {
-            extendsFrom = new String[ext.length];
-            for (int i = 0; i < ext.length; i++) {
-                extendsFrom[i] = ext[i].trim();
+            extendsFrom = new LinkedHashSet<>();
+            for (String ext : exts) {
+                extendsFrom.add(ext.trim());
             }
         }
         this.transitive = transitive;
@@ -168,7 +169,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
      * @return Returns the extends. May be empty, but never null.
      */
     public String[] getExtends() {
-        return extendsFrom;
+        return extendsFrom.toArray(new String[extendsFrom.size()]);
     }
 
     /**
@@ -232,7 +233,7 @@ public class Configuration extends DefaultExtendableItem implements InheritableI
             }
         }
 
-        this.extendsFrom = newExtends.toArray(new String[newExtends.size()]);
+        this.extendsFrom = newExtends;
     }
 
     private void addOther(Configuration[] allConfigs, Visibility visibility, Set<String> configs) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/core/report/ResolveReport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/report/ResolveReport.java b/src/java/org/apache/ivy/core/report/ResolveReport.java
index 5bc7e56..e9eec57 100644
--- a/src/java/org/apache/ivy/core/report/ResolveReport.java
+++ b/src/java/org/apache/ivy/core/report/ResolveReport.java
@@ -322,16 +322,16 @@ public class ResolveReport {
      * specified one.
      *
      * @param extended String
-     * @return String[]
+     * @return Set of String
      */
     @SuppressWarnings("unused")
-    private String[] getExtendingConfs(String extended) {
+    private Set<String> getExtendingConfs(String extended) {
         Set<String> extendingConfs = new HashSet<>();
         extendingConfs.add(extended);
         for (String conf : md.getConfigurationsNames()) {
             gatherExtendingConfs(extendingConfs, conf, extended);
         }
-        return extendingConfs.toArray(new String[extendingConfs.size()]);
+        return extendingConfs;
     }
 
     private boolean gatherExtendingConfs(Set<String> extendingConfs, String conf, String extended) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
index 2828499..9c71ea6 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
@@ -89,8 +89,8 @@ import static org.apache.ivy.core.module.descriptor.Configuration.Visibility.get
  * uses only the SAX API, which makes the parsing code harder to understand.
  */
 public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
-    static final String[] DEPENDENCY_REGULAR_ATTRIBUTES = new String[] {"org", "name", "branch",
-            "branchConstraint", "rev", "revConstraint", "force", "transitive", "changing", "conf"};
+    static final List<String> DEPENDENCY_REGULAR_ATTRIBUTES = Arrays.asList("org", "name", "branch",
+            "branchConstraint", "rev", "revConstraint", "force", "transitive", "changing", "conf");
 
     private static final XmlModuleDescriptorParser INSTANCE = new XmlModuleDescriptorParser();
 
@@ -845,8 +845,8 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                             settings.substitute(attributes.getValue("description")),
                             (ext == null) ? null : ext.split(","), transitive, deprecated);
                     ExtendableItemHelper.fillExtraAttributes(settings, configuration, attributes,
-                        new String[] {"name", "visibility", "extends", "transitive", "description",
-                                "deprecated"});
+                        Arrays.asList("name", "visibility", "extends", "transitive", "description",
+                                "deprecated"));
                     getMd().addConfiguration(configuration);
                     break;
                 case State.PUB:
@@ -954,7 +954,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                 String url = settings.substitute(attributes.getValue("url"));
                 artifact = new MDArtifact(getMd(), artName, type, ext, url == null ? null
                         : new URL(url), ExtendableItemHelper.getExtraAttributes(settings,
-                    attributes, new String[] {"ext", "type", "name", "conf"}));
+                    attributes, Arrays.asList("ext", "type", "name", "conf")));
                 String confs = settings.substitute(attributes.getValue("conf"));
                 // only add confs if they are specified. if they aren't, endElement will
                 // handle this
@@ -1013,9 +1013,9 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                     module,
                     branch,
                     revision,
-                    ExtendableItemHelper.getExtraAttributes(settings, attributes, new String[] {
+                    ExtendableItemHelper.getExtraAttributes(settings, attributes, Arrays.asList(
                             "organisation", "module", "revision", "status", "publication",
-                            "branch", "namespace", "default", "resolver"})));
+                            "branch", "namespace", "default", "resolver"))));
 
             String namespace = settings.substitute(attributes.getValue("namespace"));
             if (namespace != null) {
@@ -1107,7 +1107,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
             if (state == State.DEP_ARTIFACT) {
                 String url = settings.substitute(attributes.getValue("url"));
                 Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
-                    attributes, new String[] {"name", "type", "ext", "url", "conf"});
+                    attributes, Arrays.asList("name", "type", "ext", "url", "conf"));
                 confAware = new DefaultDependencyArtifactDescriptor(dd, name, type, ext,
                         url == null ? null : new URL(url), extraAtt);
             } else if (state == State.ARTIFACT_INCLUDE) {
@@ -1118,8 +1118,8 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                 module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
                 ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
                 Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
-                    attributes, new String[] {"org", "module", "name", "type", "ext", "matcher",
-                            "conf"});
+                    attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher",
+                            "conf"));
                 confAware = new DefaultIncludeRule(aid, matcher, extraAtt);
             } else { // _state == ARTIFACT_EXCLUDE || EXCLUDE
                 PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher"));
@@ -1129,8 +1129,8 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                 module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
                 ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
                 Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
-                    attributes, new String[] {"org", "module", "name", "type", "ext", "matcher",
-                            "conf"});
+                    attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher",
+                            "conf"));
                 confAware = new DefaultExcludeRule(aid, matcher, extraAtt);
             }
             String confs = settings.substitute(attributes.getValue("conf"));

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
index aadfd99..96c1bd4 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -749,9 +749,9 @@ public final class XmlModuleDescriptorUpdater {
 
             // if necessary translate mrid using optional namespace argument
             ModuleRevisionId localMid = ModuleRevisionId.newInstance(organisation, module, branch,
-                rev, ExtendableItemHelper
-                        .getExtraAttributes(settings, attributes, new String[] {"organisation",
-                                "module", "revision", "status", "publication", "namespace"}));
+                rev, ExtendableItemHelper.getExtraAttributes(settings, attributes,
+                            Arrays.asList("organisation", "module", "revision", "status",
+                                    "publication", "namespace")));
             ModuleRevisionId systemMid = (ns == null) ? localMid : ns.getToSystemTransformer()
                     .transform(localMid);
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/plugins/version/Match.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/Match.java b/src/java/org/apache/ivy/plugins/version/Match.java
index 93f2838..b2324e0 100644
--- a/src/java/org/apache/ivy/plugins/version/Match.java
+++ b/src/java/org/apache/ivy/plugins/version/Match.java
@@ -17,8 +17,9 @@
  */
 package org.apache.ivy.plugins.version;
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -76,16 +77,16 @@ public class Match {
     public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
         String revision = askedMrid.getRevision();
 
-        String[] args = split(getArgs());
-        String[] argValues = getRevisionArgs(revision);
+        List<String> args = split(getArgs());
+        List<String> argValues = getRevisionArgs(revision);
 
-        if (args.length != argValues.length) {
+        if (args.size() != argValues.size()) {
             return new NoMatchMatcher();
         }
 
         Map<String, String> variables = new HashMap<>();
-        for (int i = 0; i < args.length; i++) {
-            variables.put(args[i], argValues[i]);
+        for (String arg : args) {
+            variables.put(arg, argValues.get(args.indexOf(arg)));
         }
 
         String pattern = getPattern();
@@ -95,33 +96,32 @@ public class Match {
         return pMatcher.getMatcher(pattern);
     }
 
-    private String[] getRevisionArgs(String revision) {
+    private List<String> getRevisionArgs(String revision) {
         int bracketStartIndex = revision.indexOf('(');
         if (bracketStartIndex == -1) {
-            return new String[0];
+            return Collections.emptyList();
         }
 
         int bracketEndIndex = revision.indexOf(')');
         if (bracketEndIndex <= (bracketStartIndex + 1)) {
-            return new String[0];
+            return Collections.emptyList();
         }
 
-        String args = revision.substring(bracketStartIndex + 1, bracketEndIndex);
-        return split(args);
+        return split(revision.substring(bracketStartIndex + 1, bracketEndIndex));
     }
 
-    private static String[] split(String string) {
+    private static List<String> split(String string) {
         if (string == null) {
-            return new String[0];
+            return Collections.emptyList();
         }
 
         StringTokenizer tokenizer = new StringTokenizer(string, ", ");
-        List<String> tokens = new ArrayList<>();
+        List<String> tokens = new LinkedList<>();
         while (tokenizer.hasMoreTokens()) {
             tokens.add(tokenizer.nextToken());
         }
 
-        return tokens.toArray(new String[tokens.size()]);
+        return tokens;
     }
 
     private static class NoMatchMatcher implements Matcher {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java b/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
index 09ce46c..bf43e9c 100644
--- a/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
+++ b/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
@@ -18,8 +18,8 @@
 package org.apache.ivy.util.extendable;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -40,6 +40,12 @@ public final class ExtendableItemHelper {
         return ret;
     }
 
+    @Deprecated
+    public static Map<String, String> getExtraAttributes(ParserSettings settings,
+                                                         Attributes attributes, String[] ignoredAttNames) {
+        return getExtraAttributes(settings, attributes, Arrays.asList(ignoredAttNames));
+    }
+
     /**
      * Extract from the XML attribute the extra Ivy ones
      *
@@ -50,19 +56,24 @@ public final class ExtendableItemHelper {
      * @return Map&lt;String,String&gt;
      */
     public static Map<String, String> getExtraAttributes(ParserSettings settings,
-            Attributes attributes, String[] ignoredAttNames) {
+            Attributes attributes, List<String> ignoredAttNames) {
         Map<String, String> ret = new HashMap<>();
-        Collection<String> ignored = Arrays.asList(ignoredAttNames);
         for (int i = 0; i < attributes.getLength(); i++) {
-            if (!ignored.contains(attributes.getQName(i))) {
+            if (!ignoredAttNames.contains(attributes.getQName(i))) {
                 ret.put(attributes.getQName(i), settings.substitute(attributes.getValue(i)));
             }
         }
         return ret;
     }
 
+    @Deprecated
+    public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item,
+                                           Attributes attributes, String[] ignoredAttNames) {
+        fillExtraAttributes(settings, item, attributes, Arrays.asList(ignoredAttNames));
+    }
+
     public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item,
-            Attributes attributes, String[] ignoredAttNames) {
+            Attributes attributes, List<String> ignoredAttNames) {
         Map<String, String> att = getExtraAttributes(settings, attributes, ignoredAttNames);
         for (Entry<String, String> entry : att.entrySet()) {
             item.setExtraAttribute(entry.getKey(), entry.getValue());

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/test/java/org/apache/ivy/core/resolve/ResolveTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/resolve/ResolveTest.java b/test/java/org/apache/ivy/core/resolve/ResolveTest.java
index 0ad84b1..73cf685 100644
--- a/test/java/org/apache/ivy/core/resolve/ResolveTest.java
+++ b/test/java/org/apache/ivy/core/resolve/ResolveTest.java
@@ -595,9 +595,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // now we clean the repository to simulate repo not available (network pb for instance)
         FileUtil.forceDelete(new File("build/testCache2"));
@@ -607,9 +606,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
     }
 
     @Test
@@ -633,9 +631,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // now we clean the repository to simulate repo not available (network pb for instance)
         FileUtil.forceDelete(new File("build/testCache2"));
@@ -645,9 +642,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
     }
 
     @Test
@@ -672,9 +668,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // now we wait for ttl expiration
         Thread.sleep(700);
@@ -684,9 +679,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // now we clean the repository to simulate repo not available (network pb for instance)
         FileUtil.forceDelete(new File("build/testCache2"));
@@ -696,9 +690,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
     }
 
     @Test
@@ -719,9 +712,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // now we update the repository
         FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), new File(
@@ -732,9 +724,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
     }
 
     @Test
@@ -766,9 +757,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // wait for org1 TTL to expire
         Thread.sleep(700);
@@ -778,9 +768,8 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
     }
 
     @Test
@@ -809,18 +798,16 @@ public class ResolveTest {
             getResolveOptions(new String[] {"*"}));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         // resolve again with refresh: it should find the new version
         report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"),
             getResolveOptions(new String[] {"*"}).setRefresh(true));
         assertFalse(report.hasError());
 
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1",
-                        "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")),
+                report.getConfigurationReport("default").getModuleRevisionIds());
 
         FileUtil.forceDelete(new File("build/testCache2"));
     }
@@ -2029,9 +2016,8 @@ public class ResolveTest {
             r.getConfigurationReport("B").getModuleRevisionIds());
 
         // here we should get only mod2.1 cause compile is not transitive
-        assertEquals(
-                new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org2",
-                        "mod2.1", "0.3.2"))), r.getConfigurationReport("compile").getModuleRevisionIds());
+        assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2")),
+                r.getConfigurationReport("compile").getModuleRevisionIds());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/90c42ec0/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
index 6fdcf5d..d29cbbf 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
@@ -371,7 +371,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
         assertNotNull(dd);
         assertEquals("yourorg", dd.getDependencyId().getOrganisation());
         assertEquals("11.1", dd.getDependencyRevisionId().getRevision());
-        assertEquals(new HashSet<>(Collections.singletonList("*")),
+        assertEquals(Collections.singleton("*"),
             new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
         assertEquals(Collections.singletonList("myconf1"),
             Arrays.asList(dd.getDependencyConfigurations("myconf1")));
@@ -447,7 +447,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
         assertNotNull(dd);
         assertEquals("yourorg", dd.getDependencyId().getOrganisation());
         assertEquals("10.1", dd.getDependencyRevisionId().getRevision());
-        assertEquals(new HashSet<>(Collections.singletonList("*")),
+        assertEquals(Collections.singleton("*"),
             new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
         assertDependencyArtifactIncludeRules(dd, new String[] {"myconf1"}, new String[] {"your.*",
                 PatternMatcher.ANY_EXPRESSION});