@@ -109,7 +109,7 @@ public static Optional<Path> getExistHome(final String config) {
109
109
final Path userHomeRelativeConfig = userHome .resolve (config );
110
110
if (Files .isDirectory (userHome ) && Files .isRegularFile (userHomeRelativeConfig )) {
111
111
final Path existHome = userHomeRelativeConfig .getParent ().normalize ();
112
- LOG .debug ("Got eXist home: {} from system property 'user.home': {}" , existHome .toAbsolutePath (). toString () , userHome .toAbsolutePath (). toString ());
112
+ LOG .debug ("Got eXist home: {} from system property 'user.home': {}" , existHome .toAbsolutePath (), userHome .toAbsolutePath ());
113
113
return Optional .of (existHome );
114
114
}
115
115
@@ -119,7 +119,7 @@ public static Optional<Path> getExistHome(final String config) {
119
119
final Path userDirRelativeConfig = userDir .resolve (config );
120
120
if (Files .isDirectory (userDir ) && Files .isRegularFile (userDirRelativeConfig )) {
121
121
final Path existHome = userDirRelativeConfig .getParent ().normalize ();
122
- LOG .debug ("Got eXist home: {} from system property 'user.dir': {}" , existHome .toAbsolutePath (). toString () , userDir .toAbsolutePath (). toString ());
122
+ LOG .debug ("Got eXist home: {} from system property 'user.dir': {}" , existHome .toAbsolutePath (), userDir .toAbsolutePath ());
123
123
return Optional .of (existHome );
124
124
}
125
125
@@ -132,7 +132,7 @@ public static Optional<Path> getExistHome(final String config) {
132
132
existHome = Paths .get (new URI (configUrl .getPath ())).getParent ().getParent ().normalize ();
133
133
LOG .warn ("{} file was found on the classpath, but inside a Jar file! Derived EXIST_HOME from Jar's parent folder: {}" , config , existHome );
134
134
} else {
135
- existHome = Paths .get (configUrl .toURI ()).getParent ();
135
+ existHome = Paths .get (configUrl .toURI ()).getParent (). normalize () ;
136
136
if (FileUtils .fileName (existHome ).equals ("etc" )) {
137
137
existHome = existHome .getParent ().normalize ();
138
138
}
@@ -179,15 +179,14 @@ public static Path lookup(final String path) {
179
179
* @return the file handle
180
180
*/
181
181
public static Path lookup (final String path , final Optional <Path > parent ) {
182
- // resolvePath is used for things like ~user/folder
183
- final Path p = decodeUserHome (path );
184
- if (p .isAbsolute ()) {
185
- return p ;
182
+ // attempt to first resolve the path that is used for things like ~user/folder
183
+ Path p = decodeUserHome (path );
184
+ if (!p .isAbsolute ()) {
185
+ p = parent
186
+ .orElse (getExistHome ().orElse (Paths .get (System .getProperty ("user.dir" ))))
187
+ .resolve (path );
186
188
}
187
-
188
- return parent
189
- .orElse (getExistHome ().orElse (Paths .get (System .getProperty ("user.dir" ))))
190
- .resolve (path );
189
+ return p .normalize ().toAbsolutePath ();
191
190
}
192
191
193
192
0 commit comments