Skip to content

Commit 9a64bfd

Browse files
committed
upgrade tomcat/jackson-core for vulns
1 parent 483702c commit 9a64bfd

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

g11n-ws/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Copyright 2019-2025 VMware, Inc.
1+
//Copyright 2019-2026 VMware, Inc.
22
//SPDX-License-Identifier: EPL-2.0
33

44
buildscript {

g11n-ws/vip-common/src/main/java/com/vmware/vip/common/cache/SingletonCacheImpl.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
import org.ehcache.config.builders.CacheManagerBuilder;
1313
import org.ehcache.xml.XmlConfiguration;
1414

15+
import java.net.URL;
1516
import java.util.ArrayList;
1617
import java.util.List;
1718

1819
public class SingletonCacheImpl implements SingletonCache{
1920

21+
private static final String EHCACHE_CONFIG_RESOURCE = "ehcache3.xml";
22+
2023
private boolean cacheEnable;
2124

2225
private CacheManager manager;
@@ -26,12 +29,30 @@ public class SingletonCacheImpl implements SingletonCache{
2629
public SingletonCacheImpl(boolean enable){
2730
this.cacheEnable = enable;
2831
if (this.cacheEnable){
29-
Configuration xmlConf = new XmlConfiguration(SingletonCacheImpl.class.getResource("/ehcache3.xml"));
30-
this.manager= CacheManagerBuilder.newCacheManager(xmlConf);
32+
URL configUrl = getEhcacheConfigUrl();
33+
if (configUrl == null) {
34+
throw new IllegalStateException(
35+
"Ehcache config resource not found: " + EHCACHE_CONFIG_RESOURCE
36+
+ ". Ensure it is on the classpath (e.g. in src/main/resources).");
37+
}
38+
Configuration xmlConf = new XmlConfiguration(configUrl);
39+
this.manager = CacheManagerBuilder.newCacheManager(xmlConf);
3140
this.manager.init();
3241
}
3342
}
3443

44+
/**
45+
* Resolve ehcache3.xml from the classpath. Tries thread context class loader first
46+
* (for Spring Boot fat jars), then the class loader of this class.
47+
*/
48+
private static URL getEhcacheConfigUrl() {
49+
URL url = Thread.currentThread().getContextClassLoader().getResource(EHCACHE_CONFIG_RESOURCE);
50+
if (url == null) {
51+
url = SingletonCacheImpl.class.getResource("/" + EHCACHE_CONFIG_RESOURCE);
52+
}
53+
return url;
54+
}
55+
3556
private <K, V> Cache<K, V> getCache(CacheName cachename, Class<K> keyType, Class<V> valueType) throws VIPCacheException{
3657
return this.manager.getCache(cachename.name(), keyType,valueType);
3758
}

0 commit comments

Comments
 (0)