Skip to content

Commit

Permalink
Allow hibernate.javax.cache.uri to load the configuration from a jar (f…
Browse files Browse the repository at this point in the history
…ixes #1347)
  • Loading branch information
mletenay authored Dec 3, 2023
1 parent 41cf7fd commit 4fd8b21
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package com.github.benmanes.caffeine.jcache.configuration;


import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

import java.io.File;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.Collections;
import java.util.Objects;
Expand Down Expand Up @@ -166,6 +168,14 @@ private static Config resolveConfig(URI uri, ClassLoader classloader) {
return ConfigFactory.defaultOverrides(classloader)
.withFallback(ConfigFactory.parseFile(new File(uri), options))
.withFallback(ConfigFactory.defaultReferenceUnresolved(classloader));
} else if ((uri.getScheme() != null) && uri.getScheme().equalsIgnoreCase("jar")) {
try {
return ConfigFactory.defaultOverrides(classloader)
.withFallback(ConfigFactory.parseURL(uri.toURL(), options))
.withFallback(ConfigFactory.defaultReferenceUnresolved(classloader));
} catch (MalformedURLException e) {
throw new ConfigException.BadPath(uri.toString(), "Failed to load cache configuration", e);
}
} else if (isResource(uri)) {
return ConfigFactory.defaultOverrides(classloader)
.withFallback(ConfigFactory.parseResources(uri.getSchemeSpecificPart(), options))
Expand Down

0 comments on commit 4fd8b21

Please sign in to comment.