This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 4.0.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a8a09c2aff2f3b68df2da80b4e6a181c6bed905e Author: Andriy Redko <[email protected]> AuthorDate: Mon Jan 20 21:02:50 2025 -0500 CXF-8765: Option to remove Ehcache (enhance JCache API and providers presence detection in JCacheUtils) (cherry picked from commit b82c4bb038477427f4516bb6ffc9271c6ca8e517) --- .../java/org/apache/cxf/ws/security/utils/JCacheUtils.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/utils/JCacheUtils.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/utils/JCacheUtils.java index 223207695e..dcbe901b51 100644 --- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/utils/JCacheUtils.java +++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/utils/JCacheUtils.java @@ -18,6 +18,8 @@ */ package org.apache.cxf.ws.security.utils; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.util.function.Function; import java.util.logging.Logger; @@ -35,10 +37,14 @@ public final class JCacheUtils { boolean jcacheInstalled = false; try { final Class<?> caching = Class.forName("javax.cache.Caching"); + final Class<?> cachingProvider = Class.forName("javax.cache.spi.CachingProvider"); if (caching != null) { - jcacheInstalled = true; + jcacheInstalled = MethodHandles + .publicLookup() + .findStatic(caching, "getCachingProvider", MethodType.methodType(cachingProvider)) + .invoke() != null; } - } catch (Exception e) { + } catch (Throwable e) { LOG.fine("No JCache SPIs detected on classpath: " + e.getMessage()); } JCACHE_INSTALLED = jcacheInstalled;
