You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/05/19 13:34:53 UTC

[GitHub] [netbeans] entlicher opened a new pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

entlicher opened a new pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964


   Assure that we notify the finish of the debug/run session through LSP.


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

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] JaroslavTulach commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r637353150



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -198,16 +197,26 @@ public void progressHandleCreated(ProgressOperationEvent e) {
                     Lookup.getDefault()
             );
             List<String> args = argsToStringList(launchArguments.get("args"));
+            // Add session's lookup, it may override dialog displayer, etc.
+            Lookup execLookup = new ProxyLookup(launchCtx, context.getLspSession().getLookup());
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                        debugProgress.finished(exitCode == 0);
+                    });
+                    Lookups.executeWith(execLookup, () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, ed, launchFuture, debugProgress);
                     });
                 });
             } else {
-                Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                    ioContext.stop();
+                    notifyFinished(context, exitCode == 0);

Review comment:
       I've run into the problem myself as well. Then I checked the Javadoc and saw the `null` note. Then I have just fixed my code. Feel free to improve the javadoc or enhance the API.




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

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] JaroslavTulach commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r637094025



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -198,16 +197,26 @@ public void progressHandleCreated(ProgressOperationEvent e) {
                     Lookup.getDefault()
             );
             List<String> args = argsToStringList(launchArguments.get("args"));
+            // Add session's lookup, it may override dialog displayer, etc.
+            Lookup execLookup = new ProxyLookup(launchCtx, context.getLspSession().getLookup());
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                        debugProgress.finished(exitCode == 0);
+                    });
+                    Lookups.executeWith(execLookup, () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, ed, launchFuture, debugProgress);
                     });
                 });
             } else {
-                Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                    ioContext.stop();
+                    notifyFinished(context, exitCode == 0);

Review comment:
       The `exitCode` can be `null` in case there is an error launching the executable, etc. This would probably yield a `NPE`.




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

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] JaroslavTulach commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r635970171



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -200,30 +201,43 @@ public void progressHandleCreated(ProgressOperationEvent e) {
             List<String> args = argsToStringList(launchArguments.get("args"));
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    // Add session's lookup, it may override dialog displayer, etc.
+                    Lookups.executeWith(new ProxyLookup(launchCtx, context.getLspSession().getLookup()), () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture, debugProgress);
                     });
                 });
             } else {
+                AtomicReference<Future<Integer>> run = new AtomicReference<>();
                 Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                    run.set(execNative(nativeImageFile, args, context, executionDescriptor, launchFuture));
+                });
+                new RequestProcessor().post(() -> {
+                    Integer ret;

Review comment:
       This looks like the old, ugly pattern. Since https://github.com/apache/netbeans/pull/2938/files#r635969684 once can get the `exitCode` (or `null`) synchronously as soon as execution is over.




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

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] entlicher commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
entlicher commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r637293965



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -198,16 +197,26 @@ public void progressHandleCreated(ProgressOperationEvent e) {
                     Lookup.getDefault()
             );
             List<String> args = argsToStringList(launchArguments.get("args"));
+            // Add session's lookup, it may override dialog displayer, etc.
+            Lookup execLookup = new ProxyLookup(launchCtx, context.getLspSession().getLookup());
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                        debugProgress.finished(exitCode == 0);
+                    });
+                    Lookups.executeWith(execLookup, () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, ed, launchFuture, debugProgress);
                     });
                 });
             } else {
-                Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                    ioContext.stop();
+                    notifyFinished(context, exitCode == 0);

Review comment:
       Null check added.




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

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] entlicher merged pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
entlicher merged pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964


   


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

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] JaroslavTulach commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r637353150



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -198,16 +197,26 @@ public void progressHandleCreated(ProgressOperationEvent e) {
                     Lookup.getDefault()
             );
             List<String> args = argsToStringList(launchArguments.get("args"));
+            // Add session's lookup, it may override dialog displayer, etc.
+            Lookup execLookup = new ProxyLookup(launchCtx, context.getLspSession().getLookup());
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                        debugProgress.finished(exitCode == 0);
+                    });
+                    Lookups.executeWith(execLookup, () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, ed, launchFuture, debugProgress);
                     });
                 });
             } else {
-                Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                    ioContext.stop();
+                    notifyFinished(context, exitCode == 0);

Review comment:
       I'd run into the problem myself as well. Then I checked the Javadoc and saw the `null` note. Then I have just fixed my code. Feel free to improve the javadoc or enhance the API.




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

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] entlicher commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
entlicher commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r636772558



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -200,30 +201,43 @@ public void progressHandleCreated(ProgressOperationEvent e) {
             List<String> args = argsToStringList(launchArguments.get("args"));
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    // Add session's lookup, it may override dialog displayer, etc.
+                    Lookups.executeWith(new ProxyLookup(launchCtx, context.getLspSession().getLookup()), () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture, debugProgress);
                     });
                 });
             } else {
+                AtomicReference<Future<Integer>> run = new AtomicReference<>();
                 Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                    run.set(execNative(nativeImageFile, args, context, executionDescriptor, launchFuture));
+                });
+                new RequestProcessor().post(() -> {
+                    Integer ret;

Review comment:
       That significantly simplified the code, thanks.
   And it uncovered a bug in cpplite debugger - the GDB process did not finish after application exit. This is fixed, including a test, as well.




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

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] entlicher commented on a change in pull request #2964: [NETBEANS-5693] Assure that debugger session finishes when native image application exits.

Posted by GitBox <gi...@apache.org>.
entlicher commented on a change in pull request #2964:
URL: https://github.com/apache/netbeans/pull/2964#discussion_r637291509



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -198,16 +197,26 @@ public void progressHandleCreated(ProgressOperationEvent e) {
                     Lookup.getDefault()
             );
             List<String> args = argsToStringList(launchArguments.get("args"));
+            // Add session's lookup, it may override dialog displayer, etc.
+            Lookup execLookup = new ProxyLookup(launchCtx, context.getLspSession().getLookup());
             if (debug) {
                 requestProcessor.post(() -> {
-                    Lookups.executeWith(launchCtx, () -> {
+                    ActionProgress debugProgress = ActionProgress.start(launchCtx);
+                    ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                        debugProgress.finished(exitCode == 0);
+                    });
+                    Lookups.executeWith(execLookup, () -> {
                         String miDebugger = (String) launchArguments.get("miDebugger");
-                        startNativeDebug(nativeImageFile, args, miDebugger, context, executionDescriptor, launchFuture);
+                        startNativeDebug(nativeImageFile, args, miDebugger, context, ed, launchFuture, debugProgress);
                     });
                 });
             } else {
-                Lookups.executeWith(launchCtx, () -> {
-                    execNative(nativeImageFile, args, context, executionDescriptor, launchFuture);//, success);
+                ExecutionDescriptor ed = executionDescriptor.postExecution(exitCode -> {
+                    ioContext.stop();
+                    notifyFinished(context, exitCode == 0);

Review comment:
       That's a catch! It's unexpected. This fact is not clear from the Javadoc. The annotation and the Javadoc says, that `postExecution` argument is allowed to be `null`. Not that the exit code passed to the Consumer can be `null`.
   It'd be good to explicitly stress that.
   Unfortunately, the functional features hurt the safeness of Java. It's impossible to put `@NullAllowed` on the `exitCode` parameter. I'd need to do it myself (which misses the point).




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

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