Skip to content

Commit

Permalink
[NETBEANS-5080] Detach the request of DebugSession to avoid infinite …
Browse files Browse the repository at this point in the history
…loop(to finish the task)

https://issues.apache.org/jira/browse/NETBEANS-5080

DebugSession may be started via other ways.
e.g. via command line: `nc -vz localhost 9003`
In such a case, the debugger does not receive anything.
An infinite loop occurs because it waits until it receives data.
So need to detach the request when the debugger stops.
  • Loading branch information
junichi11 committed Dec 3, 2020
1 parent 0fe8a9a commit af08f08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ private void printing146558(Thread currentThread) {

@Override
public boolean cancel() {
// NETBEANS-5080 detach the request
// startProcessing() may be called via other ways
// e.g. via command line: nc -vz localhost 9003(debugger port)
// First of all, get the socket after the above command is run
// See: Socket sessionSocket = myServer.accept(); in ServerThread.run()
// Then, invokeLater.get() is called in startProcessing()
// Finally, infinite loop occurs in run() becuase do not still receive anything
detachRequest.set(true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ synchronized Session startSession(SessionId id, DebuggerOptions options, Callabl

public synchronized void stopSession(Session session) {
SessionId id = session.lookupFirst(null, SessionId.class);
// NETBEANS-5080 detach the request of the debug session to finish the task
DebugSession debugSession = session.lookupFirst(null, DebugSession.class);
if (debugSession != null) {
debugSession.cancel();
}
DebugSession debSess = getSession(id);
if (debSess != null) {
debSess.stopSession();
Expand Down

0 comments on commit af08f08

Please sign in to comment.