From 611bfd9ff91a08ad7733487ff82d187498ededc5 Mon Sep 17 00:00:00 2001 From: Jeff Wasty Date: Mon, 3 Mar 2025 09:30:08 -0800 Subject: [PATCH] The issue was with jar:file:/ NOT jar:/, corrected. --- .../sqlserver/jdbc/ConfigurableRetryLogic.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ConfigurableRetryLogic.java b/src/main/java/com/microsoft/sqlserver/jdbc/ConfigurableRetryLogic.java index d9abb87d4..47a8f6097 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ConfigurableRetryLogic.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ConfigurableRetryLogic.java @@ -287,18 +287,20 @@ private static void createConnectionRules(LinkedList listOfRules) throws private static String getCurrentClassPath() throws SQLServerException { String location = ""; String className = ""; - String schemeSpecificPart = ""; + String uriToString = ""; try { className = new Object() {}.getClass().getEnclosingClass().getName(); location = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath(); - schemeSpecificPart = ConfigurableRetryLogic.class.getProtectionDomain().getCodeSource().getLocation() - .toURI().getSchemeSpecificPart(); - if (schemeSpecificPart.startsWith(FORWARD_SLASH)) { - schemeSpecificPart = schemeSpecificPart.substring(1); // Remove leading / + URI uri = ConfigurableRetryLogic.class.getProtectionDomain().getCodeSource().getLocation() + .toURI(); + uriToString = uri.toString(); + int initialIndexOfForwardSlash = uriToString.indexOf(FORWARD_SLASH); + if (initialIndexOfForwardSlash > 0) { + uriToString = uriToString.substring(initialIndexOfForwardSlash + 1); } - if (Files.isDirectory(Paths.get(schemeSpecificPart))) { + if (Files.isDirectory(Paths.get(uriToString))) { // We check if the Path we get from the CodeSource location is a directory. If so, we are running // from class files and should remove a suffix (i.e. the props file is in a different location from the // location returned) @@ -308,7 +310,7 @@ private static String getCurrentClassPath() throws SQLServerException { return new URI(location).getPath() + DEFAULT_PROPS_FILE; // TODO: Allow custom paths } catch (InvalidPathException e) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_PathInvalid")); - Object[] msgArgs = {schemeSpecificPart}; + Object[] msgArgs = {uriToString}; throw new SQLServerException(form.format(msgArgs), null, 0, e); } catch (URISyntaxException e) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_URLInvalid"));