Fix potential NPE

This commit is contained in:
ME1312 2022-04-09 21:03:29 -04:00
parent e4300e76e2
commit ce262c62f0
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 8 additions and 6 deletions

View File

@ -70,10 +70,10 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
queue(host.getName(), () -> client.sendPacket(new PacketLinkExHost(0, null)));
setReady(client);
} else {
client.sendPacket(new PacketLinkExHost(3, "Host already linked"));
client.sendPacket(new PacketLinkExHost(3, "Host already linked: " + data.getString(0x0000)));
}
} else {
client.sendPacket(new PacketLinkExHost(4, "That host does not support a network interface"));
client.sendPacket(new PacketLinkExHost(4, "Requested host does not support network interfaces: " + data.getString(0x0000)));
}
} else {
client.sendPacket(new PacketLinkExHost(2, "There is no host with name: " + data.getString(0x0000)));

View File

@ -81,7 +81,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
queue(proxy.getName(), () -> client.sendPacket(new PacketLinkProxy(proxy.getName(), 0, null)));
setReady(client);
} else {
client.sendPacket(new PacketLinkProxy(proxy.getName(), 2, "Proxy already linked"));
client.sendPacket(new PacketLinkProxy(null, 2, "Proxy already linked: " + proxy.getName()));
}
} catch (Throwable e) {

View File

@ -176,7 +176,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
last = now;
setReady(client);
} else {
client.sendPacket(new PacketLinkServer(null, 4, "Server already linked"));
client.sendPacket(new PacketLinkServer(null, 4, "Server already linked: " + server.getName()));
}
}
}

View File

@ -98,6 +98,7 @@ public class SubServerImpl {
private void run() {
boolean falsestart = true;
int exit = Integer.MIN_VALUE;
allowrestart = true;
try {
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getString("Git-Bash"), executable)).directory(directory);
@ -121,6 +122,7 @@ public class SubServerImpl {
queue.clear();
if (process.isAlive()) process.waitFor();
exit = process.exitValue();
} catch (IOException | InterruptedException e) {
host.log.error.println(e);
allowrestart = false;
@ -128,8 +130,8 @@ public class SubServerImpl {
}
logger.destroy();
if (SubAPI.getInstance().getSubDataNetwork()[0] != null) {
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketExControlServer(this, Response.STOPPED, (Integer) process.exitValue(), (Boolean) allowrestart));
if (SubAPI.getInstance().getSubDataNetwork()[0] != null) { // noinspection UnnecessaryBoxing
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketExControlServer(this, Response.STOPPED, Integer.valueOf(exit), Boolean.valueOf(allowrestart)));
}
host.log.info.println(name + " has stopped");
process = null;