提交 0a04addf authored 作者: Thomas Mueller's avatar Thomas Mueller

TCP server: when using the trace option ("-trace"), the trace output contained…

TCP server: when using the trace option ("-trace"), the trace output contained unnecessary stack traces when stopping the server.
上级 ebdae507
......@@ -199,8 +199,10 @@ public class TcpServerThread implements Runnable {
}
transfer.writeInt(SessionRemote.STATUS_ERROR).writeString(e.getSQLState()).writeString(message)
.writeString(sql).writeInt(e.getErrorCode()).writeString(trace).flush();
} catch (IOException e2) {
server.traceError(e2);
} catch (Exception e2) {
if (!transfer.isClosed()) {
server.traceError(e2);
}
// if writing the error does not work, close the connection
stop = true;
}
......
......@@ -73,9 +73,11 @@ public class Transfer {
* Initialize the transfer object. This method will try to open an input and
* output stream.
*/
public void init() throws IOException {
in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), Transfer.BUFFER_SIZE));
out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), Transfer.BUFFER_SIZE));
public synchronized void init() throws IOException {
if (socket != null) {
in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), Transfer.BUFFER_SIZE));
out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), Transfer.BUFFER_SIZE));
}
}
/**
......@@ -277,10 +279,12 @@ public class Transfer {
/**
* Close the transfer object and the socket.
*/
public void close() {
public synchronized void close() {
if (socket != null) {
try {
out.flush();
if (out != null) {
out.flush();
}
if (socket != null) {
socket.close();
}
......@@ -613,4 +617,8 @@ public class Transfer {
this.version = version;
}
public synchronized boolean isClosed() {
return socket == null || socket.isClosed();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论