mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-05 18:42:55 +00:00
catch SocketException; it seems a valid alternative to reading -1 if the server has closed the connection
Change-Id: Iaee1dd2a35cea0b00f338fd3bb8f2e13067813f8
This commit is contained in:
1 parent
6a26465cc5
commit
dbf33e1693
2 files changed
+10
-5
No files matched your search
+2
-3
@@ -288,7 +288,6 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
boolean stop = false;
|
||||
while (!stop) {
|
||||
final Socket s = ss.accept();
|
||||
// String request = new BufferedReader(new InputStreamReader(s.getInputStream())).readLine();
|
||||
final InputStream inputStream = s.getInputStream();
|
||||
String request = readLine(inputStream);
|
||||
logger.info("received request "+request);
|
||||
@@ -375,8 +374,8 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
logger.info("received STOP request");
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
pw.close();
|
||||
pw.close(); // important: close this first, so response is delivered
|
||||
inputStream.close(); // this may let a client-side read() terminate abnormally with a SocketException
|
||||
s.close();
|
||||
logger.info("Request handled successfully.");
|
||||
}
|
||||
|
||||
+8
-2
@@ -9,6 +9,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,6 +37,7 @@ import com.sap.sse.common.Util;
|
||||
import com.sap.sse.replication.OperationExecutionListener;
|
||||
import com.sap.sse.replication.OperationWithResult;
|
||||
import com.sap.sse.replication.OperationsToMasterSender;
|
||||
import com.sap.sse.replication.OperationsToMasterSendingQueue;
|
||||
import com.sap.sse.replication.ReplicaDescriptor;
|
||||
import com.sap.sse.replication.Replicable;
|
||||
import com.sap.sse.replication.ReplicablesProvider;
|
||||
@@ -43,7 +45,6 @@ import com.sap.sse.replication.ReplicablesProvider.ReplicableLifeCycleListener;
|
||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||
import com.sap.sse.replication.ReplicationReceiver;
|
||||
import com.sap.sse.replication.ReplicationService;
|
||||
import com.sap.sse.replication.OperationsToMasterSendingQueue;
|
||||
import com.sap.sse.util.HttpUrlConnectionHelper;
|
||||
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
@@ -689,7 +690,12 @@ public class ReplicationServiceImpl implements ReplicationService, OperationsToM
|
||||
int read = content.read(buf);
|
||||
while (read != -1) {
|
||||
uuid.append(new String(buf, 0, read));
|
||||
read = content.read(buf);
|
||||
try {
|
||||
read = content.read(buf);
|
||||
} catch (SocketException e) {
|
||||
// the connection may have been closed already; interpret this as the end of the stream
|
||||
read = -1;
|
||||
}
|
||||
}
|
||||
final String replicaUUID = uuid.toString();
|
||||
registerReplicaUuidForMaster(replicaUUID, master);
|
||||
|
||||
Reference in new issue
Block a user