Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ specific language governing permissions and limitations
under the License.
-->

**2026-11-17 Arturo Bernal (abernal AT apache DOT org)**

* _3.0.1-git-10_

* Fix for [JSPWIKI-1371](https://issues.apache.org/jira/browse/JSPWIKI-1371): each caching manager uses its own Ehcache cache manager, so engines running in the same JVM no longer share the page caches nor shut them down for each other

**2026-11-14 Multiple authors**

* _3.0.1-git-09
Expand Down
2 changes: 1 addition & 1 deletion jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public final class Release {
* <p>
* If the build identifier is empty, it is not added.
*/
public static final String BUILD = "9";
public static final String BUILD = "10";

/**
* This is the generic version string you should use when printing out the version. It is of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import net.sf.ehcache.config.Configuration;
import net.sf.ehcache.config.ConfigurationFactory;
import net.sf.ehcache.event.CacheEventListenerAdapter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -37,6 +39,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -57,8 +60,8 @@ public class EhcacheCachingManager implements CachingManager, Initializable {
/** {@inheritDoc} */
@Override
public void shutdown() {
if(!cacheMap.isEmpty()) {
CacheManager.getInstance().shutdown();
if( !cacheMap.isEmpty() ) {
cacheManager.shutdown();
cacheMap.clear();
cacheStats.clear();
}
Expand All @@ -79,7 +82,10 @@ public void initialize( final Engine engine, final Properties props ) throws Wik
if (location == null ) {
LOG.error( "The ehcache configuration file from classpath on {} could not be loaded. Check setting {}", val , PROP_CACHE_CONF_FILE);
}
cacheManager = CacheManager.create( location );
// The shared CacheManager would give every engine of the same class loader the caches of the others.
final Configuration configuration = ConfigurationFactory.parseConfiguration( location );
configuration.setName( "jspwiki-" + UUID.randomUUID() );
cacheManager = CacheManager.newInstance( configuration );
registerCache( CACHE_ATTACHMENTS );
registerCache( CACHE_ATTACHMENTS_COLLECTION );
registerCache( CACHE_ATTACHMENTS_DYNAMIC );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ void testInitAndShutdown() throws Exception {
Assertions.assertEquals( 0, ecm.cacheMap.size() );
}

@Test
void testManagersDoNotShareCaches() throws Exception {
final EhcacheCachingManager first = new EhcacheCachingManager();
final EhcacheCachingManager second = new EhcacheCachingManager();
first.initialize( null, new Properties() );
second.initialize( null, new Properties() );
try {
first.put( CachingManager.CACHE_PAGES, "OnlyInFirst", "content" );
Assertions.assertNull( second.get( CachingManager.CACHE_PAGES, "OnlyInFirst", () -> null ) );
Assertions.assertTrue( second.keys( CachingManager.CACHE_PAGES ).isEmpty() );

first.shutdown();
second.put( CachingManager.CACHE_PAGES, "InSecond", "content" );
Assertions.assertEquals( "content", second.get( CachingManager.CACHE_PAGES, "InSecond", () -> null ) );
} finally {
first.shutdown();
second.shutdown();
}
}

@Test
void testEnabled() {
Assertions.assertTrue( ecm.enabled( CachingManager.CACHE_PAGES ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Licensed to the Apache Software Foundation (ASF) under one

package org.apache.wiki.providers;

import net.sf.ehcache.CacheManager;
import org.apache.wiki.TestEngine;
import org.apache.wiki.api.core.Page;
import org.apache.wiki.cache.CachingManager;
Expand All @@ -28,7 +27,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.File;
Expand All @@ -41,11 +39,6 @@ class CachingProviderTest {

TestEngine engine;

@BeforeAll
static void ensureEhCacheFreshStart() {
CacheManager.getInstance().shutdown();
}

@AfterEach
void tearDown() {
engine.stop();
Expand Down
Loading