You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2023/11/30 11:56:07 UTC
(commons-crypto) 01/02: Revert replacement of "/" by File.separator
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git
commit 1ae8893a4029925160548ccdb6756d3821d2b5cb
Author: Sebb <se...@apache.org>
AuthorDate: Thu Nov 30 11:46:47 2023 +0000
Revert replacement of "/" by File.separator
Resources use "/" on all systems
---
src/main/java/org/apache/commons/crypto/NativeCodeLoader.java | 9 ++++++---
src/main/java/org/apache/commons/crypto/OsInfo.java | 6 ++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
index 9bb9c0d4..32ea9253 100644
--- a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
+++ b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
@@ -37,6 +37,9 @@ import org.apache.commons.io.IOUtils;
*/
final class NativeCodeLoader {
+ /** The separator to be used in constructing a resource path */
+ private static final String RESOURCE_PATH_SEPARATOR = "/";
+
private static final String SIMPLE_NAME = NativeCodeLoader.class.getSimpleName();
private static final String NATIVE_LIBNAME = "commons-crypto";
@@ -82,7 +85,7 @@ final class NativeCodeLoader {
*/
private static File extractLibraryFile(final String libFolderForCurrentOS, final String libraryFileName,
final String targetFolder) {
- final String nativeLibraryFilePath = libFolderForCurrentOS + File.separator + libraryFileName;
+ final String nativeLibraryFilePath = libFolderForCurrentOS + RESOURCE_PATH_SEPARATOR + libraryFileName;
// Attach UUID to the native library file to ensure multiple class loaders
// can read the libcommons-crypto multiple times.
@@ -171,12 +174,12 @@ final class NativeCodeLoader {
// Load an OS-dependent native library inside a jar file
nativeLibraryPath = "/org/apache/commons/crypto/native/" + OsInfo.getNativeLibFolderPathForCurrentOS();
debug("%s nativeLibraryPath = %s", SIMPLE_NAME, nativeLibraryPath);
- final String resource = nativeLibraryPath + File.separator + nativeLibraryName;
+ final String resource = nativeLibraryPath + RESOURCE_PATH_SEPARATOR + nativeLibraryName;
boolean hasNativeLib = hasResource(resource);
debug("%s resource %s exists = %s", SIMPLE_NAME, resource, hasNativeLib);
if (!hasNativeLib) {
final String altName = NATIVE_LIBNAME_ALT;
- if (OsInfo.getOSName().equals("Mac") && hasResource(nativeLibraryPath + File.separator + altName)) {
+ if (OsInfo.getOSName().equals("Mac") && hasResource(nativeLibraryPath + RESOURCE_PATH_SEPARATOR + altName)) {
// Fix for openjdk7 for Mac
nativeLibraryName = altName;
hasNativeLib = true;
diff --git a/src/main/java/org/apache/commons/crypto/OsInfo.java b/src/main/java/org/apache/commons/crypto/OsInfo.java
index a3dc8093..3fcd3190 100644
--- a/src/main/java/org/apache/commons/crypto/OsInfo.java
+++ b/src/main/java/org/apache/commons/crypto/OsInfo.java
@@ -17,7 +17,6 @@
*/
package org.apache.commons.crypto;
-import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
@@ -28,6 +27,9 @@ import java.util.Locale;
*/
final class OsInfo {
+ /** The separator to be used in constructing a resource path */
+ private static final String RESOURCE_PATH_SEPARATOR = "/";
+
private final static HashMap<String, String> archMapping = new HashMap<>();
/**
@@ -140,7 +142,7 @@ final class OsInfo {
* @return the current OS's native lib folder.
*/
static String getNativeLibFolderPathForCurrentOS() {
- return getOSName() + File.separator + getArchName();
+ return getOSName() + RESOURCE_PATH_SEPARATOR + getArchName();
}
/**