From 5328edad076b49539c6dcf54a024edd6e53f0724 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 10 Jun 2026 12:19:41 +0200 Subject: [PATCH] fix: GameService.load() NPE on null bundleFile + ZipService test path - GameService.load(): null-check bundleFile before resolving path (Path.resolve(null) throws NullPointerException) - ZipServiceTest: pass absolute exePath to createBundle (relativize requires both paths to be absolute or both relative) --- src/main/java/org/dostalgia/GameService.java | 9 ++++++--- src/test/java/org/dostalgia/ZipServiceTest.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dostalgia/GameService.java b/src/main/java/org/dostalgia/GameService.java index a2fb409..fecd4df 100644 --- a/src/main/java/org/dostalgia/GameService.java +++ b/src/main/java/org/dostalgia/GameService.java @@ -77,9 +77,12 @@ public class GameService implements GameStore { ); // Detect bundle size try { - Path bundlePath = gamesDir.resolve(game.getBundleFile()); - if (Files.exists(bundlePath)) { - game.setBundleSize(Files.size(bundlePath)); + String bf = game.getBundleFile(); + if (bf != null) { + Path bundlePath = gamesDir.resolve(bf); + if (Files.exists(bundlePath)) { + game.setBundleSize(Files.size(bundlePath)); + } } } catch (IOException ignored) {} return game; diff --git a/src/test/java/org/dostalgia/ZipServiceTest.java b/src/test/java/org/dostalgia/ZipServiceTest.java index ab512ad..535167b 100644 --- a/src/test/java/org/dostalgia/ZipServiceTest.java +++ b/src/test/java/org/dostalgia/ZipServiceTest.java @@ -154,7 +154,7 @@ class ZipServiceTest { Path bundlePath = dir.resolve("output.jsdos"); - zip.createBundle(extractDir, "game.exe", List.of(), bundlePath); + zip.createBundle(extractDir, extractDir.resolve("game.exe").toString(), List.of(), bundlePath); assertTrue(Files.exists(bundlePath)); assertTrue(Files.size(bundlePath) > 0); @@ -193,7 +193,7 @@ class ZipServiceTest { Path bundlePath = dir.resolve("output.jsdos"); - zip.createBundle(extractDir, "game.exe", List.of(), bundlePath); + zip.createBundle(extractDir, extractDir.resolve("game.exe").toString(), List.of(), bundlePath); try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(bundlePath))) { ZipEntry entry;