Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 899A1187BB for ; Thu, 10 Dec 2015 15:07:47 +0000 (UTC) Received: (qmail 12900 invoked by uid 500); 10 Dec 2015 15:07:47 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 12812 invoked by uid 500); 10 Dec 2015 15:07:47 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 12803 invoked by uid 99); 10 Dec 2015 15:07:47 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Dec 2015 15:07:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 96534180B18 for ; Thu, 10 Dec 2015 15:07:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.247 X-Spam-Level: * X-Spam-Status: No, score=1.247 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id MNoCutY-QTZH for ; Thu, 10 Dec 2015 15:07:33 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id B36C920599 for ; Thu, 10 Dec 2015 15:07:32 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E727CE0044 for ; Thu, 10 Dec 2015 15:07:31 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id DD5D93A04EC for ; Thu, 10 Dec 2015 15:07:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1719092 [1/2] - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/access/ main/java/org/apache/commons/jcs/auxiliary/disk/ main/java/org/apache/commons/jcs/auxiliary/disk/block/ main/java/org/apache/common... Date: Thu, 10 Dec 2015 15:07:31 -0000 To: commits@commons.apache.org From: tv@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151210150731.DD5D93A04EC@svn01-us-west.apache.org> Author: tv Date: Thu Dec 10 15:07:30 2015 New Revision: 1719092 URL: http://svn.apache.org/viewvc?rev=1719092&view=rev Log: Address issues reported by Findbugs Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/AbstractCacheAccess.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElement.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheAttributes.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheInfo.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CompositeCacheAttributes.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/config/OptionConverter.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryReceiver.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/PoolConfiguration.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManager.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSThrashTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheRemovalUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheShrinkUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapUnitTest.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/AbstractCacheAccess.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/AbstractCacheAccess.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/AbstractCacheAccess.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/AbstractCacheAccess.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,8 @@ package org.apache.commons.jcs.access; * under the License. */ +import java.io.IOException; + import org.apache.commons.jcs.access.behavior.ICacheAccessManagement; import org.apache.commons.jcs.access.exception.CacheException; import org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes; @@ -26,8 +28,6 @@ import org.apache.commons.jcs.engine.beh import org.apache.commons.jcs.engine.control.CompositeCache; import org.apache.commons.jcs.engine.stats.behavior.ICacheStats; -import java.io.IOException; - /** * This class provides the common methods for all types of access to the cache. *

@@ -54,7 +54,7 @@ public abstract class AbstractCacheAcces *

* @param cacheControl The cache which the created instance accesses */ - public AbstractCacheAccess( CompositeCache cacheControl ) + protected AbstractCacheAccess( CompositeCache cacheControl ) { this.cacheControl = cacheControl; } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,14 @@ package org.apache.commons.jcs.auxiliary * under the License. */ +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.locks.ReentrantReadWriteLock; + import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging; import org.apache.commons.jcs.auxiliary.AuxiliaryCache; import org.apache.commons.jcs.auxiliary.disk.behavior.IDiskCacheAttributes; @@ -36,14 +44,6 @@ import org.apache.commons.jcs.engine.sta import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.locks.ReentrantReadWriteLock; - /** * Abstract class providing a base implementation of a disk cache, which can be easily extended to * implement a disk cache for a specific persistence mechanism. @@ -58,7 +58,6 @@ import java.util.concurrent.locks.Reentr */ public abstract class AbstractDiskCache extends AbstractAuxiliaryCacheEventLogging - implements AuxiliaryCache { /** The logger */ private static final Log log = LogFactory.getLog( AbstractDiskCache.class ); @@ -66,9 +65,6 @@ public abstract class AbstractDiskCache< /** Generic disk cache attributes */ private IDiskCacheAttributes diskCacheAttributes = null; - // TODO most of these fields should be made private with getters/setters as necessary - // Though hopefully many of them can be set at construction and made final - /** * Map where elements are stored between being added to this cache and actually spooled to disk. * This allows puts to the disk cache to return quickly, and the more expensive operation of @@ -77,31 +73,31 @@ public abstract class AbstractDiskCache< * If the elements are pulled into the memory cache while the are still in purgatory, writing to * disk can be canceled. */ - protected Map> purgatory = new HashMap>(); + private Map> purgatory; /** * The CacheEventQueue where changes will be queued for asynchronous updating of the persistent * storage. */ - protected ICacheEventQueue cacheEventQueue; + private ICacheEventQueue cacheEventQueue; /** * Indicates whether the cache is 'alive': initialized, but not yet disposed. Child classes must * set this to true. */ - protected boolean alive = false; + private boolean alive = false; /** Every cache will have a name, subclasses must set this when they are initialized. */ - protected String cacheName; + private String cacheName; /** DEBUG: Keeps a count of the number of purgatory hits for debug messages */ - protected int purgHits = 0; + private int purgHits = 0; /** * We lock here, so that we cannot get an update after a remove all. an individual removal locks * the item. */ - protected final ReentrantReadWriteLock removeAllLock = new ReentrantReadWriteLock(); + private final ReentrantReadWriteLock removeAllLock = new ReentrantReadWriteLock(); // ----------------------------------------------------------- constructors @@ -111,10 +107,9 @@ public abstract class AbstractDiskCache< *

* @param attr */ - public AbstractDiskCache( IDiskCacheAttributes attr ) + protected AbstractDiskCache( IDiskCacheAttributes attr ) { this.diskCacheAttributes = attr; - this.cacheName = attr.getCacheName(); // create queue @@ -128,6 +123,22 @@ public abstract class AbstractDiskCache< } /** + * @return true if the cache is alive + */ + public boolean isAlive() + { + return alive; + } + + /** + * @param alive set the alive status + */ + public void setAlive(boolean alive) + { + this.alive = alive; + } + + /** * Purgatory size of -1 means to use a HashMap with no size limit. Anything greater will use an * LRU map of some sort. *

@@ -459,7 +470,7 @@ public abstract class AbstractDiskCache< public void run() { boolean keepGoing = true; - long total = 0; + // long total = 0; long interval = 100; while ( keepGoing ) { @@ -467,7 +478,7 @@ public abstract class AbstractDiskCache< try { Thread.sleep( interval ); - total += interval; + // total += interval; // log.info( "total = " + total ); } catch ( InterruptedException e ) @@ -483,7 +494,7 @@ public abstract class AbstractDiskCache< // wait up to 60 seconds for dispose and then quit if not done. try { - t.join( this.diskCacheAttributes.getShutdownSpoolTimeLimit() * 1000 ); + t.join( this.diskCacheAttributes.getShutdownSpoolTimeLimit() * 1000L ); } catch ( InterruptedException ex ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElement.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElement.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElement.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElement.java Thu Dec 10 15:07:30 2015 @@ -31,7 +31,6 @@ import org.apache.commons.jcs.engine.beh */ public class PurgatoryElement extends CacheElement - implements ICacheElement { /** Don't change */ private static final long serialVersionUID = -8152034342684135628L; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java Thu Dec 10 15:07:30 2015 @@ -144,7 +144,7 @@ public class BlockDiskCache } // Initialization finished successfully, so set alive to true. - alive = true; + setAlive(true); if ( log.isInfoEnabled() ) { log.info( logCacheName + "Block Disk Cache is alive." ); @@ -314,7 +314,7 @@ public class BlockDiskCache @Override protected ICacheElement processGet( K key ) { - if ( !alive ) + if ( !isAlive() ) { if ( log.isDebugEnabled() ) { @@ -371,7 +371,7 @@ public class BlockDiskCache @Override protected void processUpdate( ICacheElement element ) { - if ( !alive ) + if ( !isAlive() ) { if ( log.isDebugEnabled() ) { @@ -430,7 +430,7 @@ public class BlockDiskCache @Override protected boolean processRemove( K key ) { - if ( !alive ) + if ( !isAlive() ) { if ( log.isDebugEnabled() ) { @@ -458,7 +458,7 @@ public class BlockDiskCache if ( k instanceof String && k.toString().startsWith( key.toString() ) ) { - int[] ded = this.keyStore.get( key ); + int[] ded = entry.getValue(); this.dataFile.freeBlocks( ded ); iter.remove(); removed = true; @@ -478,7 +478,7 @@ public class BlockDiskCache if ( k instanceof GroupAttrName && ((GroupAttrName)k).groupId.equals(((GroupAttrName)key).groupId)) { - int[] ded = this.keyStore.get( key ); + int[] ded = entry.getValue(); this.dataFile.freeBlocks( ded ); iter.remove(); removed = true; @@ -575,7 +575,7 @@ public class BlockDiskCache protected void disposeInternal() throws InterruptedException { - if ( !alive ) + if ( !isAlive() ) { log.error( logCacheName + "Not alive and dispose was called, filename: " + fileName ); return; @@ -584,8 +584,7 @@ public class BlockDiskCache try { // Prevents any interaction with the cache while we're shutting down. - alive = false; - + setAlive(false); this.keyStore.saveKeys(); try @@ -620,7 +619,6 @@ public class BlockDiskCache /** * Returns the attributes. *

- * (non-Javadoc) * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getAuxiliaryCacheAttributes() */ @Override @@ -697,7 +695,7 @@ public class BlockDiskCache ArrayList> elems = new ArrayList>(); - elems.add(new StatElement( "Is Alive", Boolean.valueOf(alive) ) ); + elems.add(new StatElement( "Is Alive", Boolean.valueOf(isAlive()) ) ); elems.add(new StatElement( "Key Map Size", Integer.valueOf(this.keyStore.size()) ) ); if (this.dataFile != null) Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java Thu Dec 10 15:07:30 2015 @@ -20,7 +20,6 @@ package org.apache.commons.jcs.auxiliary */ import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; @@ -185,7 +184,7 @@ public class IndexedDiskCache exte initializeRecycleBin(); // Initialization finished successfully, so set alive to true. - alive = true; + setAlive(true); if (log.isInfoEnabled()) { log.info(logCacheName + "Indexed Disk Cache is alive."); @@ -228,12 +227,10 @@ public class IndexedDiskCache exte *

* * @param cattr - * @throws FileNotFoundException * @throws IOException * @throws InterruptedException */ - private void initializeKeysAndData(IndexedDiskCacheAttributes cattr) throws FileNotFoundException, IOException, - InterruptedException + private void initializeKeysAndData(IndexedDiskCacheAttributes cattr) throws IOException, InterruptedException { this.dataFile = new IndexedDisk(new File(rafDir, fileName + ".data"), getElementSerializer()); this.keyFile = new IndexedDisk(new File(rafDir, fileName + ".key"), getElementSerializer()); @@ -288,7 +285,7 @@ public class IndexedDiskCache exte { loadKeys(); - if (keyHash.size() == 0) + if (keyHash.isEmpty()) { dataFile.reset(); } @@ -503,7 +500,7 @@ public class IndexedDiskCache exte @Override protected void processUpdate(ICacheElement ce) { - if (!alive) + if (!isAlive()) { log.error(logCacheName + "No longer alive; aborting put of key = " + ce.getKey()); return; @@ -619,7 +616,7 @@ public class IndexedDiskCache exte @Override protected ICacheElement processGet(K key) { - if (!alive) + if (!isAlive()) { log.error(logCacheName + "No longer alive so returning null for key = " + key); return null; @@ -780,7 +777,7 @@ public class IndexedDiskCache exte @Override protected boolean processRemove(K key) { - if (!alive) + if (!isAlive()) { log.error(logCacheName + "No longer alive so returning false for key = " + key); return false; @@ -854,7 +851,7 @@ public class IndexedDiskCache exte for (K k : keyHash.keySet()) { - if (k instanceof String && k.toString().startsWith(key.toString())) + if (k instanceof String && k.toString().startsWith(key)) { itemsToRemove.add(k); } @@ -942,7 +939,7 @@ public class IndexedDiskCache exte @Override public void processRemoveAll() { - ICacheEvent cacheEvent = createICacheEvent(cacheName, "all", ICacheEventLogger.REMOVEALL_EVENT); + ICacheEvent cacheEvent = createICacheEvent(getCacheName(), "all", ICacheEventLogger.REMOVEALL_EVENT); try { reset(); @@ -1035,7 +1032,7 @@ public class IndexedDiskCache exte keyHash = null; if (maxKeySize >= 0) { - if (this.diskLimitType.equals(DiskLimitType.COUNT)) + if (this.diskLimitType == DiskLimitType.COUNT) { keyHash = new LRUMapCountLimited(maxKeySize); } @@ -1070,7 +1067,7 @@ public class IndexedDiskCache exte @Override public void processDispose() { - ICacheEvent cacheEvent = createICacheEvent(cacheName, "none", ICacheEventLogger.DISPOSE_EVENT); + ICacheEvent cacheEvent = createICacheEvent(getCacheName(), "none", ICacheEventLogger.DISPOSE_EVENT); try { Runnable disR = new Runnable() @@ -1104,14 +1101,14 @@ public class IndexedDiskCache exte */ protected void disposeInternal() { - if (!alive) + if (!isAlive()) { log.error(logCacheName + "Not alive and dispose was called, filename: " + fileName); return; } // Prevents any interaction with the cache while we're shutting down. - alive = false; + setAlive(false); Thread optimizationThread = currentOptimizationThread; if (isRealTimeOptimizationEnabled && optimizationThread != null) @@ -1595,7 +1592,7 @@ public class IndexedDiskCache exte ArrayList> elems = new ArrayList>(); - elems.add(new StatElement("Is Alive", Boolean.valueOf(alive))); + elems.add(new StatElement("Is Alive", Boolean.valueOf(isAlive()))); elems.add(new StatElement("Key Map Size", Integer.valueOf(this.keyHash != null ? this.keyHash.size() : -1))); try { @@ -1663,11 +1660,8 @@ public class IndexedDiskCache exte * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override - public int compare(IndexedDiskElementDescriptor o1, IndexedDiskElementDescriptor o2) + public int compare(IndexedDiskElementDescriptor ded1, IndexedDiskElementDescriptor ded2) { - IndexedDiskElementDescriptor ded1 = o1; - IndexedDiskElementDescriptor ded2 = o2; - if (ded1.pos < ded2.pos) { return -1; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java Thu Dec 10 15:07:30 2015 @@ -135,7 +135,7 @@ public class JDBCDiskCache this.dsFactory = dsFactory; // Initialization finished successfully, so set alive to true. - alive = true; + setAlive(true); } /** @@ -463,7 +463,7 @@ public class JDBCDiskCache log.debug( "Getting [" + key + "] from disk" ); } - if ( !alive ) + if ( !isAlive() ) { return null; } @@ -570,7 +570,7 @@ public class JDBCDiskCache log.debug( "Getting [" + pattern + "] from disk" ); } - if ( !alive ) + if ( !isAlive() ) { return null; } @@ -717,12 +717,12 @@ public class JDBCDiskCache psSelect.executeUpdate(); - alive = true; + setAlive(true); } catch ( SQLException e ) { log.error( "Problem creating statement. sql [" + sql + "]", e ); - alive = false; + setAlive(false); } finally { @@ -767,13 +767,13 @@ public class JDBCDiskCache { psDelete = con.prepareStatement( sql ); psDelete.setString( 1, this.getCacheName() ); - alive = true; + setAlive(true); psDelete.executeUpdate(); } catch ( SQLException e ) { log.error( "Problem creating statement.", e ); - alive = false; + setAlive(false); } finally { @@ -839,14 +839,14 @@ public class JDBCDiskCache psDelete.setString( 2, this.getCacheName() ); psDelete.setLong( 3, now ); - alive = true; + setAlive(true); deleted = psDelete.executeUpdate(); } catch ( SQLException e ) { log.error( "Problem creating statement.", e ); - alive = false; + setAlive(false); } finally { @@ -893,7 +893,7 @@ public class JDBCDiskCache @Override public void processDispose() { - ICacheEvent cacheEvent = createICacheEvent( cacheName, (K)"none", ICacheEventLogger.DISPOSE_EVENT ); + ICacheEvent cacheEvent = createICacheEvent( getCacheName(), (K)"none", ICacheEventLogger.DISPOSE_EVENT ); try { try Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,12 @@ package org.apache.commons.jcs.auxiliary * under the License. */ +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging; import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes; @@ -33,12 +39,6 @@ import org.apache.commons.jcs.engine.sta import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - /** * Lateral distributor. Returns null on get by default. Net search not implemented. */ @@ -98,20 +98,17 @@ public class LateralCache { try { - if ( log.isDebugEnabled() ) + if (ce != null) { - log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " - + CacheInfo.listenerId ); + if ( log.isDebugEnabled() ) + { + log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " + + CacheInfo.listenerId ); + } + lateralCacheService.update( ce, CacheInfo.listenerId ); } - lateralCacheService.update( ce, CacheInfo.listenerId ); - } - catch ( NullPointerException npe ) - { - log.error( "Failure updating lateral. lateral = " + lateralCacheService, npe ); - handleException( npe, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); - return; } - catch ( Exception ex ) + catch ( IOException ex ) { handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); } @@ -214,7 +211,7 @@ public class LateralCache { return lateralCacheService.getKeySet( cacheName ); } - catch ( Exception ex ) + catch ( IOException ex ) { handleException( ex, "Failed to get key set from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); @@ -243,7 +240,7 @@ public class LateralCache { lateralCacheService.remove( cacheName, key, CacheInfo.listenerId ); } - catch ( Exception ex ) + catch ( IOException ex ) { handleException( ex, "Failed to remove " + key + " from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } @@ -264,7 +261,7 @@ public class LateralCache { lateralCacheService.removeAll( cacheName, CacheInfo.listenerId ); } - catch ( Exception ex ) + catch ( IOException ex ) { handleException( ex, "Failed to remove all from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } @@ -290,7 +287,7 @@ public class LateralCache lateralCacheService.dispose( this.lateralCacheAttributes.getCacheName() ); // Should remove connection } - catch ( Exception ex ) + catch ( IOException ex ) { log.error( "Couldn't dispose", ex ); handleException( ex, "Failed to dispose " + lateralCacheAttributes.getCacheName() ); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheAttributes.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheAttributes.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheAttributes.java Thu Dec 10 15:07:30 2015 @@ -23,14 +23,12 @@ import org.apache.commons.jcs.auxiliary. import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes; -import java.io.Serializable; - /** * This class stores attributes for all of the available lateral cache auxiliaries. */ public class LateralCacheAttributes extends AbstractAuxiliaryCacheAttributes - implements Serializable, ILateralCacheAttributes + implements ILateralCacheAttributes { /** Don't change */ private static final long serialVersionUID = -3408449508837393660L; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java Thu Dec 10 15:07:30 2015 @@ -31,7 +31,6 @@ import org.apache.commons.jcs.auxiliary. import org.apache.commons.jcs.auxiliary.lateral.LateralCacheMonitor; import org.apache.commons.jcs.auxiliary.lateral.LateralCacheNoWait; import org.apache.commons.jcs.auxiliary.lateral.LateralCacheNoWaitFacade; -import org.apache.commons.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes; import org.apache.commons.jcs.auxiliary.lateral.behavior.ILateralCacheListener; import org.apache.commons.jcs.auxiliary.lateral.socket.tcp.behavior.ITCPLateralCacheAttributes; import org.apache.commons.jcs.engine.CacheWatchRepairable; @@ -178,6 +177,7 @@ public class LateralTCPCacheFactory // Create the monitoring daemon thread this.monitor = new LateralCacheMonitor(this); this.monitor.setDaemon( true ); + this.monitor.start(); this.lateralWatch = new CacheWatchRepairable(); this.lateralWatch.setCacheWatch( new ZombieCacheWatch() ); @@ -209,7 +209,14 @@ public class LateralTCPCacheFactory if (this.monitor != null) { this.monitor.notifyShutdown(); - // this.monitor.join(5000); + try + { + this.monitor.join(5000); + } + catch (InterruptedException e) + { + // swallow + } this.monitor = null; } } @@ -365,15 +372,14 @@ public class LateralTCPCacheFactory *

* This should be called by create cache. *

- * @param lac ILateralCacheAttributes + * @param attr ITCPLateralCacheAttributes * @param cacheMgr * * @return the listener if created, else null */ - private ILateralCacheListener createListener( ILateralCacheAttributes lac, + private ILateralCacheListener createListener( ITCPLateralCacheAttributes attr, ICompositeCacheManager cacheMgr ) { - ITCPLateralCacheAttributes attr = (ITCPLateralCacheAttributes) lac; ILateralCacheListener listener = null; // don't create a listener if we are not receiving. @@ -381,21 +387,14 @@ public class LateralTCPCacheFactory { if ( log.isInfoEnabled() ) { - log.info( "Getting listener for " + lac ); + log.info( "Getting listener for " + attr ); } - try - { - // make a listener. if one doesn't exist - listener = LateralTCPListener.getInstance( attr, cacheMgr ); + // make a listener. if one doesn't exist + listener = LateralTCPListener.getInstance( attr, cacheMgr ); - // register for shutdown notification - cacheMgr.registerShutdownObserver( (IShutdownObserver) listener ); - } - catch ( Exception e ) - { - log.error( "Problem creating lateral listener", e ); - } + // register for shutdown notification + cacheMgr.registerShutdownObserver( (IShutdownObserver) listener ); } else { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java Thu Dec 10 15:07:30 2015 @@ -20,6 +20,7 @@ package org.apache.commons.jcs.auxiliary */ import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; +import org.apache.commons.jcs.auxiliary.remote.RemoteLocation; import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType; /** @@ -74,32 +75,26 @@ public interface ICommonRemoteCacheAttri void setRemoteServiceName( String s ); /** - * Gets the remoteHost attribute of the IRemoteCacheAttributes object + * Sets the location attribute of the RemoteCacheAttributes object. *

- * @return The remoteHost value + * @param location The new location value */ - String getRemoteHost(); + void setRemoteLocation( RemoteLocation location ); /** - * Sets the remoteHost attribute of the IRemoteCacheAttributes object + * Sets the location attribute of the RemoteCacheAttributes object. *

- * @param s The new remoteHost value + * @param host The new remoteHost value + * @param port The new remotePort value */ - void setRemoteHost( String s ); + void setRemoteLocation( String host, int port ); /** - * Gets the remotePort attribute of the IRemoteCacheAttributes object + * Gets the location attribute of the RemoteCacheAttributes object. *

- * @return The remotePort value + * @return The remote location value */ - int getRemotePort(); - - /** - * Sets the remotePort attribute of the IRemoteCacheAttributes object - *

- * @param p The new remotePort value - */ - void setRemotePort( int p ); + public RemoteLocation getRemoteLocation(); /** * Gets the clusterServers attribute of the IRemoteCacheAttributes object Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java Thu Dec 10 15:07:30 2015 @@ -1,5 +1,7 @@ package org.apache.commons.jcs.auxiliary.remote.behavior; +import org.apache.commons.jcs.auxiliary.remote.RemoteLocation; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -63,14 +65,14 @@ public interface IRemoteCacheAttributes *

* @return The failovers value */ - String[] getFailovers(); + RemoteLocation[] getFailovers(); /** * Sets the failovers attribute of the IRemoteCacheAttributes object *

* @param f The new failovers value */ - void setFailovers( String[] f ); + void setFailovers( RemoteLocation[] f ); /** * Gets the localPort attribute of the IRemoteCacheAttributes object Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java Thu Dec 10 15:07:30 2015 @@ -156,9 +156,8 @@ public class RemoteHttpCacheDispatcher switch ( remoteCacheRequest.getRequestType() ) { case GET: - keyValue = remoteCacheRequest.getKey() + ""; - break; case REMOVE: + case GET_KEYSET: keyValue = remoteCacheRequest.getKey() + ""; break; case GET_MATCHING: @@ -167,9 +166,6 @@ public class RemoteHttpCacheDispatcher case GET_MULTIPLE: keyValue = remoteCacheRequest.getKeySet() + ""; break; - case GET_KEYSET: - keyValue = remoteCacheRequest.getKey() + ""; - break; case UPDATE: keyValue = remoteCacheRequest.getCacheElement().getKey() + ""; break; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,12 @@ package org.apache.commons.jcs.auxiliary * under the License. */ +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.apache.commons.jcs.auxiliary.remote.value.RemoteCacheRequest; import org.apache.commons.jcs.auxiliary.remote.value.RemoteCacheResponse; import org.apache.commons.jcs.engine.behavior.ICacheElement; @@ -27,12 +33,6 @@ import org.apache.commons.jcs.engine.beh import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.io.IOException; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - /** * The Servlet deserializes the request object. The request object is passed to the processor. The * processor then calls the service which does the work of talking to the cache. @@ -126,8 +126,6 @@ public class RemoteCacheServiceAdaptor } } - ICacheElement element = null; - - element = getFromCacheListeners( key, fromCluster, cacheDesc, element ); + ICacheElement element = getFromCacheListeners( key, fromCluster, cacheDesc, null ); return element; } @@ -731,8 +729,6 @@ public class RemoteCacheServer */ private Map> processGetMultiple( String cacheName, Set keys, long requesterId ) { - Map> elements = null; - boolean fromCluster = isRequestFromCluster( requesterId ); if ( log.isDebugEnabled() ) @@ -741,17 +737,8 @@ public class RemoteCacheServer + "] fromCluster = " + fromCluster ); } - CacheListeners cacheDesc = null; - try - { - cacheDesc = getCacheListeners( cacheName ); - } - catch ( Exception e ) - { - log.error( "Problem getting listeners.", e ); - } - - elements = getMultipleFromCacheListeners( keys, elements, fromCluster, cacheDesc ); + CacheListeners cacheDesc = getCacheListeners( cacheName ); + Map> elements = getMultipleFromCacheListeners( keys, null, fromCluster, cacheDesc ); return elements; } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java Thu Dec 10 15:07:30 2015 @@ -19,17 +19,6 @@ package org.apache.commons.jcs.auxiliary * under the License. */ -import org.apache.commons.jcs.auxiliary.AuxiliaryCacheConfigurator; -import org.apache.commons.jcs.auxiliary.remote.RemoteUtils; -import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheConstants; -import org.apache.commons.jcs.engine.behavior.ICacheServiceAdmin; -import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; -import org.apache.commons.jcs.utils.config.OptionConverter; -import org.apache.commons.jcs.utils.config.PropertySetter; -import org.apache.commons.jcs.utils.threadpool.DaemonThreadFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.IOException; import java.io.Serializable; import java.net.MalformedURLException; @@ -45,6 +34,17 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.apache.commons.jcs.auxiliary.AuxiliaryCacheConfigurator; +import org.apache.commons.jcs.auxiliary.remote.RemoteUtils; +import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheConstants; +import org.apache.commons.jcs.engine.behavior.ICacheServiceAdmin; +import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs.utils.config.OptionConverter; +import org.apache.commons.jcs.utils.config.PropertySetter; +import org.apache.commons.jcs.utils.threadpool.DaemonThreadFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * Provides remote cache services. This creates remote cache servers and can proxy command line * requests to a running server. @@ -156,8 +156,7 @@ public class RemoteCacheServerFactory rcsa.setConfigFileName( propFile ); // These should come from the file! - rcsa.setRemotePort( port ); - rcsa.setRemoteHost( host ); + rcsa.setRemoteLocation( host, port ); if ( log.isInfoEnabled() ) { log.info( "Creating server with these attributes: " + rcsa ); @@ -355,14 +354,14 @@ public class RemoteCacheServerFactory String lccStr = prop.getProperty( REMOTE_LOCAL_CLUSTER_CONSISTENCY ); if ( lccStr != null ) { - boolean lcc = Boolean.valueOf( lccStr ).booleanValue(); + boolean lcc = Boolean.parseBoolean( lccStr ); rcsa.setLocalClusterConsistency( lcc ); } String acgStr = prop.getProperty( REMOTE_ALLOW_CLUSTER_GET ); if ( acgStr != null ) { - boolean acg = Boolean.valueOf( acgStr ).booleanValue(); + boolean acg = Boolean.parseBoolean( lccStr ); rcsa.setAllowClusterGet( acg ); } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheInfo.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheInfo.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheInfo.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheInfo.java Thu Dec 10 15:07:30 2015 @@ -40,7 +40,7 @@ public final class CacheInfo * TODO: may have some trouble in failover mode if the cache keeps its old * id. We may need to reset this when moving into failover. */ - protected static final VMID vmid = new VMID(); + private static final VMID vmid = new VMID(); /** By default this is the hashcode of the VMID */ public static final long listenerId = vmid.hashCode(); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CompositeCacheAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CompositeCacheAttributes.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CompositeCacheAttributes.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CompositeCacheAttributes.java Thu Dec 10 15:07:30 2015 @@ -412,7 +412,7 @@ public class CompositeCacheAttributes { try { - ICompositeCacheAttributes cattr = (CompositeCacheAttributes) this.clone(); + ICompositeCacheAttributes cattr = (ICompositeCacheAttributes) this.clone(); return cattr; } catch ( Exception e ) Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java Thu Dec 10 15:07:30 2015 @@ -232,7 +232,7 @@ public class CompositeCacheConfigurator *

* @param props */ - protected void parseSystemRegions( Properties props ) + protected void parseSystemRegions( Properties props ) { Enumeration en = props.propertyNames(); while ( en.hasMoreElements() ) @@ -242,7 +242,7 @@ public class CompositeCacheConfigurator { String regionName = key.substring( SYSTEM_REGION_PREFIX.length() ); String value = OptionConverter.findAndSubst( key, props ); - ICache cache; + ICache cache; synchronized ( regionName ) { cache = parseRegion( props, regionName, value, null, SYSTEM_REGION_PREFIX ); @@ -258,7 +258,7 @@ public class CompositeCacheConfigurator *

* @param props */ - protected void parseRegions( Properties props ) + protected void parseRegions( Properties props ) { List regionNames = new ArrayList(); @@ -273,7 +273,7 @@ public class CompositeCacheConfigurator regionNames.add( regionName ); String auxiliaryList = OptionConverter.findAndSubst( key, props ); - ICache cache; + ICache cache; synchronized ( regionName ) { cache = parseRegion( props, regionName, auxiliaryList ); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java Thu Dec 10 15:07:30 2015 @@ -26,12 +26,13 @@ import java.security.AccessControlExcept import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; -import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.locks.ReentrantLock; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -79,9 +80,12 @@ public class CompositeCacheManager public static final String JMX_OBJECT_NAME = "org.apache.commons.jcs:type=JCSAdminBean"; /** Caches managed by this cache manager */ - private final Map> caches = + private final ConcurrentMap> caches = new ConcurrentHashMap>(); + /** Lock for initialization of caches */ + private ReentrantLock cacheLock = new ReentrantLock(); + /** Number of clients accessing this cache manager */ private int clients; @@ -92,15 +96,15 @@ public class CompositeCacheManager private IElementAttributes defaultElementAttr = new ElementAttributes(); /** Used to keep track of configured auxiliaries */ - private final Map auxiliaryFactoryRegistry = + private final ConcurrentMap auxiliaryFactoryRegistry = new ConcurrentHashMap( 11 ); /** Used to keep track of attributes for auxiliaries. */ - private final Map auxiliaryAttributeRegistry = + private final ConcurrentMap auxiliaryAttributeRegistry = new ConcurrentHashMap( 11 ); /** Used to keep track of configured auxiliaries */ - private final Map> auxiliaryCaches = + private final ConcurrentMap> auxiliaryCaches = new ConcurrentHashMap>( 11 ); /** Properties with which this manager was configured. This is exposed for other managers. */ @@ -459,7 +463,7 @@ public class CompositeCacheManager { log.info( "Using system property [[" + key + "] [" + sysProps.getProperty( key ) + "]]" ); } - props.put( key, sysProps.getProperty( key ) ); + props.setProperty( key, sysProps.getProperty( key ) ); } } } @@ -603,19 +607,32 @@ public class CompositeCacheManager log.debug( "attr = " + attr ); } - synchronized ( caches ) + cache = (CompositeCache) caches.get( cattr.getCacheName() ); + + if (cache == null) { - cache = (CompositeCache) caches.get( cattr.getCacheName() ); - if ( cache == null ) + cacheLock.lock(); + + try { - cattr.setCacheName( cattr.getCacheName() ); + // double check + cache = (CompositeCache) caches.get( cattr.getCacheName() ); + + if ( cache == null ) + { + cattr.setCacheName( cattr.getCacheName() ); - CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( this ); + CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( this ); - cache = configurator.parseRegion( this.getConfigurationProperties(), cattr.getCacheName(), - this.defaultAuxValues, cattr ); + cache = configurator.parseRegion( this.getConfigurationProperties(), cattr.getCacheName(), + this.defaultAuxValues, cattr ); - caches.put( cattr.getCacheName(), cache ); + caches.put( cattr.getCacheName(), cache ); + } + } + finally + { + cacheLock.unlock(); } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,8 @@ package org.apache.commons.jcs.engine.me * under the License. */ +import java.util.Set; + import org.apache.commons.jcs.engine.behavior.ICacheElement; import org.apache.commons.jcs.engine.behavior.IElementAttributes; import org.apache.commons.jcs.engine.control.CompositeCache; @@ -27,8 +29,6 @@ import org.apache.commons.jcs.engine.mem import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.Set; - /** * A background memory shrinker. Memory problems and concurrent modification exception caused by * acting directly on an iterator of the underlying memory cache should have been solved. @@ -201,7 +201,6 @@ public class ShrinkerThread // stop processing if limit has been reached. if ( spoolLimit && spoolCount >= this.maxSpoolPerRun ) { - keys = null; return; } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/config/OptionConverter.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/config/OptionConverter.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/config/OptionConverter.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/config/OptionConverter.java Thu Dec 10 15:07:30 2015 @@ -19,11 +19,11 @@ package org.apache.commons.jcs.utils.con * under the License. */ +import java.util.Properties; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.Properties; - /** * This class is based on the log4j class org.apache.log4j.helpers.OptionConverter that was made by * Ceki Gülcü Simon Kitching; Avy Sharell (sharell@online.fr) Anders Kristensen Matthieu @@ -184,7 +184,6 @@ public class OptionConverter * @param dEfault * @return Object */ - public static boolean toBoolean( String value, boolean dEfault ) { if ( value == null ) @@ -217,7 +216,7 @@ public class OptionConverter String s = value.trim(); try { - return Integer.valueOf( s ).intValue(); + return Integer.parseInt(s); } catch ( NumberFormatException e ) { @@ -263,7 +262,7 @@ public class OptionConverter { try { - return Long.valueOf( s ).longValue() * multiplier; + return Long.parseLong(s) * multiplier; } catch ( NumberFormatException e ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java Thu Dec 10 15:07:30 2015 @@ -197,7 +197,7 @@ public final class UDPDiscoveryAttribute /** @return a clone of this object */ @Override - public Object clone() + public UDPDiscoveryAttributes clone() { UDPDiscoveryAttributes attributes = new UDPDiscoveryAttributes(); attributes.setSendDelaySec( this.getSendDelaySec() ); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryReceiver.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryReceiver.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryReceiver.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryReceiver.java Thu Dec 10 15:07:30 2015 @@ -170,7 +170,7 @@ public class UDPDiscoveryReceiver objectStream = new ObjectInputStreamClassLoaderAware( byteStream, null ); obj = objectStream.readObject(); - if ( obj != null && obj instanceof UDPDiscoveryMessage ) + if ( obj instanceof UDPDiscoveryMessage ) { // Ensure that the address we're supposed to send to is, indeed, the address // of the machine on the other end of this connection. This guards against Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java Thu Dec 10 15:07:30 2015 @@ -133,7 +133,7 @@ public abstract class AbstractLRUMap @@ -321,6 +322,7 @@ public class JCSThrashTest if ( listSize.equals( statElement.getName() ) ) { result = statElement.getData().toString(); + break; } } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java Thu Dec 10 15:07:30 2015 @@ -100,7 +100,7 @@ public class AbstractDiskCacheUnitTest diskCache.dispose(); // VERIFY - assertFalse( "disk cache should not be alive.", diskCache.alive ); + assertFalse( "disk cache should not be alive.", diskCache.isAlive() ); assertEquals( "Status should be disposed", CacheStatus.DISPOSED, diskCache.getStatus() ); } @@ -186,7 +186,7 @@ public class AbstractDiskCacheUnitTest { super( attr ); diskCacheAttributes = attr; - super.alive = true; + setAlive(true); } /** Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java Thu Dec 10 15:07:30 2015 @@ -56,11 +56,11 @@ public class HsqlSetupTableUtil try { - sStatement.executeQuery( createSql.toString() ); + sStatement.execute( createSql.toString() ); } catch ( SQLException e ) { - if ( e.toString().indexOf( "already exists" ) != -1 ) + if ("23000".equals(e.getSQLState())) { newT = false; } @@ -78,11 +78,11 @@ public class HsqlSetupTableUtil if ( newT ) { - for ( int i = 1; i < setupData.length; i++ ) + for ( int i = 0; i < setupData.length; i++ ) { try { - sStatement.executeQuery( setupData[i] ); + sStatement.execute( setupData[i] ); } catch ( SQLException e ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheRemovalUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheRemovalUnitTest.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheRemovalUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheRemovalUnitTest.java Thu Dec 10 15:07:30 2015 @@ -19,16 +19,17 @@ package org.apache.commons.jcs.auxiliary * under the License. */ -import junit.framework.TestCase; -import org.apache.commons.jcs.JCS; -import org.apache.commons.jcs.access.CacheAccess; - import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; +import junit.framework.TestCase; + +import org.apache.commons.jcs.JCS; +import org.apache.commons.jcs.access.CacheAccess; + /** Tests for the removal functionality. */ public class JDBCDiskCacheRemovalUnitTest extends TestCase @@ -136,12 +137,11 @@ public class JDBCDiskCacheRemovalUnitTes try { - sStatement.executeQuery( createSql.toString() ); + sStatement.execute( createSql.toString() ); } catch ( SQLException e ) { - // FIXME: This is unreliable - if ( e.toString().indexOf( "already exists" ) != -1 ) + if ("23000".equals(e.getSQLState())) { newT = false; } @@ -159,11 +159,11 @@ public class JDBCDiskCacheRemovalUnitTes if ( newT ) { - for ( int i = 1; i < setupData.length; i++ ) + for ( int i = 0; i < setupData.length; i++ ) { try { - sStatement.executeQuery( setupData[i] ); + sStatement.execute( setupData[i] ); } catch ( SQLException e ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheShrinkUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheShrinkUnitTest.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheShrinkUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheShrinkUnitTest.java Thu Dec 10 15:07:30 2015 @@ -19,11 +19,8 @@ package org.apache.commons.jcs.auxiliary * under the License. */ -import junit.framework.TestCase; -import org.apache.commons.jcs.JCS; -import org.apache.commons.jcs.access.CacheAccess; -import org.apache.commons.jcs.access.exception.CacheException; -import org.apache.commons.jcs.utils.timing.SleepUtil; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.sql.Connection; import java.sql.DriverManager; @@ -31,29 +28,29 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; +import org.apache.commons.jcs.JCS; +import org.apache.commons.jcs.access.CacheAccess; +import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.commons.jcs.utils.timing.SleepUtil; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + /** * Runs basic tests for the JDBC disk cache. *

* @author Aaron Smuts */ public class JDBCDiskCacheShrinkUnitTest - extends TestCase { - /** - * Test setup + * Creates the DB *

- * @throws ClassNotFoundException - * @throws IllegalAccessException - * @throws InstantiationException - * @throws SQLException + * @throws Exception */ - @Override - public void setUp() - throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException + @BeforeClass + public static void setupDatabase() throws Exception { - JCS.setConfigFilename( "/TestJDBCDiskCacheShrink.ccf" ); - System.setProperty( "hsqldb.cache_scale", "8" ); String rafroot = "target"; @@ -72,11 +69,21 @@ public class JDBCDiskCacheShrinkUnitTest } /** + * Test setup + */ + @Before + public void setUp() + { + JCS.setConfigFilename( "/TestJDBCDiskCacheShrink.ccf" ); + } + + /** * Test the basic JDBC disk cache functionality with a hsql backing. Verify that items * configured to expire after 1 second actually expire. *

* @throws Exception */ + @Test public void testExpireInBackground() throws Exception { @@ -114,6 +121,7 @@ public class JDBCDiskCacheShrinkUnitTest * @throws CacheException * @throws InterruptedException */ + @Test public void testDidNotExpire() throws CacheException, InterruptedException { @@ -166,6 +174,7 @@ public class JDBCDiskCacheShrinkUnitTest * @throws CacheException * @throws InterruptedException */ + @Test public void testDidNotExpireEternal() throws CacheException, InterruptedException { @@ -219,7 +228,7 @@ public class JDBCDiskCacheShrinkUnitTest * * @throws SQLException if database problems occur */ - void setupTABLE( Connection cConn ) throws SQLException + private static void setupTABLE( Connection cConn ) throws SQLException { boolean newT = true; @@ -241,11 +250,11 @@ public class JDBCDiskCacheShrinkUnitTest try { - sStatement.executeQuery( createSql.toString() ); + sStatement.execute( createSql.toString() ); } catch ( SQLException e ) { - if ( e.toString().indexOf( "already exists" ) != -1 ) + if ("23000".equals(e.getSQLState())) { newT = false; } @@ -263,11 +272,11 @@ public class JDBCDiskCacheShrinkUnitTest if ( newT ) { - for ( int i = 1; i < setupData.length; i++ ) + for ( int i = 0; i < setupData.length; i++ ) { try { - sStatement.executeQuery( setupData[i] ); + sStatement.execute( setupData[i] ); } catch ( SQLException e ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java?rev=1719092&r1=1719091&r2=1719092&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java Thu Dec 10 15:07:30 2015 @@ -19,6 +19,10 @@ package org.apache.commons.jcs.auxiliary * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -27,28 +31,27 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import junit.framework.TestCase; - import org.apache.commons.jcs.JCS; import org.apache.commons.jcs.access.CacheAccess; import org.apache.commons.jcs.engine.behavior.ICacheElement; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; /** * Runs basic tests for the JDBC disk cache. * @author Aaron Smuts */ public class MySQLDiskCacheHsqlBackedUnitTest - extends TestCase { /** * Creates the DB *

* @throws Exception */ - public MySQLDiskCacheHsqlBackedUnitTest() - throws Exception + @BeforeClass + public static void setupDatabase() throws Exception { - super(); System.setProperty( "hsqldb.cache_scale", "8" ); String rafroot = "target"; @@ -66,7 +69,7 @@ public class MySQLDiskCacheHsqlBackedUni /** * Test setup */ - @Override + @Before public void setUp() { JCS.setConfigFilename( "/TestMySQLDiskCache.ccf" ); @@ -76,6 +79,7 @@ public class MySQLDiskCacheHsqlBackedUni * Test the basic JDBC disk cache functionality with a hsql backing. * @throws Exception */ + @Test public void testSimpleJDBCPutGetWithHSQL() throws Exception { @@ -148,6 +152,7 @@ public class MySQLDiskCacheHsqlBackedUni *

* @throws Exception */ + @Test public void testPutGetMatchingWithHSQL() throws Exception { @@ -176,7 +181,7 @@ public class MySQLDiskCacheHsqlBackedUni * SETUP TABLE FOR CACHE * @param cConn */ - void setupTABLE( Connection cConn ) throws SQLException + private static void setupTABLE( Connection cConn ) throws SQLException { boolean newT = true;