This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a7cafb8f9cc176245801a3f6664ab8d1c5b6e4a8 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) --- .../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;
