Skip to content

Commit

Permalink
The issue was with jar:file:/ NOT jar:/, corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Mar 3, 2025
1 parent 72f15af commit 611bfd9
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,20 @@ private static void createConnectionRules(LinkedList<String> 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)
Expand All @@ -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"));
Expand Down

0 comments on commit 611bfd9

Please sign in to comment.