mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
reverted to per-byte request reading but close input stream before closing output stream on server
Change-Id: I711b6652838b53bda91e209c9573d58cfe73ad79
This commit is contained in:
+8
-10
@@ -2,11 +2,9 @@ package com.sap.sse.replication.testsupport;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
@@ -290,9 +288,9 @@ 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);
|
||||
// String request = new BufferedReader(new InputStreamReader(s.getInputStream())).readLine();
|
||||
final InputStream inputStream = s.getInputStream();
|
||||
String request = readLine(inputStream);
|
||||
logger.info("received request "+request);
|
||||
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
|
||||
if (request.startsWith("POST /replication/replication")) {
|
||||
@@ -302,7 +300,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
try {
|
||||
return s.getInputStream().available() <= 0;
|
||||
return inputStream.available() <= 0;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -311,7 +309,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
try {
|
||||
return s.getInputStream().available() > 0;
|
||||
return inputStream.available() > 0;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -323,7 +321,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return s.getInputStream().read();
|
||||
return inputStream.read();
|
||||
}
|
||||
});
|
||||
final HttpServletResponse responseMock = Mockito.mock(HttpServletResponse.class);
|
||||
@@ -340,7 +338,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
return null;
|
||||
}
|
||||
}).when(responseMock).sendError(Matchers.anyInt(), Matchers.isA(String.class));
|
||||
while (!readLine(s.getInputStream()).isEmpty());
|
||||
while (!readLine(inputStream).isEmpty());
|
||||
servlet.doPost(requestMock, responseMock);
|
||||
if (!error[0]) {
|
||||
pw.println("HTTP/1.1 200 OK");
|
||||
@@ -377,8 +375,8 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
logger.info("received STOP request");
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
pw.close();
|
||||
s.getInputStream().close();
|
||||
s.close();
|
||||
logger.info("Request handled successfully.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user