mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21488 Stopping docker debug process unexpectedly in the very beginning of Python debug session fixed (take 2)
This commit is contained in:
+3
-2
@@ -30,8 +30,7 @@ public abstract class BaseDebuggerTransport implements DebuggerTransport {
|
||||
return sendMessageImpl(packed);
|
||||
}
|
||||
catch (SocketException se) {
|
||||
myDebugger.disconnect();
|
||||
myDebugger.fireCommunicationError();
|
||||
onSocketException();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.debug(e);
|
||||
@@ -41,6 +40,8 @@ public abstract class BaseDebuggerTransport implements DebuggerTransport {
|
||||
|
||||
protected abstract boolean sendMessageImpl(byte[] packed) throws IOException;
|
||||
|
||||
protected abstract void onSocketException();
|
||||
|
||||
public static void logFrame(ProtocolFrame frame, boolean out) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("%1$tH:%1$tM:%1$tS.%1$tL %2$s %3$s\n", new Date(), (out ? "<<<" : ">>>"), frame));
|
||||
|
||||
+22
-7
@@ -17,6 +17,7 @@ import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* {@link DebuggerTransport} implementation that expects a debugging script to behave as a server. The main process of the debugging script
|
||||
@@ -73,10 +74,6 @@ public class ClientModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
"Inappropriate state of Python debugger for connecting to Python debugger: " + myState + "; " + State.INIT + " is expected");
|
||||
}
|
||||
|
||||
doConnect();
|
||||
}
|
||||
|
||||
private void doConnect() throws IOException {
|
||||
synchronized (mySocketObject) {
|
||||
if (mySocket != null) {
|
||||
try {
|
||||
@@ -126,6 +123,7 @@ public class ClientModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
beforeHandshake.countDown();
|
||||
try {
|
||||
myDebugger.handshake();
|
||||
myDebuggerReader.connectionApproved();
|
||||
return true;
|
||||
}
|
||||
catch (PyDebuggerException e) {
|
||||
@@ -194,6 +192,14 @@ public class ClientModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSocketException() {
|
||||
myDebugger.disconnect();
|
||||
if (myState == State.APPROVED) {
|
||||
myDebugger.fireCommunicationError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
@@ -246,7 +252,12 @@ public class ClientModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
DISCONNECTED
|
||||
}
|
||||
|
||||
public class DebuggerReader extends BaseDebuggerReader {
|
||||
public static class DebuggerReader extends BaseDebuggerReader {
|
||||
/**
|
||||
* Indicates that the debugger connection has been approved within this {@link DebuggerReader}.
|
||||
*/
|
||||
private final AtomicBoolean myConnectionApproved = new AtomicBoolean(false);
|
||||
|
||||
public DebuggerReader(@NotNull RemoteDebugger debugger, @NotNull InputStream stream) throws IOException {
|
||||
super(stream, CharsetToolkit.UTF8_CHARSET, debugger); //TODO: correct encoding?
|
||||
start(getClass().getName());
|
||||
@@ -254,16 +265,20 @@ public class ClientModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
|
||||
@Override
|
||||
protected void onExit() {
|
||||
if (myState == State.APPROVED) {
|
||||
if (myConnectionApproved.get()) {
|
||||
getDebugger().fireExitEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCommunicationError() {
|
||||
if (myState == State.APPROVED) {
|
||||
if (myConnectionApproved.get()) {
|
||||
getDebugger().fireCommunicationError();
|
||||
}
|
||||
}
|
||||
|
||||
public void connectionApproved() {
|
||||
myConnectionApproved.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -108,6 +108,12 @@ public class ServerModeDebuggerTransport extends BaseDebuggerTransport {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSocketException() {
|
||||
myDebugger.disconnect();
|
||||
myDebugger.fireCommunicationError();
|
||||
}
|
||||
|
||||
public static class DebuggerReader extends BaseDebuggerReader {
|
||||
public DebuggerReader(@NotNull RemoteDebugger debugger, @NotNull InputStream stream) throws IOException {
|
||||
super(stream, CharsetToolkit.UTF8_CHARSET, debugger); //TODO: correct encoding?
|
||||
|
||||
Reference in New Issue
Block a user