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