Skip to content

Commit 30ab9f1

Browse files
committed
[GS] fixes possible exception when client disconnects - ci release
1 parent fa1baf5 commit 30ab9f1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

msi.gama.headless/src/msi/gama/headless/listener/GamaWebSocketServer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ public void onOpen(final WebSocket conn, final ClientHandshake handshake) {
159159
// conn.getRemoteSocketAddress().getAddress().getHostAddress() + " to the
160160
// server!");
161161
// broadcast("new connection: " + handshake.getResourceDescriptor()); // This
162-
// method sends a message to all clients connected
163-
DEBUG.OUT(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
162+
// method sends a message to all clients connected DEBUG.OUT(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
164163
conn.send(Jsoner
165164
.serialize(new GamaServerMessage(GamaServerMessageType.ConnectionSuccessful, "" + conn.hashCode())));
166165

@@ -169,7 +168,9 @@ public void onOpen(final WebSocket conn, final ClientHandshake handshake) {
169168
timer.scheduleAtFixedRate(new TimerTask() {
170169
@Override
171170
public void run() {
172-
conn.sendPing();
171+
if (conn.isOpen()) {
172+
conn.sendPing();
173+
}
173174
}
174175
}, 0, pingInterval);
175176
pingTimers.put(conn, timer);

msi.gama.headless/src/msi/gama/headless/listener/UploadCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public CommandResponse execute(final WebSocket socket, final IMap<String, Object
2222
}
2323

2424
try (FileWriter myWriter = new FileWriter(filepath)) {
25-
myWriter.write("" + content);
25+
myWriter.write(content);
2626
return new CommandResponse(GamaServerMessageType.CommandExecutedSuccessfully, "", map, false);
2727
} catch (Exception ex) {
2828
ex.printStackTrace();

0 commit comments

Comments
 (0)