You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/12/02 10:56:51 UTC

[GitHub] [maven] mthmulders commented on a diff in pull request #816: Small optimisations and cleanup

mthmulders commented on code in PR #816:
URL: https://github.com/apache/maven/pull/816#discussion_r1038025130


##########
maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java:
##########
@@ -194,15 +162,30 @@ public Map<String, String> getProjectProperties() {
     }
 
     public DefaultProfileActivationContext setProjectProperties(Properties projectProperties) {
-        if (projectProperties != null) {
-            this.projectProperties = projectProperties.entrySet().stream()
-                    .collect(collectingAndThen(
-                            toMap(k -> String.valueOf(k.getKey()), v -> String.valueOf(v)),
-                            Collections::unmodifiableMap));
-        } else {
-            this.projectProperties = Collections.emptyMap();
-        }
+        return setProjectProperties(toMap(projectProperties));
+    }
+
+    public DefaultProfileActivationContext setProjectProperties(Map<String, String> projectProperties) {
+        this.projectProperties = unmodifiable(projectProperties);

Review Comment:
   Previously, a `null` for the `projectProperties` argument would result in `this.projectProperties` being an empty `Map`. With this patch, it would result in `this.projectProperties` being `null`. Are you sure that's an intended change?



##########
maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java:
##########
@@ -23,17 +23,19 @@
 import org.codehaus.plexus.interpolation.AbstractValueSource;
 
 class BuildTimestampValueSource extends AbstractValueSource {
-    private final MavenBuildTimestamp mavenBuildTimestamp;
+    private final Date startTime;
+    private final Map<String, String> properties;
 
     BuildTimestampValueSource(Date startTime, Map<String, String> properties) {
         super(false);
-        this.mavenBuildTimestamp = new MavenBuildTimestamp(startTime, properties);
+        this.startTime = startTime;
+        this.properties = properties;

Review Comment:
   Would it make sense to default to an empty collection in case the constructor argument is empty?



##########
maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java:
##########
@@ -23,17 +23,19 @@
 import org.codehaus.plexus.interpolation.AbstractValueSource;
 
 class BuildTimestampValueSource extends AbstractValueSource {
-    private final MavenBuildTimestamp mavenBuildTimestamp;
+    private final Date startTime;
+    private final Map<String, String> properties;
 
     BuildTimestampValueSource(Date startTime, Map<String, String> properties) {

Review Comment:
   Now that we've switched to Java 8, would it make sense to refactor `Date` to a JSR-310 type?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org