From 49112b23aa4d0b82dfde12c8dbf1244434cb7d23 Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 22 Aug 2026 12:53:54 +0200 Subject: [PATCH 1/2] fix(reporter): degrade to the placeholder image when a resource property is unset Resources.loadImage(fname) built "/" + fname and looked that up regardless of whether fname was null, so a missing property produced the literal path "/null" - Resources.class.getResource("/null") returns null, and the method threw FileNotFoundException("/null") instead of falling back to its own placeholder image the way it already does for a genuinely-missing-but-named resource. RES_BANNER_IMAGE/RES_SERVER_ICON only exist in a downstream consumer's crashreporter.properties (cr-terasology, cr-destsol, ...), not cr-core's own crashreporter_defaults.properties - so GlobalProperties.get() returning null for those keys is an expected, not exceptional, case whenever cr-core runs standalone (confirmed while testing runInteractiveTest: this is exactly what crashed RootPanel's banner image lookup). Co-Authored-By: Claude Sonnet 5 --- .../java/org/terasology/crashreporter/Resources.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cr-core/src/main/java/org/terasology/crashreporter/Resources.java b/cr-core/src/main/java/org/terasology/crashreporter/Resources.java index 75c7cfa..01606e5 100644 --- a/cr-core/src/main/java/org/terasology/crashreporter/Resources.java +++ b/cr-core/src/main/java/org/terasology/crashreporter/Resources.java @@ -28,10 +28,19 @@ private Resources() { } /** - * @param fname the absolute path in the jar/project + * @param fname the absolute path in the jar/project, or {@code null} if the property naming it + * was never set - e.g. {@code RES_BANNER_IMAGE}/{@code RES_SERVER_ICON} only exist + * in a downstream consumer's {@code crashreporter.properties} + * ({@code cr-terasology}, {@code cr-destsol}, ...), not {@code cr-core}'s own + * {@code crashreporter_defaults.properties} - so any caller running against + * {@code cr-core} alone can hit this with {@code null}, not just a bad filename. * @return the buffered image, wrapped in an Icon */ public static BufferedImage loadImage(String fname) { + if (fname == null) { + System.err.println("No resource path given (missing property?) - using placeholder image"); + return createDummyImage(64, 64, "?"); + } try { String fullPath = "/" + fname; URL rsc = Resources.class.getResource(fullPath); From d92bf2c0caca973c87f20194182375637844fea9 Mon Sep 17 00:00:00 2001 From: BenjaminAmos <24301287+BenjaminAmos@users.noreply.github.com> Date: Sat, 22 Aug 2026 13:10:52 +0100 Subject: [PATCH 2/2] style: clarify comment in Resources.java --- .../main/java/org/terasology/crashreporter/Resources.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cr-core/src/main/java/org/terasology/crashreporter/Resources.java b/cr-core/src/main/java/org/terasology/crashreporter/Resources.java index 01606e5..f5f0027 100644 --- a/cr-core/src/main/java/org/terasology/crashreporter/Resources.java +++ b/cr-core/src/main/java/org/terasology/crashreporter/Resources.java @@ -29,11 +29,7 @@ private Resources() { /** * @param fname the absolute path in the jar/project, or {@code null} if the property naming it - * was never set - e.g. {@code RES_BANNER_IMAGE}/{@code RES_SERVER_ICON} only exist - * in a downstream consumer's {@code crashreporter.properties} - * ({@code cr-terasology}, {@code cr-destsol}, ...), not {@code cr-core}'s own - * {@code crashreporter_defaults.properties} - so any caller running against - * {@code cr-core} alone can hit this with {@code null}, not just a bad filename. + * was never set * @return the buffered image, wrapped in an Icon */ public static BufferedImage loadImage(String fname) {