matthiasblaesing commented on code in PR #8036:
URL: https://github.com/apache/netbeans/pull/8036#discussion_r1895002781


##########
platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java:
##########
@@ -213,7 +219,8 @@ public NbPacScriptEvaluator(String pacSourceCocde) throws 
PacParsingException {
     @Override
     public List<Proxy> findProxyForURL(URI uri) throws PacValidationException {
 
-        List<Proxy> jsResultAnalyzed;
+        AtomicReference<List<Proxy>> resultHolder = new 
AtomicReference<>(null);

Review Comment:
   This can be moved into the `else`-block. No need to hold it in the outer 
context.



##########
platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java:
##########
@@ -196,6 +200,8 @@ public class NbPacScriptEvaluator implements 
PacScriptEvaluator {
     private static final String PAC_SOCKS5_FFEXT = "SOCKS5"; // Mozilla 
Firefox extension. Not part of original Netscape spec.
     private static final String PAC_HTTP_FFEXT = "HTTP"; // Mozilla Firefox 
extension. Not part of original Netscape spec.
     private static final String PAC_HTTPS_FFEXT = "HTTPS"; // Mozilla Firefox 
extension. Not part of original Netscape spec.
+    private static class RPSingleton { private static final RequestProcessor 
instance = new RequestProcessor(NbPacScriptEvaluator.class.getName(), 
Runtime.getRuntime().availableProcessors(), true, false); }
+    private static RequestProcessor getRequestProcessor() { return 
RPSingleton.instance; }

Review Comment:
   Why this complex construct? Why not just
   
   ```
   private static final RequestProcessor RP = new 
RequestProcessor(NbPacScriptEvaluator.class.getName(), 
Runtime.getRuntime().availableProcessors(), true, false);
   ```
   
   This is done all over the code base. The proposed style looks overly complex 
without clear benefits.
   
   Why the limit to number available processors?  For a real PAC script I would 
expect it to be throttled by network IO (DNS look ups for example). If high CPU 
usage is the problem (and thus an attacker is expected), I would go with a 
throughput of 1. 



-- 
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