Skip to content

Commit

Permalink
[bugfix] Don't stop startup if an EXPath Package cannot be loaded. Cl…
Browse files Browse the repository at this point in the history
…oses #4693
  • Loading branch information
adamretter committed Feb 4, 2023
1 parent 40ef8fe commit 35e7664
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions exist-core/src/main/java/org/exist/repo/ExistRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
*/
public class ExistRepository extends Observable implements BrokerPoolService {

private final static Logger EXIST_LOG = LogManager.getLogger(BrokerPool.class);
private final static Logger LOG = LogManager.getLogger(ExistRepository.class);
private static final String EXPATH_REPO_DIR_NAME = "expathrepo";
private static final String LEGACY_DEFAULT_EXPATH_REPO_DIR = "webapp/WEB-INF/" + EXPATH_REPO_DIR_NAME;
Expand Down Expand Up @@ -98,13 +99,27 @@ public void prepare(final BrokerPool brokerPool) throws BrokerPoolServiceExcepti

LOG.info("Using directory {} for expath package repository", expathDir.toAbsolutePath().toString());

final FileSystemStorage storage;
try {
storage = new FileSystemStorage(expathDir);
} catch(final PackageException e) {
throw new BrokerPoolServiceException("Unable to open storage for EXPath Package Repository: " + expathDir.toAbsolutePath(), e);
}
storage.setErrorIfNoContentDir(false);

this.myParent = new Repository(storage);
final List<PackageException> exceptions = this.myParent.init();
if (exceptions.size() > 0) {
EXIST_LOG.warn("It may not have been possible to load all EXPath Packages, see repo.log for details...");
for (final PackageException exception : exceptions) {
LOG.error(exception.getMessage(), exception);
}
}

try {
final FileSystemStorage storage = new FileSystemStorage(expathDir);
storage.setErrorIfNoContentDir(false);
this.myParent = new Repository(storage);
myParent.registerExtension(new ExistPkgExtension());
} catch(final PackageException e) {
throw new BrokerPoolServiceException("Unable to prepare EXPath Package Repository: " + expathDir.toAbsolutePath().toString(), e);
throw new BrokerPoolServiceException("Unable to register EXPath Package Repository extension 'ExistPkgExtension': " + e.getMessage(), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion exist-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
<dependency>
<groupId>org.expath.packaging</groupId>
<artifactId>pkg-java</artifactId>
<version>1.6.1</version>
<version>2.0.0</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 35e7664

Please sign in to comment.