Skip to content

Commit

Permalink
FileLocator#classPathRoutine(): refactored the assertion to the Files…
Browse files Browse the repository at this point in the history
…ystemResourceInitializationException
  • Loading branch information
pavly-gerges committed Aug 7, 2024
1 parent b1b4342 commit 8e5a9e1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!");
}
}

/**
Expand Down

0 comments on commit 8e5a9e1

Please sign in to comment.