diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java index bf5827334..88cf581fd 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java @@ -173,21 +173,27 @@ public DefaultArtifact( } this.version = emptify(version); this.file = null; - this.properties = merge(properties, (type != null) ? type.getProperties() : null); + this.properties = mergeArtifactProperties(properties, (type != null) ? type.getProperties() : null); } - private static Map merge(Map dominant, Map recessive) { + private static Map mergeArtifactProperties( + Map artifactProperties, Map typeDefaultProperties) { Map properties; - if ((dominant == null || dominant.isEmpty()) && (recessive == null || recessive.isEmpty())) { - properties = Collections.emptyMap(); + if (artifactProperties == null || artifactProperties.isEmpty()) { + if (typeDefaultProperties == null || typeDefaultProperties.isEmpty()) { + properties = Collections.emptyMap(); + } else { + // type default properties are already unmodifiable + return typeDefaultProperties; + } } else { properties = new HashMap<>(); - if (recessive != null) { - properties.putAll(recessive); + if (typeDefaultProperties != null) { + properties.putAll(typeDefaultProperties); } - if (dominant != null) { - properties.putAll(dominant); + if (artifactProperties != null) { + properties.putAll(artifactProperties); } properties = Collections.unmodifiableMap(properties); }