Skip to content
Snippets Groups Projects
Commit 47efa893 authored by Sebastian Krings's avatar Sebastian Krings
Browse files

port prob2 change to handling of windows newlines in socket server communication

parent f0f9cb16
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import java.io.IOException; ...@@ -12,6 +12,7 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.nio.charset.Charset;
import de.prob.cli.CliException; import de.prob.cli.CliException;
import de.prob.cli.CliStarter; import de.prob.cli.CliStarter;
...@@ -49,6 +50,7 @@ public class ServerConnection implements IServerConnection { ...@@ -49,6 +50,7 @@ public class ServerConnection implements IServerConnection {
return lastCommand; return lastCommand;
} }
@Override
public String getDebuggingKey() { public String getDebuggingKey() {
return cli == null ? null : cli.getDebuggingKey(); return cli == null ? null : cli.getDebuggingKey();
} }
...@@ -75,6 +77,7 @@ public class ServerConnection implements IServerConnection { ...@@ -75,6 +77,7 @@ public class ServerConnection implements IServerConnection {
} }
} }
@Override
public String sendCommand(final String commandString) throws ProBException { public String sendCommand(final String commandString) throws ProBException {
if (shutdown) { if (shutdown) {
final String message = "probcli is currently shutting down"; final String message = "probcli is currently shutting down";
...@@ -100,7 +103,8 @@ public class ServerConnection implements IServerConnection { ...@@ -100,7 +103,8 @@ public class ServerConnection implements IServerConnection {
try { try {
input = readAnswer(); input = readAnswer();
if (input == null) if (input == null)
throw new IOException("ProB binary returned nothing - it might have crashed"); throw new IOException(
"ProB binary returned nothing - it might have crashed");
} catch (final IOException e) { } catch (final IOException e) {
shutdown(); shutdown();
String message = "Exception while reading from socket"; String message = "Exception while reading from socket";
...@@ -152,7 +156,9 @@ public class ServerConnection implements IServerConnection { ...@@ -152,7 +156,9 @@ public class ServerConnection implements IServerConnection {
// trim white spaces and append // trim white spaces and append
// instead of removing the last byte trim is used, because on // instead of removing the last byte trim is used, because on
// windows prob uses \r\n as new line. // windows prob uses \r\n as new line.
result.append((new String(buffer, 0, count)).trim()); String s = new String(buffer, 0, count, Charset
.defaultCharset().name());
result.append(s.replace("\r", "").replace("\n", ""));
} else { } else {
done = true; done = true;
} }
...@@ -161,6 +167,7 @@ public class ServerConnection implements IServerConnection { ...@@ -161,6 +167,7 @@ public class ServerConnection implements IServerConnection {
return result.length() > 0 ? result.toString() : null; return result.length() > 0 ? result.toString() : null;
} }
@Override
public void startup(final File file) throws CliException { public void startup(final File file) throws CliException {
if (shutdown) { if (shutdown) {
startcli(file); startcli(file);
...@@ -173,6 +180,7 @@ public class ServerConnection implements IServerConnection { ...@@ -173,6 +180,7 @@ public class ServerConnection implements IServerConnection {
} }
} }
@Override
public void shutdown() { public void shutdown() {
if (!shutdown) { if (!shutdown) {
if (socket != null) { if (socket != null) {
...@@ -199,6 +207,7 @@ public class ServerConnection implements IServerConnection { ...@@ -199,6 +207,7 @@ public class ServerConnection implements IServerConnection {
} }
} }
@Override
public int getCliPortNumber() { public int getCliPortNumber() {
return cli.getPort(); return cli.getPort();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment