Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-beta-5
-
None
-
None
Description
The Build constructor has the following code:
Map<Object, InputLocation> newlocs = builder.locations != null ? builder.locations : Collections.emptyMap(); Map<Object, InputLocation> oldlocs = builder.base != null && builder.base.locations != null ? builder.base.locations : Collections.emptyMap(); Map<Object, InputLocation> mutableLocations = new HashMap<>(super.locations); mutableLocations.put("sourceDirectory", newlocs.containsKey("sourceDirectory") ? newlocs.get("sourceDirectory") : oldlocs.get("sourceDirectory")); mutableLocations.put("scriptSourceDirectory", newlocs.containsKey("scriptSourceDirectory") ? newlocs.get("scriptSourceDirectory") : oldlocs.get("scriptSourceDirectory")); mutableLocations.put("testSourceDirectory", newlocs.containsKey("testSourceDirectory") ? newlocs.get("testSourceDirectory") : oldlocs.get("testSourceDirectory")); mutableLocations.put("outputDirectory", newlocs.containsKey("outputDirectory") ? newlocs.get("outputDirectory") : oldlocs.get("outputDirectory")); mutableLocations.put("testOutputDirectory", newlocs.containsKey("testOutputDirectory") ? newlocs.get("testOutputDirectory") : oldlocs.get("testOutputDirectory")); mutableLocations.put("extensions", newlocs.containsKey("extensions") ? newlocs.get("extensions") : oldlocs.get("extensions")); this.locations = Collections.unmodifiableMap(mutableLocations);
This is inefficient, especially when building models programmatically, in which cases locations are usually not set. The code will always store a null value for each key, whereas an empty map could be sufficient if there's no actual values.
The generator code is located at:
https://github.com/apache/maven/blob/b370e5e9299813e6df483bac049ec162b86fb7e8/src/mdo/model.vm#L174-L186
Attachments
Issue Links
- links to