From ddf31fd1a549c8f0c3528a241b8e70f650c0a9f5 Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Thu, 11 May 2023 09:32:50 -0400 Subject: [PATCH] Initialize BldVersion directly using the classloader resources. --- src/main/java/rife/bld/BldVersion.java | 19 ++++++++++++++----- src/main/java/rife/bld/wrapper/Wrapper.java | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/rife/bld/BldVersion.java b/src/main/java/rife/bld/BldVersion.java index b28cc03..d4a8c0a 100644 --- a/src/main/java/rife/bld/BldVersion.java +++ b/src/main/java/rife/bld/BldVersion.java @@ -4,8 +4,9 @@ */ package rife.bld; -import rife.resources.ResourceFinderClasspath; -import rife.resources.exceptions.ResourceFinderErrorException; +import rife.tools.FileUtils; + +import java.io.IOException; /** * Singleton class that provides access to the current bld version as a string. @@ -17,10 +18,18 @@ public class BldVersion { private String version_; BldVersion() { - ResourceFinderClasspath resource_finder = ResourceFinderClasspath.instance(); + var resource = getClass().getClassLoader().getResource("BLD_VERSION"); try { - version_ = resource_finder.getContent("BLD_VERSION"); - } catch (ResourceFinderErrorException e) { + if (resource == null) { + version_ = null; + } else { + var connection = resource.openConnection(); + connection.setUseCaches(false); + try (var input_stream = connection.getInputStream()) { + version_ = FileUtils.readString(input_stream); + } + } + } catch (IOException e) { version_ = null; } diff --git a/src/main/java/rife/bld/wrapper/Wrapper.java b/src/main/java/rife/bld/wrapper/Wrapper.java index 571cf87..15d30d2 100644 --- a/src/main/java/rife/bld/wrapper/Wrapper.java +++ b/src/main/java/rife/bld/wrapper/Wrapper.java @@ -429,7 +429,7 @@ public class Wrapper { } } - // find the wrapper classloader in the hierarchy and add the RIFE2 jar to it + // find the wrapper classloader in the hierarchy and add the bld jar to it classloader_ = new WrapperClassLoader(); classloader_.add(distribution_file.toURI().toURL());