[FIX] NPE при запуске LaunchServer`а.

This commit is contained in:
Zaxar163 2019-06-11 12:04:22 +03:00
parent 408da409df
commit d1132806da
2 changed files with 8 additions and 5 deletions

View file

@ -41,7 +41,6 @@ public void init() {
public final boolean sync() throws IOException { public final boolean sync() throws IOException {
boolean exists = exists(); boolean exists = exists();
if (sign != null)
CommonHelper.removeExc(sign); CommonHelper.removeExc(sign);
if (binary != null) { if (binary != null) {
CommonHelper.removeExc(binary.getBytes()); CommonHelper.removeExc(binary.getBytes());
@ -50,8 +49,10 @@ public final boolean sync() throws IOException {
binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null;
sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null;
CommonHelper.addExc(sign); CommonHelper.addExc(sign);
if (binary != null) {
CommonHelper.addExc(binary.getBytes()); CommonHelper.addExc(binary.getBytes());
CommonHelper.addExc(binary.getDigest()); CommonHelper.addExc(binary.getDigest());
}
return exists; return exists;
} }

View file

@ -143,12 +143,14 @@ public static GsonBuilder newBuilder() {
} }
public static void addExc(byte[] exclusion) { public static void addExc(byte[] exclusion) {
if (exclusion == null) return;
JsonArray add = new JsonArray(exclusion.length); JsonArray add = new JsonArray(exclusion.length);
for (byte b : exclusion) add.add(new JsonPrimitive(b)); for (byte b : exclusion) add.add(new JsonPrimitive(b));
ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add);
} }
public static void removeExc(byte[] exclusion) { public static void removeExc(byte[] exclusion) {
if (exclusion == null) return;
ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion);
} }