This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch update_7.0.X
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git


The following commit(s) were added to refs/heads/update_7.0.X by this push:
     new 354164e4 update 7.0.X
354164e4 is described below

commit 354164e415f3a37e958b8e6984e86a7277423c87
Author: Lee Rhodes <[email protected]>
AuthorDate: Sat May 9 14:41:51 2026 -0700

    update 7.0.X
---
 .../apache/datasketches/memory/internal/Util.java  | 45 ++++++++++++++--------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
index a05deb57..1302a2d2 100644
--- 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
+++ 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
@@ -292,22 +292,6 @@ public final class Util {
     }
   }
 
-  /**
-   * Returns a byte array of the contents of the file defined by the given 
resourceName.
-   * This is only used in test.
-   * If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
-   * 
-   * @param resourceName the short name or the full path name.
-   * @return a byte array of the contents of the file defined by the given 
resourceName.
-   */
-  public static byte[] getResourceBytes(final String resourceName) {
-    try {
-      return Files.readAllBytes(getResourceFile(resourceName).toPath());
-    } catch (final IOException e) {
-      throw new IllegalArgumentException("Cannot read resource: " + 
resourceName + LS + e);
-    }
-  }
-
   /**
    * Checks if the given resourceName exists and sets it to Read-Only.  This 
is only used in test.
    * If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
@@ -327,7 +311,34 @@ public final class Util {
   }
   
   /**
-   *   Windows and JAR friendly get Resource File. This is only used in test.
+   * Returns a byte array of the contents of the file defined by the given 
resourceName.
+   * This is only used in test.
+   * If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
+   * 
+   * @param resourceName the short name or the full path name.
+   * @return a byte array of the contents of the file defined by the given 
resourceName.
+   */
+  public static byte[] getResourceBytes(final String resourceName) {
+    Objects.requireNonNull(resourceName, "Given resourceName must not be 
null");
+    
+    String normalizedName = resourceName.replace('\\', '/');
+    if (normalizedName.startsWith("/")) {
+      normalizedName = normalizedName.substring(1);
+    }
+
+    final ClassLoader loader = Util.class.getClassLoader();
+    try (InputStream in = loader.getResourceAsStream(normalizedName)) {
+      if (in == null) {
+        throw new IllegalArgumentException("Resource not found: " + 
normalizedName);
+      }
+      return in.readAllBytes();
+    } catch (final IOException e) {
+      throw new IllegalArgumentException("Cannot read resource: " + 
normalizedName + LS + e);
+    }
+  }
+
+  /**
+   *   Windows, POSIX, and JAR friendly get Resource File. This is only used 
in test.
    *   If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
    *   @param resourceName the simple file name or full path name. 
    *   Any back-slashes will be converted to forward slashes and a leading 
forward slash will be removed.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to