From 8e5a9e1c70879f141a21af63899ac2efcd664194 Mon Sep 17 00:00:00 2001 From: pavl_g Date: Wed, 7 Aug 2024 17:18:55 -0400 Subject: [PATCH] FileLocator#classPathRoutine(): refactored the assertion to the FilesystemResourceInitializationException --- .../snaploader/filesystem/FileLocator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/filesystem/FileLocator.java b/snaploader/src/main/java/electrostatic4j/snaploader/filesystem/FileLocator.java index c93b3bc..3043bd9 100644 --- a/snaploader/src/main/java/electrostatic4j/snaploader/filesystem/FileLocator.java +++ b/snaploader/src/main/java/electrostatic4j/snaploader/filesystem/FileLocator.java @@ -148,8 +148,10 @@ public void initialize(int size) throws IOException { /** * Commands for the classpath routines. + * + * @throws FilesystemResourceInitializationException if the classpath routine fails to locate the file. */ - protected void classPathRoutine() { + protected void classPathRoutine() throws FilesystemResourceInitializationException { SnapLoaderLogger.log(Level.INFO, getClass().getName(), "initialize(int)", "File locator initialized using classpath routine with hash key #" + getHashKey()); // Use the AppClassLoader, a BuiltinClassLoader to get the resources from the classpath @@ -162,8 +164,9 @@ protected void classPathRoutine() { // getClassLoader() is invoked on them, it will return "null" pointer // indicating the invalidity of active loaders this.fileInputStream = getClass().getClassLoader().getResourceAsStream(filePath); - assert (this.fileInputStream != null): - "Classpath Routine failed: the file is not in the classpath!"; + if (this.fileInputStream == null) { + throw new FilesystemResourceInitializationException("Classpath Routine failed: the file is not in the classpath!"); + } } /**