Skip to content

Commit

Permalink
Load correct OpenSSL libraries on Windows 64
Browse files Browse the repository at this point in the history
With OpenSSL 1.1.1 we are getting different names for the DLL
depending on 32/64-bit Windows. Need to account for this when
loading the DLL's so that they are found.

Also, stopped trying to load DLL's we no longer provide.

Issue: 131
  • Loading branch information
markphip committed May 4, 2020
1 parent ecb5dc9 commit fd5bd35
Showing 1 changed file with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,22 @@
public class JhlClientAdapterFactory extends SVNClientAdapterFactory {

private static final String[] WINDOWSLIBS = new String[] {
"msvcr100", "msvcp100", "zlib-1",
"libapr-1", "libapriconv-1", "libeay32", "ssleay32",
"libcrypto-1_1", "capi", "libssl-1_1", "libaprutil-1",
"dbghelp", "libsasl", "libserf-1",
// libraries as of 1.5
"msvcr100", "msvcp100",
"libapr-1", "libapriconv-1",
"libcrypto-1_1", "capi", "libssl-1_1",
"libaprutil-1",
"libserf-1",
"libsvn_subr-1", "libsvn_delta-1", "libsvn_diff-1", "libsvn_wc-1",
"libsvn_fs_util-1", "libsvn_fs_fs-1", "libsvn_fs_x-1", "libsvn_fs-1",
"libsvn_repos-1", "libsvn_ra-1", "libsvn_client-1"
};

private static final String[] WINDOWSLIBS64 = new String[] {
"msvcr100", "msvcp100",
"libapr-1", "libapriconv-1",
"libcrypto-1_1-x64", "capi", "libssl-1_1-x64",
"libaprutil-1",
"libserf-1",
"libsvn_subr-1", "libsvn_delta-1", "libsvn_diff-1", "libsvn_wc-1",
"libsvn_fs_util-1", "libsvn_fs_fs-1", "libsvn_fs_x-1", "libsvn_fs-1",
"libsvn_repos-1", "libsvn_ra-1", "libsvn_client-1"
Expand Down Expand Up @@ -106,16 +117,27 @@ public static boolean isAvailable() {
// because of a problem in one of these libraries the proper behavior
// will still occur -- meaning JavaHL adapter is disabled.
if(isOsWindows()) {

for (int i = 0; i < WINDOWSLIBS.length; i++) {
try {
System.loadLibrary(WINDOWSLIBS[i]);
} catch (Exception e) {
javaHLErrors.append(e.getMessage()).append("\n");
} catch (UnsatisfiedLinkError e) {
javaHLErrors.append(e.getMessage()).append("\n");
}
}
if (is32bit()) {
for (int i = 0; i < WINDOWSLIBS.length; i++) {
try {
System.loadLibrary(WINDOWSLIBS[i]);
} catch (Exception e) {
javaHLErrors.append(e.getMessage()).append("\n");
} catch (UnsatisfiedLinkError e) {
javaHLErrors.append(e.getMessage()).append("\n");
}
}
} else {
for (int i = 0; i < WINDOWSLIBS64.length; i++) {
try {
System.loadLibrary(WINDOWSLIBS64[i]);
} catch (Exception e) {
javaHLErrors.append(e.getMessage()).append("\n");
} catch (UnsatisfiedLinkError e) {
javaHLErrors.append(e.getMessage()).append("\n");
}
}
}

}
//workaround to solve Subclipse ISSUE #83
Expand Down Expand Up @@ -215,6 +237,20 @@ public static boolean isOsWindows()
return false;
}
}

/**
* Answer whether running on 32-bit JVM
* @return true when running on 32-bit JVM
*/
public static boolean is32bit()
{
try {
return System.getProperty("os.arch").equalsIgnoreCase("x86");
} catch (SecurityException ex) {
// we are not allowed to look at this property
return false;
}
}

/**
* @return an error string describing problems during loading platform native libraries (if any)
Expand Down

0 comments on commit fd5bd35

Please sign in to comment.