From d1132806da1158da73da9bf0c14a71beed124c24 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 12:04:22 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20NPE=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BF=D1=83=D1=81=D0=BA=D0=B5=20LaunchServer`=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/binary/LauncherBinary.java | 11 ++++++----- .../java/pro/gravit/utils/helper/CommonHelper.java | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index d09db69c..238e9de3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -41,8 +41,7 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); - if (sign != null) - CommonHelper.removeExc(sign); + CommonHelper.removeExc(sign); if (binary != null) { CommonHelper.removeExc(binary.getBytes()); CommonHelper.removeExc(binary.getDigest()); @@ -50,9 +49,11 @@ public final boolean sync() throws IOException { binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; CommonHelper.addExc(sign); - CommonHelper.addExc(binary.getBytes()); - CommonHelper.addExc(binary.getDigest()); - return exists; + if (binary != null) { + CommonHelper.addExc(binary.getBytes()); + CommonHelper.addExc(binary.getDigest()); + } + return exists; } public static Path resolve(LaunchServer server, String ext) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 18e4a1de..b0000ead 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -143,12 +143,14 @@ public static GsonBuilder newBuilder() { } public static void addExc(byte[] exclusion) { + if (exclusion == null) return; JsonArray add = new JsonArray(exclusion.length); for (byte b : exclusion) add.add(new JsonPrimitive(b)); ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); } public static void removeExc(byte[] exclusion) { + if (exclusion == null) return; ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); }