fix(StorageServiceImpl, StaticResourceServiceImpl): handle nested jar paths when resolving parent directory

This commit is contained in:
extio-de
2026-06-27 13:20:50 +02:00
parent f948be3fe4
commit 0a9f2e8884
3 changed files with 15 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.extio</groupId> <groupId>de.extio</groupId>
<artifactId>game-engine</artifactId> <artifactId>game-engine</artifactId>
<version>1.0.22</version> <version>1.0.23</version>
<properties> <properties>
<java.version>25</java.version> <java.version>25</java.version>

View File

@@ -28,7 +28,13 @@ public class StaticResourceServiceImpl implements StaticResourceService {
if (location == null) { if (location == null) {
try { try {
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation(); final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
final Path parent = Paths.get(url.toURI()).getParent(); Path parent;
if (url.toString().startsWith("jar:nested:")) {
parent = Paths.get(url.toString().substring("jar:nested:".length(), url.toString().indexOf("/!"))).getParent();
}
else {
parent = Paths.get(url.toURI()).getParent();
}
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize(); final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
final String currentSubDir = jarPath.getFileName().toString(); final String currentSubDir = jarPath.getFileName().toString();

View File

@@ -38,7 +38,13 @@ public class StorageServiceImpl implements StorageService {
if (location == null) { if (location == null) {
try { try {
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation(); final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
final Path parent = Paths.get(url.toURI()).getParent(); Path parent;
if (url.toString().startsWith("jar:nested:")) {
parent = Paths.get(url.toString().substring("jar:nested:".length(), url.toString().indexOf("/!"))).getParent();
}
else {
parent = Paths.get(url.toURI()).getParent();
}
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize(); final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
final String currentSubDir = jarPath.getFileName().toString(); final String currentSubDir = jarPath.getFileName().toString();