You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "matthiasblaesing (via GitHub)" <gi...@apache.org> on 2023/02/18 11:18:31 UTC

[GitHub] [netbeans] matthiasblaesing opened a new pull request, #5530: Remove Thread#stop from httpserver and update embedded tomcat

matthiasblaesing opened a new pull request, #5530:
URL: https://github.com/apache/netbeans/pull/5530

   NetBeans carries an embedded httpserver, that is used for various use-cases:
   
   - view javadoc in external browser
   - preview result of XSLT transformation
   - record tomcat traffic monitor
   
   This changeset:
   
   - updates the embedded tomcat from tomcat 3.2.4 and servlet-api 2.2 to tomcat 9.0.71 and servlet-api 4.0, which are the last versions supporting the `javax` namespace
   - reworks the starting mechanism not to require a separate thread (partitial fix for #4952)
   - makes the embedded webserver visible and stoppable in the UI: 
   ![image](https://user-images.githubusercontent.com/2179736/219857285-6ba60b00-95c9-4ac8-baa2-dc40517f8433.png)
   - fixes the tests and enables running them in CI/CD tests
   - ensures access control is established for all resources and servlets


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111317946


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   since this file is already touched why not changing this to StringBuilder?



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111317946


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   since this file is already touched why not changing this to StringBuilder?
   with maybe adding some sensible initial capacity like new StringBuilder(name.size()*2 ) or somethig**



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1116027551


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:
##########
@@ -75,60 +90,77 @@ static void initHTTPServer() {
                 return;
             inSetRunning = true;
             try {
-                if ((serverThread != null) && (!httpserverSettings().running)) {
+                if ((tomcat != null) && (!HttpServerSettings.running)) {
                     // another thread is trying to start the server, wait for a while and then stop it if it's still bad
                     try {
-                        Thread.currentThread().sleep(2000);
+                        Thread.sleep(2000);
                     } catch (InterruptedException e) {}
-                    if ((serverThread != null) && (!httpserverSettings().running)) {
-                        serverThread.stop();
-                        serverThread = null;
+                    if ((tomcat != null) && (!HttpServerSettings.running)) {
+                        try {
+                            tomcat.stop();
+                            tomcat.destroy();
+                        } catch (LifecycleException ex) {
+                            Exceptions.printStackTrace(ex);
+                        }
+                        tomcat = null;
+                        progressHandle.close();
+                        progressHandle = null;
                     }
                 }
-                if (serverThread == null) {
-                    serverThread = new Thread("HTTPServer") { // NOI18N
-                        public void run() {
+                if (tomcat == null) {
+                    try {
+                        buildServer();
+                        tomcat.start();
+                        httpserverSettings().runSuccess();
+                        reloader.activate();
+                        progressHandle = ProgressHandle.createHandle(
+                                "Internal Webserver", () -> {
+                                    httpserverSettings().setRunning(false);
+                                    return true;
+                                }
+                        );
+                        progressHandle.start();
+                        progressHandle.progress("Running on port " + httpserverSettings().getPort());
+                        progressHandle.switchToDeterminate(1, 1);

Review Comment:
   instead of the two lines, this would work too I believe:
   `progressHandle.suspend("Running on port " + httpserverSettings().getPort());`
   
   it will print the port number inside the progress bar, which looks kinda nice IMO.



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111332733


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   @lbownik red means removed



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442024224

   > preview result of XSLT transformation
   
   @matthiasblaesing this made me curious. When I press the blue xsl transformation button on a xml and transform it, it would open the transformed file directly in a browser (not from the webserver). This is not what you mean by preview, right?
   
   Opening downloaded javadoc of maven deps works great, cancel/restart worked too.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111317984


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();
-        for (int i = 0; i < name.length (); i++) {
-            if (Character.isLetterOrDigit (name.charAt (i)) ||
-                name.charAt (i) == '.') {
-                sb.append (name.charAt (i));
-            }
-            else {
-                String code = Integer.toHexString ((int)name.charAt (i)).toUpperCase ();
-                if (code.length ()<2)
-                    code = (code.length () == 0)? "00": "0"+code;   // NOI18N
-                sb.append ("%").                                    // NOI18N
-                append ((code.length () == 2)? code: code.substring (code.length ()-2));
-            }
-        }
-        return sb.toString ();
-    }
-    
-    /** Unconverts string from URL into old string. 
-     *  This mangling decodes '%xy'
-     */
-    static String demangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   since this file is already touched why not changing this to StringBuilder?
   with maybe adding some sensible initial capacity like new StringBuilder(name.size()*2 ) or somethig



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111323102


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:
##########
@@ -171,113 +173,104 @@ static void stopHTTPServer() {
         }
     }
     
-    
-    private static ContextManager getContextManager(EmbededTomcat tc) {
-        try {
-            java.lang.reflect.Field fm = EmbededTomcat.class.getDeclaredField("contextM");   // NOI18N
-            fm.setAccessible(true);
-            return (ContextManager)fm.get(tc);
-        }
-        catch (NoSuchFieldException e) {
-            return null;
-        }
-        catch (IllegalAccessException e) {
-            return null;
-        }
-    }
-    
 
-    /** Removes WebXmlReader interceptor to avoid attempt 
-     *  to load JspServlet that processes jsp file and produces confusing message
-     */
-    private static void removeWebXmlReader (EmbededTomcat tc) {
-        try {
-            java.lang.reflect.Field fm = EmbededTomcat.class.getDeclaredField("contextInt");   // NOI18N
-            fm.setAccessible(true);
-            Vector contextInt = (Vector)fm.get(tc);
-            Iterator it = contextInt.iterator ();
-            while (it.hasNext ()) {
-                Object o = it.next ();
-                if (o instanceof WebXmlReader) {
-                    contextInt.remove (o);
-                    break;
-                }
+    private static void buildServer() throws Exception {
+        tomcat = new Tomcat();
+        tomcat.setPort(httpserverSettings().getPort());
+        tomcat.getServer().setUtilityThreads(1);
+        tomcat.getConnector().setXpoweredBy(false);
+	TaskQueue tq = new TaskQueue(10);
+	ThreadPoolExecutor tf  = new ThreadPoolExecutor(0, 3, 60, TimeUnit.SECONDS, tq);
+	tomcat.getConnector().getProtocolHandler().setExecutor(tf);
+
+        File wd = Places.getCacheSubdirectory("httpwork");
+        Context ctx = tomcat.addContext("", wd.getAbsolutePath());
+
+        ctx.setResources(new StandardRoot() {
+            @Override
+            protected void registerURLStreamHandlerFactory() {
+                // Tomcat tries to override the URLStreamHandlerFactory, this
+                // collides with NetBeans usage and alternative registration
+                // methods are only available on JDK 9+
+                // So disable this here, we don't really need it.
             }
-        }
-        catch (NoSuchFieldException e) {
-            return;
-        }
-        catch (IllegalAccessException e) {
-            return;
-        }
-    }
-    
+        });
 
-    private static ContextManager buildServer() throws Exception {
-        HttpServerSettings op = httpserverSettings ();
+        ctx.setSessionTimeout(30);
 
-        NbLogger logger = new NbLogger();
-        logger.setName("tc_log");    // NOI18N
+        initContext(ctx);
 
-        final EmbededTomcat tc=new EmbededTomcat();
-        
-        File wd = FileUtil.toFile (FileUtil.getConfigRoot());
-        wd = new File(wd, "httpwork"); // NOI18N
-        tc.setWorkDir(wd.getAbsolutePath());
-        
-        // install interceptors which need to be initialized BEFORE the default server interceptors
-	NbLoaderInterceptor nbL =new NbLoaderInterceptor();
-	tc.addContextInterceptor( nbL );
-        
-        // hack - force initialization of default interceptors, so our interceptor is after them
-        tc.addApplicationAdapter(null);
+        reloader = new ContextReloader (tomcat, ctx);
+    }
 
-        // install interceptors which need to be initialized AFTER the default server interceptors
-	NbServletsInterceptor nbI =new NbServletsInterceptor();
-	tc.addContextInterceptor( nbI );
+    private static void initContext(Context ctx) {
 
-        removeWebXmlReader (tc);
-        
-        ServletContext sctx;
-        sctx=tc.addContext("", wd.toURI().toURL());  // NOI18N
-        tc.initContext( sctx );
-        //ctxt.getServletLoader().setParentLoader(TopManager.getDefault().systemClassLoader());
-        
-        tc.addEndpoint( op.getPort(), null, null);
+        ctx.setParentClassLoader(Lookup.getDefault().lookup(ClassLoader.class));
 
-        final ContextManager cm = getContextManager(tc);
-        
-        reloader = new ContextReloader (tc, cm, sctx);
-        
-        // reduce number of threads
-        Enumeration e = cm.getConnectors ();
-        while (e.hasMoreElements ()) {
-            Object o = e.nextElement ();
-            if (o instanceof PoolTcpConnector) {
-                org.apache.tomcat.core.ServerConnector conn = (PoolTcpConnector)o;
-                conn.setAttribute (PoolTcpConnector.MIN_SPARE_THREADS, "0");     // NOI18N
-                conn.setAttribute (PoolTcpConnector.MAX_SPARE_THREADS, "1");     // NOI18N
-                conn.setAttribute (PoolTcpConnector.MAX_THREADS, "3");           // NOI18N
-            }
+        for (String mapping : ctx.findServletMappings()) {
+            ctx.removeServletMapping(mapping);
         }
-        
-        return cm;
-        
-    }
 
-    private static class NbLogger extends TomcatLogger {
-        public NbLogger() {
-            super();
+        for (Container container : asList(ctx.findChildren())) {
+            ctx.removeChild(container);
         }
 
-        protected void realLog(String message) {
+        for(FilterMap fm: ctx.findFilterMaps()) {
+            ctx.removeFilterMap(fm);
         }
 
-        protected void realLog(String message, Throwable t) {
+        for(FilterDef fd: ctx.findFilterDefs()) {
+            ctx.removeFilterDef(fd);
         }
-    
-        public void flush() {
+
+        Wrapper sw = ctx.createWrapper();
+        sw.setServletClass("org.netbeans.modules.httpserver.WrapperServlet");
+        sw.setName("WrapperServlet");
+        ctx.addChild(sw);
+
+        ctx.addServletMappingDecoded(httpserverSettings().getWrapperBaseURL() + "*", "WrapperServlet");
+
+        // Originally the Apache Tomcat InvokerServlet took care of invoking
+        // servlet. This servlet was remove from Tomcat. As a replacement

Review Comment:
   -> 'was removed'



##########
enterprise/web.monitor/serversrc/org/netbeans/modules/web/monitor/server/NotifyUtil.java:
##########
@@ -117,28 +119,32 @@ void setIDE(String server) throws MalformedURLException {
     }
 		
     void sendRecord(MonitorData monData, String queryStr) {
-	
-	if(debug) log("NotifyUtil::notifyServer");  //NOI18N
-
-	if(ideServer != null) { 
-	    String urlStr = ideServer.concat(queryStr);
-	    if(debug) log("NotifyUtil: url is " + urlStr);  //NOI18N
-	    sendRecord(urlStr, monData); 
-	} 
-
-	if(otherIDEs.isEmpty()) return; 
-
-	Enumeration ides = otherIDEs.elements();
-	while(ides.hasMoreElements()) {
-
-	    String base = (String)ides.nextElement();
-
-	    if(debug) 
-		log("NotifyUtil: url is " + base.concat(queryStr)); //NOI18N
-	    if(!sendRecord(base.concat(queryStr), monData))
-		otherIDEs.remove(base); 
-	}
-	return; 
+        try {
+            if(debug) log("NotifyUtil::notifyServer");  //NOI18N
+
+            if(ideServer != null) {
+                    String urlStr = ideServer.concat(URLEncoder.encode(queryStr, "UTF-8"));

Review Comment:
   nitpick: the UTF String literals need all the `//NOI18N`, right?
   
   or: `StandardCharsets.UTF_8.name()`



##########
ide/httpserver/src/org/netbeans/modules/httpserver/AccessFilter.java:
##########
@@ -21,60 +21,44 @@
 
 import java.io.IOException;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.rmi.ServerException;
 import java.util.Set;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import org.openide.util.Exceptions;
-
 import org.openide.util.NbBundle;
 
-/** Base servlet for servlets which access NetBeans Open APIs
-*
-* @author Petr Jiricka
-* @version 0.11 May 5, 1999
-*/
-public abstract class NbBaseServlet extends HttpServlet {
+/**
+ * Base servlet for servlets which access NetBeans Open APIs
+ *
+ * @author Petr Jiricka
+ * @version 0.11 May 5, 1999
+ */
+public class AccessFilter implements Filter {

Review Comment:
   is now a filter and no longer a servlet -> doc needs tweaks



##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:
##########
@@ -171,113 +173,104 @@ static void stopHTTPServer() {
         }
     }
     
-    
-    private static ContextManager getContextManager(EmbededTomcat tc) {
-        try {
-            java.lang.reflect.Field fm = EmbededTomcat.class.getDeclaredField("contextM");   // NOI18N
-            fm.setAccessible(true);
-            return (ContextManager)fm.get(tc);
-        }
-        catch (NoSuchFieldException e) {
-            return null;
-        }
-        catch (IllegalAccessException e) {
-            return null;
-        }
-    }
-    
 
-    /** Removes WebXmlReader interceptor to avoid attempt 
-     *  to load JspServlet that processes jsp file and produces confusing message
-     */
-    private static void removeWebXmlReader (EmbededTomcat tc) {
-        try {
-            java.lang.reflect.Field fm = EmbededTomcat.class.getDeclaredField("contextInt");   // NOI18N
-            fm.setAccessible(true);
-            Vector contextInt = (Vector)fm.get(tc);
-            Iterator it = contextInt.iterator ();
-            while (it.hasNext ()) {
-                Object o = it.next ();
-                if (o instanceof WebXmlReader) {
-                    contextInt.remove (o);
-                    break;
-                }
+    private static void buildServer() throws Exception {
+        tomcat = new Tomcat();
+        tomcat.setPort(httpserverSettings().getPort());
+        tomcat.getServer().setUtilityThreads(1);
+        tomcat.getConnector().setXpoweredBy(false);
+	TaskQueue tq = new TaskQueue(10);
+	ThreadPoolExecutor tf  = new ThreadPoolExecutor(0, 3, 60, TimeUnit.SECONDS, tq);
+	tomcat.getConnector().getProtocolHandler().setExecutor(tf);
+
+        File wd = Places.getCacheSubdirectory("httpwork");
+        Context ctx = tomcat.addContext("", wd.getAbsolutePath());
+
+        ctx.setResources(new StandardRoot() {
+            @Override
+            protected void registerURLStreamHandlerFactory() {
+                // Tomcat tries to override the URLStreamHandlerFactory, this
+                // collides with NetBeans usage and alternative registration
+                // methods are only available on JDK 9+
+                // So disable this here, we don't really need it.
             }
-        }
-        catch (NoSuchFieldException e) {
-            return;
-        }
-        catch (IllegalAccessException e) {
-            return;
-        }
-    }
-    
+        });
 
-    private static ContextManager buildServer() throws Exception {
-        HttpServerSettings op = httpserverSettings ();
+        ctx.setSessionTimeout(30);
 
-        NbLogger logger = new NbLogger();
-        logger.setName("tc_log");    // NOI18N
+        initContext(ctx);
 
-        final EmbededTomcat tc=new EmbededTomcat();
-        
-        File wd = FileUtil.toFile (FileUtil.getConfigRoot());
-        wd = new File(wd, "httpwork"); // NOI18N
-        tc.setWorkDir(wd.getAbsolutePath());
-        
-        // install interceptors which need to be initialized BEFORE the default server interceptors
-	NbLoaderInterceptor nbL =new NbLoaderInterceptor();
-	tc.addContextInterceptor( nbL );
-        
-        // hack - force initialization of default interceptors, so our interceptor is after them
-        tc.addApplicationAdapter(null);
+        reloader = new ContextReloader (tomcat, ctx);
+    }
 
-        // install interceptors which need to be initialized AFTER the default server interceptors
-	NbServletsInterceptor nbI =new NbServletsInterceptor();
-	tc.addContextInterceptor( nbI );
+    private static void initContext(Context ctx) {
 
-        removeWebXmlReader (tc);
-        
-        ServletContext sctx;
-        sctx=tc.addContext("", wd.toURI().toURL());  // NOI18N
-        tc.initContext( sctx );
-        //ctxt.getServletLoader().setParentLoader(TopManager.getDefault().systemClassLoader());
-        
-        tc.addEndpoint( op.getPort(), null, null);
+        ctx.setParentClassLoader(Lookup.getDefault().lookup(ClassLoader.class));
 
-        final ContextManager cm = getContextManager(tc);
-        
-        reloader = new ContextReloader (tc, cm, sctx);
-        
-        // reduce number of threads
-        Enumeration e = cm.getConnectors ();
-        while (e.hasMoreElements ()) {
-            Object o = e.nextElement ();
-            if (o instanceof PoolTcpConnector) {
-                org.apache.tomcat.core.ServerConnector conn = (PoolTcpConnector)o;
-                conn.setAttribute (PoolTcpConnector.MIN_SPARE_THREADS, "0");     // NOI18N
-                conn.setAttribute (PoolTcpConnector.MAX_SPARE_THREADS, "1");     // NOI18N
-                conn.setAttribute (PoolTcpConnector.MAX_THREADS, "3");           // NOI18N
-            }
+        for (String mapping : ctx.findServletMappings()) {
+            ctx.removeServletMapping(mapping);
         }
-        
-        return cm;
-        
-    }
 
-    private static class NbLogger extends TomcatLogger {
-        public NbLogger() {
-            super();
+        for (Container container : asList(ctx.findChildren())) {
+            ctx.removeChild(container);
         }
 
-        protected void realLog(String message) {
+        for(FilterMap fm: ctx.findFilterMaps()) {
+            ctx.removeFilterMap(fm);
         }
 
-        protected void realLog(String message, Throwable t) {
+        for(FilterDef fd: ctx.findFilterDefs()) {
+            ctx.removeFilterDef(fd);
         }
-    
-        public void flush() {
+
+        Wrapper sw = ctx.createWrapper();
+        sw.setServletClass("org.netbeans.modules.httpserver.WrapperServlet");
+        sw.setName("WrapperServlet");
+        ctx.addChild(sw);
+
+        ctx.addServletMappingDecoded(httpserverSettings().getWrapperBaseURL() + "*", "WrapperServlet");
+
+        // Originally the Apache Tomcat InvokerServlet took care of invoking
+        // servlet. This servlet was remove from Tomcat. As a replacement
+        // this servlet is used. The idea is, that this servlet serves as a
+        // fallback servlet. When it is invoked, it looksup the right servlet,
+        // registers it and redispatches the request.
+        sw = ctx.createWrapper();
+        sw.setServlet(new HttpServlet() {
+            @Override
+            protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+                String className = classFromPath((HttpServletRequest) request);
+                LOG.log(Level.FINE, "Servlet class name: {0}", className);
+                if (className != null) {
+                    try {
+                        Class<?> clazz = Class.forName(className, true, ctx.getParentClassLoader());
+                        Tomcat.addServlet(ctx, className, (Servlet) clazz.getConstructor().newInstance());
+                        ctx.addServletMappingDecoded("/servlet/" + className + "/*", className);
+                        request.getRequestDispatcher(request.getRequestURI()).forward(request, response);
+                    } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {

Review Comment:
   some of those can be combined to the `ReflectiveOperationException` to shorten the line



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442421636

   Thanks for testing. Would have been to easy. I'll think about alternatives.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111317984


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();
-        for (int i = 0; i < name.length (); i++) {
-            if (Character.isLetterOrDigit (name.charAt (i)) ||
-                name.charAt (i) == '.') {
-                sb.append (name.charAt (i));
-            }
-            else {
-                String code = Integer.toHexString ((int)name.charAt (i)).toUpperCase ();
-                if (code.length ()<2)
-                    code = (code.length () == 0)? "00": "0"+code;   // NOI18N
-                sb.append ("%").                                    // NOI18N
-                append ((code.length () == 2)? code: code.substring (code.length ()-2));
-            }
-        }
-        return sb.toString ();
-    }
-    
-    /** Unconverts string from URL into old string. 
-     *  This mangling decodes '%xy'
-     */
-    static String demangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   since this file is already touched why not changing this to StringBuilder?



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111317496


##########
ide/httpserver/src/org/netbeans/modules/httpserver/GrantAccessPanel.java:
##########
@@ -55,7 +55,7 @@ private void initComponents() {
         localTopMessage.setDisabledTextColor (javax.swing.UIManager.getColor ("Label.foreground"));  // NOI18N
         localTopMessage.setFont (javax.swing.UIManager.getFont ("Label.font")); // NOI18N
 
-        StringBuffer lTopMessage = new StringBuffer();
+        StringBuilder lTopMessage = new StringBuilder();
         lTopMessage.append(msg);
         localTopMessage.setText(lTopMessage.toString());

Review Comment:
   Is lTopMessage even needed here? 
   Wouldn't
    
   localTopMessage.setText(msg != null ? msg : "null"); 
   suffice ?



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1445153116

   @mbien @lbownik thank you for your inputs. I reworked this and it should fix your comments. I rebased the changeset onto master and added new commits, that hold the changes. The original commits are unchanged. I plan to selectively squash before merge (see commit comments for the target commits).
   
   For controlling the server I dropped the progress handle approach and register the server in the `Services` tab:
   
   ![image](https://user-images.githubusercontent.com/2179736/221367676-b527eb77-565d-47ab-8589-9d0b09988c22.png)
   
   ![image](https://user-images.githubusercontent.com/2179736/221367686-a1f592c0-2d87-4343-ba66-523afa066618.png)
   
   ![image](https://user-images.githubusercontent.com/2179736/221367697-f83c90ff-b872-4d40-82ae-1bb5e5439d06.png)
   


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing merged pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing merged PR #5530:
URL: https://github.com/apache/netbeans/pull/5530


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442035032

   > > preview result of XSLT transformation
   > 
   > @matthiasblaesing this made me curious. When I press the blue xsl transformation button on a xml and transform it, it would open the transformed file directly in a browser (not from the webserver). This is not what you mean by preview, right?
   
   No, I meant this:
   
   ![image](https://user-images.githubusercontent.com/2179736/220961804-6d0b59cc-0943-4aab-8ace-6fcb95a32a5b.png)
   
   This allows you to preview, change the source, reload, repeat.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1117956163


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerURLMapper.java:
##########
@@ -82,7 +90,12 @@ private URL decodeURL(String path) {
                 newPath.append(tok);
             } else {
                 try {
-                    newPath.append(URLDecoder.decode(tok, "UTF-8")); // NOI18N
+                    String decodedToken = URLDecoder.decode(tok, "UTF-8"); // NOI18N
+                    if(decodedToken.startsWith("/") && decodedToken.endsWith("/")) { // NOI18N
+                        newPath.append(decodedToken.substring(1, decodedToken.length() - 1));

Review Comment:
   who about
   newPath.append(decodedToken, 1, decodedTocken.length() b -1) ;
   
   it avoids sub-string allocation and a loop
   turning newPath into StringBuilder  in line 86 would also improve performance a bit.



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1116027551


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:
##########
@@ -75,60 +90,77 @@ static void initHTTPServer() {
                 return;
             inSetRunning = true;
             try {
-                if ((serverThread != null) && (!httpserverSettings().running)) {
+                if ((tomcat != null) && (!HttpServerSettings.running)) {
                     // another thread is trying to start the server, wait for a while and then stop it if it's still bad
                     try {
-                        Thread.currentThread().sleep(2000);
+                        Thread.sleep(2000);
                     } catch (InterruptedException e) {}
-                    if ((serverThread != null) && (!httpserverSettings().running)) {
-                        serverThread.stop();
-                        serverThread = null;
+                    if ((tomcat != null) && (!HttpServerSettings.running)) {
+                        try {
+                            tomcat.stop();
+                            tomcat.destroy();
+                        } catch (LifecycleException ex) {
+                            Exceptions.printStackTrace(ex);
+                        }
+                        tomcat = null;
+                        progressHandle.close();
+                        progressHandle = null;
                     }
                 }
-                if (serverThread == null) {
-                    serverThread = new Thread("HTTPServer") { // NOI18N
-                        public void run() {
+                if (tomcat == null) {
+                    try {
+                        buildServer();
+                        tomcat.start();
+                        httpserverSettings().runSuccess();
+                        reloader.activate();
+                        progressHandle = ProgressHandle.createHandle(
+                                "Internal Webserver", () -> {
+                                    httpserverSettings().setRunning(false);
+                                    return true;
+                                }
+                        );
+                        progressHandle.start();
+                        progressHandle.progress("Running on port " + httpserverSettings().getPort());
+                        progressHandle.switchToDeterminate(1, 1);

Review Comment:
   instead of the two lines, this would work too I believe:
   `progressHandle.suspend("Running on port " + httpserverSettings().getPort());`



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442056656

   @matthiasblaesing wow. Yeah this works too. I somehow never realized that this was a combo box with other options than file names - everything makes sense now.
   
   I noticed that it is currently fairly easy to make NB throw exceptions while trying to open random resources in the web browser.
   
   example:
    - http://127.0.0.1:8082/resource
   ```
   java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "pi" is null
   	org.netbeans.modules.httpserver.WrapperServlet.getRequestURL(WrapperServlet.java:111)
   	org.netbeans.modules.httpserver.WrapperServlet.processRequest(WrapperServlet.java:66)
   	org.netbeans.modules.httpserver.WrapperServlet.doGet(WrapperServlet.java:52)
   	javax.servlet.http.HttpServlet.service(HttpServlet.java:497)
   	javax.servlet.http.HttpServlet.service(HttpServlet.java:584)
   ...
   ```
    - http://127.0.0.1:8082/resource/
   ```
    java.lang.IllegalArgumentException: URI is not absolute
   	java.base/java.net.URL.fromURI(URL.java:722)
   	java.base/java.net.URI.toURL(URI.java:1136)
   	org.netbeans.modules.httpserver.WrapperServlet.getRequestURL(WrapperServlet.java:115)
   	org.netbeans.modules.httpserver.WrapperServlet.processRequest(WrapperServlet.java:66)
   	org.netbeans.modules.httpserver.WrapperServlet.doGet(WrapperServlet.java:52)
   	javax.servlet.http.HttpServlet.service(HttpServlet.java:497)
   	javax.servlet.http.HttpServlet.service(HttpServlet.java:584)
   ...
   ```


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1117956163


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerURLMapper.java:
##########
@@ -82,7 +90,12 @@ private URL decodeURL(String path) {
                 newPath.append(tok);
             } else {
                 try {
-                    newPath.append(URLDecoder.decode(tok, "UTF-8")); // NOI18N
+                    String decodedToken = URLDecoder.decode(tok, "UTF-8"); // NOI18N
+                    if(decodedToken.startsWith("/") && decodedToken.endsWith("/")) { // NOI18N
+                        newPath.append(decodedToken.substring(1, decodedToken.length() - 1));

Review Comment:
   how about
   newPath.append(decodedToken, 1, decodedTocken.length() b -1) ;
   
   it avoids sub-string allocation and a loop
   turning newPath into StringBuilder  in line 86 would also improve performance a bit.



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lbownik commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "lbownik (via GitHub)" <gi...@apache.org>.
lbownik commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1117956163


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerURLMapper.java:
##########
@@ -82,7 +90,12 @@ private URL decodeURL(String path) {
                 newPath.append(tok);
             } else {
                 try {
-                    newPath.append(URLDecoder.decode(tok, "UTF-8")); // NOI18N
+                    String decodedToken = URLDecoder.decode(tok, "UTF-8"); // NOI18N
+                    if(decodedToken.startsWith("/") && decodedToken.endsWith("/")) { // NOI18N
+                        newPath.append(decodedToken.substring(1, decodedToken.length() - 1));

Review Comment:
   how about
   newPath.append(decodedToken, 1, decodedTocken.length() -1) ;
   
   it avoids sub-string allocation and a loop
   turning newPath into StringBuilder  in line 86 would also improve performance a bit.



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1436071750

   @BradWalker @mbien I saw your thumbs up. I assume you had a look at the changeset, so thank you.
   
   I'll let this stay for a week to give others time to have a look and if no-one objects till then, I'll merge.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1111318115


##########
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerSettings.java:
##########
@@ -428,54 +382,6 @@ Set<String> getGrantedAddressesSet() {
         return addr;
     }
 
-    Properties getMappedServlets() {
-        return mappedServlets;
-    }
-
-    /** Converts string into string that is usable in URL. 
-     *  This mangling changes some characters
-     */
-    static String mangle (String name) {
-        StringBuffer sb = new StringBuffer ();
-        for (int i = 0; i < name.length (); i++) {
-            if (Character.isLetterOrDigit (name.charAt (i)) ||
-                name.charAt (i) == '.') {
-                sb.append (name.charAt (i));
-            }
-            else {
-                String code = Integer.toHexString ((int)name.charAt (i)).toUpperCase ();
-                if (code.length ()<2)
-                    code = (code.length () == 0)? "00": "0"+code;   // NOI18N
-                sb.append ("%").                                    // NOI18N
-                append ((code.length () == 2)? code: code.substring (code.length ()-2));
-            }
-        }
-        return sb.toString ();
-    }
-    
-    /** Unconverts string from URL into old string. 
-     *  This mangling decodes '%xy'
-     */
-    static String demangle (String name) {
-        StringBuffer sb = new StringBuffer ();

Review Comment:
   Because I stared at this for multiple hours and will only invest more time, if really necessary.



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442136887

   another NPE during shutdown, might be more difficult to reproduce:
   ```
   java.lang.NullPointerException: Cannot invoke "org.netbeans.api.progress.ProgressHandle.close()" because "org.netbeans.modules.httpserver.HttpServerModule.progressHandle" is null
   	at org.netbeans.modules.httpserver.HttpServerModule.stopHTTPServer(HttpServerModule.java:192)
   	at org.netbeans.modules.httpserver.HttpServerModule.close(HttpServerModule.java:80)
   [catch] at org.netbeans.core.startup.NbInstaller.closeAsync(NbInstaller.java:718)
   	at org.netbeans.ModuleManager.shutDownAsync(ModuleManager.java:2372)
   	at org.netbeans.core.startup.ModuleSystem.shutDownAsync(ModuleSystem.java:346)
   	at org.netbeans.core.NbLifeExit.doExit(NbLifeExit.java:117)
   	at org.netbeans.core.NbLifeExit.run(NbLifeExit.java:72)
   ```


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1442172084

   the progress handle is causing a UX issue during shutdown. The IDE will open the warning dialog when background processes are still active while the user is trying to close the IDE, you probably didn't notice this since during dev time 
   `tryme.arg.hack=-J-Dnetbeans.full.hack=true` is set in `nbbuild/build.properties` and the dialog won't show up.
   
   
   ![exit_warning](https://user-images.githubusercontent.com/114367/220983319-2f7a6bad-a508-4df0-8730-030599b52904.png)
   
   
   The problem is that this dialog is opened **before** `HttpServerModule.close()` is called so there doesn't seem to be a clean way to fix this. Maybe @neilcsmith-net knows a trick.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on a diff in pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#discussion_r1117947586


##########
enterprise/web.monitor/serversrc/org/netbeans/modules/web/monitor/server/MonitorFilter.java:
##########
@@ -587,7 +587,7 @@ else if(debug) {
 	    return; 
 	} 
 
-	StringBuffer buf = 
+	StringBuffer buf =
 	    new StringBuffer(monData.getAttributeValue("id")); //NOI18N

Review Comment:
   curious whitespace change, potentially meant to change this to `StringBuilder`?



##########
enterprise/web.monitor/serversrc/org/netbeans/modules/web/monitor/server/NotifyUtil.java:
##########
@@ -117,28 +119,32 @@ void setIDE(String server) throws MalformedURLException {
     }
 		
     void sendRecord(MonitorData monData, String queryStr) {
-	
-	if(debug) log("NotifyUtil::notifyServer");  //NOI18N
-
-	if(ideServer != null) { 
-	    String urlStr = ideServer.concat(queryStr);
-	    if(debug) log("NotifyUtil: url is " + urlStr);  //NOI18N
-	    sendRecord(urlStr, monData); 
-	} 
-
-	if(otherIDEs.isEmpty()) return; 
-
-	Enumeration ides = otherIDEs.elements();
-	while(ides.hasMoreElements()) {
-
-	    String base = (String)ides.nextElement();
-
-	    if(debug) 
-		log("NotifyUtil: url is " + base.concat(queryStr)); //NOI18N
-	    if(!sendRecord(base.concat(queryStr), monData))
-		otherIDEs.remove(base); 
-	}
-	return; 
+        try {
+            if(debug) log("NotifyUtil::notifyServer");  //NOI18N
+
+            if(ideServer != null) {
+                    String urlStr = ideServer.concat(URLEncoder.encode(queryStr, "UTF-8")); //NOI18N
+                    if(debug) log("NotifyUtil: url is " + urlStr);  //NOI18N
+                    sendRecord(urlStr, monData);
+            }

Review Comment:
   some indentation issues here



-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #5530: Remove Thread#stop from httpserver and update embedded tomcat

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #5530:
URL: https://github.com/apache/netbeans/pull/5530#issuecomment-1445205687

   And another iteration.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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