Skip to content

Commit

Permalink
Set the validator class loader during its execution
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoncek committed Nov 6, 2023
1 parent f10f2d4 commit b635485
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ List<NamedResult> execute(Collection<Validator> validators) throws Exception {
}
});
Iterators.addAll(rpms, new ArgFileIterator(parameters.argPaths));
var oldClassLoader = Thread.currentThread().getContextClassLoader();
return validators.parallelStream().map(validator -> {
try {
Thread.currentThread().setContextClassLoader(validator.getClass().getClassLoader());
var startTime = LocalDateTime.now();
var result = validator.validate(rpms, parameters.validatorArgs
.getOrDefault(validator.getTestName(), Optional.empty()).orElse(null));
Expand All @@ -468,6 +470,8 @@ List<NamedResult> execute(Collection<Validator> validators) throws Exception {
var logEntry = Common.logException(ex);
result.error(logEntry.pattern(), logEntry.objects());
return new NamedResult(result, validator.getTestName());
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}).toList();
}
Expand Down

0 comments on commit b635485

Please sign in to comment.