Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ProB Rodin Plugin
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB Rodin Plugin
Commits
47efa893
Commit
47efa893
authored
10 years ago
by
Sebastian Krings
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
de.prob.core/src/de/prob/core/internal/ServerConnection.java
+11
-2
11 additions, 2 deletions
de.prob.core/src/de/prob/core/internal/ServerConnection.java
with
11 additions
and
2 deletions
de.prob.core/src/de/prob/core/internal/ServerConnection.java
+
11
−
2
View file @
47efa893
...
@@ -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
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment