mbien commented on code in PR #5482:
URL: https://github.com/apache/netbeans/pull/5482#discussion_r1111006238


##########
java/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java:
##########
@@ -149,6 +153,9 @@ public class MavenCommandLineExecutor extends 
AbstractMavenExecutor {
     private static final RequestProcessor UPDATE_INDEX_RP = new 
RequestProcessor(RunUtils.class.getName(), 5);
 
     private static final String ICON_MAVEN_PROJECT = 
"org/netbeans/modules/maven/resources/Maven2Icon.gif"; // NOI18N
+
+    private final Function<String, Boolean> mavenCommandMultiThreadAnalyzer = 
isMavenDaemon() ? MavenCommandParametersAnalyzer::isMultiThreaded : 
MavenDaemonCommandParametersAnalyzer::isMultiThreaded ;
+

Review Comment:
   could you inline this?
   
   please note: I just tried it and NB is having trouble with inlining 
functions, might need manual adjustments to make it compile.



##########
java/maven/src/org/netbeans/modules/maven/execute/cmd/analyzer/MavenDaemonCommandParametersAnalyzer.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.maven.execute.cmd.analyzer;
+
+import java.util.List;
+
+/**
+ *
+ * @author asbachb
+ */
+public class MavenDaemonCommandParametersAnalyzer {
+
+    private static final String REGEX_SPACE_OR_LINE_END = "(\\s.*|^)";
+
+    private static final List<String> SINGLE_THREAD_INDICATORS = List.of(
+            ".*-T 1" + REGEX_SPACE_OR_LINE_END,
+            ".*--threads 1" + REGEX_SPACE_OR_LINE_END,
+            ".*-Dmvnd.serial" + REGEX_SPACE_OR_LINE_END,
+            ".*-1" + REGEX_SPACE_OR_LINE_END,
+            ".*--serial + REGEX_SPACE_OR_LINE_END"
+    );
+
+    private MavenDaemonCommandParametersAnalyzer() {
+    }
+
+    public static boolean isMultiThreaded(String mvndCommandParameters) {
+        return !SINGLE_THREAD_INDICATORS.stream()
+                .filter(indicator -> mvndCommandParameters.matches(indicator))
+                .findAny()
+                .isPresent();

Review Comment:
   consider:
   ```java
               return SINGLE_THREAD_INDICATORS.stream()
                       .noneMatch(indicator -> 
mvndCommandParameters.matches(indicator));
   ```
   I got a collection of jackpot code inspections here:
   
https://github.com/mbien/jackpot-inspections/blob/c5ab627bb39f81153a562d0352f2c403452e0945/StreamPerformance.hint#L138-L155
   
   always makes me happy when it finds something out of nowhere :)
   



##########
java/maven/src/org/netbeans/modules/maven/execute/cmd/analyzer/MavenDaemonCommandParametersAnalyzer.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.maven.execute.cmd.analyzer;
+
+import java.util.List;
+
+/**
+ *
+ * @author asbachb
+ */
+public class MavenDaemonCommandParametersAnalyzer {

Review Comment:
   could be an interface with `@FunctionalInterface`, right?
   
   I am wondering if we could simply move both classes into 
MavenCommandLineExecutor (package private). Would still remain testable and 
everything is in one place. It is probably not something what will be reused 
outside of that class.
   
   edit: just tried it and I think I like that better



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to