Author: manik.surtani(a)jboss.com
Date: 2008-05-08 06:05:42 -0400 (Thu, 08 May 2008)
New Revision: 5808
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/DataContainer.java
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/Version.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.java
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java
core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java
core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java
core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
Log:
Code cleanups based on IntelliJ inspections
Modified: core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-05-08 09:16:18 UTC
(rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-05-08 10:05:42 UTC
(rev 5808)
@@ -105,7 +105,7 @@
public Cache<Object, Object> getCache(String configName, boolean create) throws
Exception
{
- Cache<Object, Object> cache = null;
+ Cache<Object, Object> cache;
synchronized (caches)
{
cache = caches.get(configName);
@@ -236,10 +236,10 @@
{
Integer count = checkouts.get(configName);
if (count == null)
- count = new Integer(0);
- Integer newVal = new Integer(count.intValue() + 1);
+ count = 0;
+ Integer newVal = count + 1;
checkouts.put(configName, newVal);
- return newVal.intValue();
+ return newVal;
}
}
@@ -248,12 +248,12 @@
synchronized (checkouts)
{
Integer count = checkouts.get(configName);
- if (count == null || count.intValue() < 1)
+ if (count == null || count < 1)
throw new IllegalStateException("invalid count of " + count +
" for " + configName);
- Integer newVal = new Integer(count.intValue() - 1);
+ Integer newVal = count - 1;
checkouts.put(configName, newVal);
- return newVal.intValue();
+ return newVal;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-05-08 09:16:18 UTC
(rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-05-08 10:05:42 UTC
(rev 5808)
@@ -367,6 +367,7 @@
/**
* Returns a debug string with optional details of contents.
*/
+ @SuppressWarnings("deprecation")
public String toString(boolean details)
{
StringBuffer sb = new StringBuffer();
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-05-08 09:16:18
UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-05-08 10:05:42
UTC (rev 5808)
@@ -25,6 +25,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
*/
+@SuppressWarnings("deprecation")
public class InvocationContext implements Cloneable
{
private static final Log log = LogFactory.getLog(InvocationContext.class);
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-05-08 09:16:18 UTC
(rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-05-08 10:05:42 UTC
(rev 5808)
@@ -227,6 +227,7 @@
return !configuration.isInactiveOnStartup() && !isUsingBuddyReplication
&& (configuration.isFetchInMemoryState() || loaderFetch);
}
+ @SuppressWarnings("deprecation")
private void initialiseChannelAndRpcDispatcher(boolean fetchState) throws
CacheException
{
channel = configuration.getRuntimeConfig().getChannel();
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-05-08 09:16:18 UTC
(rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-05-08 10:05:42 UTC
(rev 5808)
@@ -542,8 +542,8 @@
throw new CacheException("Region " + fqn + " is already being
activated/deactivated");
}
- NodeSPI parent = null;
- NodeSPI subtreeRoot = null;
+ NodeSPI parent;
+ NodeSPI subtreeRoot;
boolean parentLocked = false;
boolean subtreeLocked = false;
NodeLock parentLock = null;
@@ -816,7 +816,7 @@
// JBAS-1288
// Try to establish a default region if there isn't one already
- boolean needDefault = true;
+ boolean needDefault;
List<EvictionRegionConfig> ercs = evictionConfig.getEvictionRegionConfigs();
// APPROACH 1: Scan for a default region, try to add if not there.
@@ -890,13 +890,15 @@
/**
* Returns a string containing debug information on every region.
+ *
+ * @return Regions as a string
*/
public String dumpRegions()
{
StringBuilder sb = new StringBuilder();
for (Region r : regionsRegistry.values())
{
- sb.append("\tRegion " + r);
+ sb.append("\tRegion ").append(r);
sb.append("\n");
}
return sb.toString();
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2008-05-08 09:16:18 UTC (rev
5807)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2008-05-08 10:05:42 UTC (rev
5808)
@@ -134,10 +134,9 @@
public static short encodeVersion(int major, int minor, int patch)
{
- short version = (short) ((major << MAJOR_SHIFT)
+ return (short) ((major << MAJOR_SHIFT)
+ (minor << MINOR_SHIFT)
+ patch);
- return version;
}
public static String decodeVersion(short version)
@@ -145,8 +144,7 @@
int major = (version & MAJOR_MASK) >> MAJOR_SHIFT;
int minor = (version & MINOR_MASK) >> MINOR_SHIFT;
int patch = (version & PATCH_MASK);
- String versionString = major + "." + minor + "." + patch;
- return versionString;
+ return major + "." + minor + "." + patch;
}
public static boolean isBefore124(short version)
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -758,6 +758,7 @@
log.trace("removeFromGroup notification complete");
}
+ @SuppressWarnings("deprecation")
private void addBuddies(List<Address> buddies) throws CacheException
{
if (log.isDebugEnabled())
@@ -869,8 +870,6 @@
for (int i = 0; i < timeouts.length; i++)
{
- timeoutException = null;
-
boolean force = (i == timeouts.length - 1);
try
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -100,9 +100,9 @@
Fqn backupRoot =
Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
if (BuddyFqnTransformer.isDeadBackupRoot(backupRoot))
{
- //actualNode = searchDeadRoot(backupRoot, fqn);
+ @SuppressWarnings("unchecked")
Set<Integer> deadChildNames = new
TreeSet<Integer>(spi.getChildrenNames(backupRoot));
- Integer[] elems = deadChildNames.toArray(new Integer[]{});
+ Integer[] elems = deadChildNames.toArray(new
Integer[deadChildNames.size()]);
// these are integers. we need to start with the highest/most
recent.
for (int i = elems.length - 1; i > -1; i--)
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -29,7 +29,7 @@
public static final int METHOD_ID = 22;
private DataCommand dataCommand;
- private Boolean searchBackupSubtrees;
+ private boolean searchBackupSubtrees;
private DataContainer dataContainer;
private InterceptorChain interceptorChain;
@@ -85,7 +85,8 @@
{
results.add(true);
results.add(callResults);
- } else
+ }
+ else
{
results.add(false);
results.add(null);
@@ -153,10 +154,7 @@
if (dataCommand != null ? !dataCommand.equals(that.dataCommand) : that.dataCommand
!= null)
return false;
- if (searchBackupSubtrees != null ?
!searchBackupSubtrees.equals(that.searchBackupSubtrees) : that.searchBackupSubtrees !=
null)
- return false;
-
- return true;
+ return searchBackupSubtrees == that.searchBackupSubtrees;
}
@Override
@@ -164,7 +162,7 @@
{
int result;
result = (dataCommand != null ? dataCommand.hashCode() : 0);
- result = 31 * result + (searchBackupSubtrees != null ?
searchBackupSubtrees.hashCode() : 0);
+ result = 31 * result + (searchBackupSubtrees ? 1 : 0);
return result;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -88,7 +88,7 @@
public Configuration getConfiguration(String configName)
{
- Configuration config = null;
+ Configuration config;
synchronized (configs)
{
config = configs.get(configName);
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -290,8 +290,7 @@
public void set(Object o)
{
this.doConcurrentModCheck();
- NodeEntry e = (NodeEntry) o;
- cursor.node = e;
+ cursor.node = (NodeEntry) o;
}
public void add(Object o)
Modified: core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -212,7 +212,7 @@
if (list.getLength() > 1) throw new ConfigurationException("Has multiple
" + XmlHelper.ROOT + " tag");
Node node = list.item(0);
- Element element = null;
+ Element element;
if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
{
element = (Element) node;
@@ -440,7 +440,7 @@
Element singletonStoreElement = (Element) singletonStoreNode;
boolean singletonStoreEnabled =
XmlHelper.readBooleanContents(singletonStoreElement, "enabled");
String singletonStoreClass = XmlHelper.readStringContents(singletonStoreElement,
"class");
- Properties singletonStoreproperties = null;
+ Properties singletonStoreproperties;
try
{
singletonStoreproperties =
XmlHelper.readPropertiesContents(singletonStoreElement, "properties");
@@ -567,7 +567,7 @@
}
}
- EvictionPolicy policy = null;
+ EvictionPolicy policy;
try
{
policy = (EvictionPolicy) Util.loadClass(evictionClass).newInstance();
@@ -581,7 +581,7 @@
throw new RuntimeException("Eviction class is not properly loaded in
classloader", e);
}
- EvictionPolicyConfig epc = null;
+ EvictionPolicyConfig epc;
try
{
epc = policy.getEvictionConfigurationClass().newInstance();
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -60,7 +60,7 @@
protected boolean isRollingBack(Transaction tx)
{
if (tx == null) return false;
- int status = -1;
+ int status;
try
{
status = tx.getStatus();
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -279,7 +279,6 @@
@Override
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
{
- Object result;
Object returnValue = invokeNextInterceptor(ctx, command);
if (inTransaction())
{
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -301,6 +301,7 @@
replicateCall(null, cleanupCommand, false, false, false, true, -1);
}
+ @SuppressWarnings("deprecation")
private GravitateResult gravitateData(Fqn fqn) throws Exception
{
if (trace) log.trace("Requesting data gravitation for Fqn " + fqn);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -136,7 +136,7 @@
else
{
Fqn fqn = command.getFqn();
- Region r = null;
+ Region r;
if (fqn != null && command.getKey() != null && (r =
getRegion(fqn, NodeEventType.REMOVE_ELEMENT_EVENT)) != null)
{
registerEvictionEventToRegionManager(new EvictedEventNode(fqn,
NodeEventType.REMOVE_ELEMENT_EVENT, 1), r);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -11,7 +11,6 @@
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.CachePrinter;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -132,13 +131,10 @@
* Returns an unmofiable list with all the interceptors in sequence.
* If first in chain is null an empty list is returned.
*/
- public List<CommandInterceptor> getInterceptorsAsList()
+ public List<CommandInterceptor> asList()
{
- List<CommandInterceptor> result;
- if (firstInChain == null)
- {
- result = Collections.EMPTY_LIST;
- }
+ if (firstInChain == null) return Collections.emptyList();
+
List<CommandInterceptor> retval = new
LinkedList<CommandInterceptor>();
CommandInterceptor tmp = firstInChain;
do
@@ -147,8 +143,7 @@
tmp = tmp.getNext();
}
while (tmp != null);
- result = Collections.unmodifiableList(retval);
- return result;
+ return Collections.unmodifiableList(retval);
}
@@ -196,35 +191,6 @@
}
/**
- * Returns the chain as a list.
- */
- public List<CommandInterceptor> asList()
- {
- List<CommandInterceptor> result;
- if (this.firstInChain == null)
- {
- result = null;
- }
- int num = 1;
- CommandInterceptor tmp = this.firstInChain;
- while ((tmp = tmp.getNext()) != null)
- {
- num++;
- }
- List<CommandInterceptor> retval = new
ArrayList<CommandInterceptor>(num);
- tmp = this.firstInChain;
- num = 0;
- do
- {
- retval.add(tmp);
- tmp = tmp.getNext();
- }
- while (tmp != null);
- result = retval;
- return result;
- }
-
- /**
* Appends at the end.
*/
public void appendIntereceptor(CommandInterceptor ci)
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -80,13 +80,7 @@
private boolean skipInvalidation(InvocationContext ctx)
{
Option optionOverride = ctx.getOptionOverrides();
- if (optionOverride != null && optionOverride.isCacheModeLocal() &&
(ctx.getTransaction() == null))
- {
- // skip replication!!
- return true;
- }
- if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") Command
" + ctx.getCommand());
- return false;
+ return optionOverride != null && optionOverride.isCacheModeLocal()
&& (ctx.getTransaction() == null);
}
@Override
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -84,9 +84,7 @@
@Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
- sb.append("tx=" + getTxAsString() + ", handlers=" + handlers);
- return sb.toString();
+ return "tx=" + getTxAsString() + ", handlers=" + handlers;
}
private String getTxAsString()
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -126,7 +126,7 @@
public List<CommandInterceptor> getInterceptorChain()
{
- return invoker.getInterceptorsAsList();
+ return invoker.asList();
}
public void removeInterceptor(int position)
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -278,7 +278,7 @@
// TODO: Revisit. Is this really threadsafe? See comment in putIfAbsent() - same
solution should be applied here too.
assertValid();
Fqn nf = Fqn.fromRelativeFqn(getFqn(), f);
- Option o1 = null;
+ Option o1;
try
{
o1 = spi.getInvocationContext().getOptionOverrides().clone();
@@ -292,7 +292,7 @@
if (child == null)
{
- Option o2 = null;
+ Option o2;
try
{
o2 = o1.clone();
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-05-08 09:16:18
UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-05-08 10:05:42
UTC (rev 5808)
@@ -348,6 +348,7 @@
}
@Deprecated
+ @SuppressWarnings("deprecation")
public boolean getUseRegionBasedMarshalling()
{
return getConfiguration().isUseRegionBasedMarshalling();
@@ -537,6 +538,8 @@
getConfiguration().setTransactionManagerLookupClass(cl);
}
+ @Deprecated
+ @SuppressWarnings("deprecation")
public void setUseRegionBasedMarshalling(boolean isTrue)
{
getConfiguration().setUseRegionBasedMarshalling(isTrue);
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-05-08 09:16:18 UTC (rev
5807)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-05-08 10:05:42 UTC (rev
5808)
@@ -122,7 +122,7 @@
public static String getDefaultCacheObjectName(Configuration config, String
cacheImplClass)
{
// get the cache's registration name
- String tmpName = null;
+ String tmpName;
if (config.getClusterName() == null)
{
tmpName = NO_CLUSTER_PREFIX + getUniqueId(cacheImplClass);
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -87,7 +87,7 @@
boolean moveToBuddy = subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)
&& subtree.size() > 1;
// store new state
- Fqn fqn = null;
+ Fqn fqn;
//NodeData nd = null;
Object objectFromStream = cache.getMarshaller().objectFromObjectStream(in);
if (objectFromStream instanceof NodeDataMarker)
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -371,13 +371,8 @@
{
try
{
- // ObjectInputStream ois = null;
- // ois = new ObjectInputStream(is);
- // Object marshalledNode = ois.readObject();
-
// deserialize result
- Map<Object, Object> oldNode = (Map<Object, Object>)
unmarshall(is);
- return oldNode;
+ return (Map<Object, Object>) unmarshall(is);
}
catch (Exception e)
{
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -11,6 +11,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
+@SuppressWarnings("deprecation")
public class AdjListJDBCCacheLoaderConfig extends IndividualCacheLoaderConfig
{
/**
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -132,7 +132,7 @@
*/
private CacheLoader createCacheLoader() throws Exception
{
- CacheLoader tmpLoader = null;
+ CacheLoader tmpLoader;
// if we only have a single cache loader configured in the chaining cacheloader
then
// don't use a chaining cache loader at all.
@@ -199,6 +199,7 @@
* @return a cache loader
* @throws Exception
*/
+ @SuppressWarnings("deprecation")
private CacheLoader createCacheLoader(CacheLoaderConfig.IndividualCacheLoaderConfig
cfg, CacheSPI cache) throws Exception
{
// create loader
@@ -339,7 +340,7 @@
if (preloadChildren)
{
// 3. Then recursively for all child nodes, preload them as well
- Set children = null;
+ Set children;
try
{
children = loader.getChildrenNames(fqn);
Modified: core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -109,6 +109,7 @@
}
}
+ @SuppressWarnings("deprecation")
private Object callRemote(DataCommand dataCommand) throws Exception
{
if (trace) log.trace("cache=" + cache.getLocalAddress() + "; calling
with " + dataCommand);
Modified: core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -421,7 +421,7 @@
if (!child.exists()) return new HashMap(0); // no node attribs exist hence the
empty HashMap.
//if(!child.exists()) return null;
- Map m = null;
+ Map m;
try
{
//m = (Map) unmarshall(child);
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -65,6 +65,7 @@
* @deprecated please use the {@link org.jboss.cache.loader.JDBCCacheLoader}.
*/
@Deprecated
+@SuppressWarnings("deprecation")
public class JDBCCacheLoaderOld extends AdjListJDBCCacheLoader
{
private static final Log log = LogFactory.getLog(JDBCCacheLoaderOld.class);
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -9,6 +9,7 @@
* @deprecated please use JDBCCacheLoaderConfig
*/
@Deprecated
+@SuppressWarnings("deprecation")
public class JDBCCacheLoaderOldConfig extends AdjListJDBCCacheLoaderConfig
{
/**
Modified: core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -210,15 +210,8 @@
final boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) log.debug("start pushing in-memory state to cache
cacheLoader");
- try
- {
- pushState(cache.getRoot());
- if (debugEnabled) log.debug("in-memory state passed to cache
cacheLoader successfully");
- }
- catch (Exception e)
- {
- throw e;
- }
+ pushState(cache.getRoot());
+ if (debugEnabled) log.debug("in-memory state passed to cache cacheLoader
successfully");
return null;
}
@@ -334,10 +327,6 @@
{
throw new Exception("task timed out", e);
}
- catch (ExecutionException e)
- {
- throw e;
- }
catch (InterruptedException e)
{
/* Re-assert the thread's interrupted status */
Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -1085,7 +1085,7 @@
private Map<Object, Object> makeDataObject(DatabaseEntry entry)
{
Map<Object, Object> map = (Map<Object, Object>)
serialBinding.entryToObject(entry);
- if (true && map == null)
+ if (map == null)
{
map = new HashMap<Object, Object>();
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -67,7 +67,6 @@
private static final String NAME = "JdbmCacheLoader";
private JdbmCacheLoaderConfig config;
- private String cacheDbName;
private RecordManager recman;
private BTree tree;
@@ -118,6 +117,7 @@
/* Parse config string. */
File homeDir;
int offset = locationStr.indexOf('#');
+ String cacheDbName;
if (offset >= 0 && offset < locationStr.length() - 1)
{
homeDir = new File(locationStr.substring(0, offset));
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -75,6 +75,7 @@
}
@Start
+ @SuppressWarnings("deprecation")
protected void init()
{
this.useRegionBasedMarshalling = configuration.isUseRegionBasedMarshalling();
@@ -204,8 +205,6 @@
// Strip out the buddy group portion
fqn = BuddyFqnTransformer.getActualFqn(fqn);
}
- Region r = regionManager.getRegion(fqn, Region.Type.MARSHALLING, false);
- return r;
- //return r != null && r.isActive() ? r : null;
+ return regionManager.getRegion(fqn, Region.Type.MARSHALLING, false);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -1,6 +1,7 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
@@ -28,6 +29,6 @@
type.equals(Byte.class) || type.equals(Short.class) ||
type.equals(Integer.class) ||
type.equals(Long.class) || type.equals(Float.class) ||
type.equals(Double.class) ||
(type.isArray() && isTypeExcluded(type.getComponentType())) ||
type.equals(Fqn.class) || type.equals(GlobalTransaction.class) ||
type.equals(Address.class) ||
- type.equals(MethodCall.class) || type.equals(MarshalledValue.class);
+ ReplicableCommand.class.isAssignableFrom(type) ||
type.equals(MarshalledValue.class);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-05-08 09:16:18
UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-05-08 10:05:42
UTC (rev 5808)
@@ -13,7 +13,7 @@
* The reason why this is implemented specially in JBoss Cache rather than resorting to
* Java serialization or even the more efficient JBoss serialization is that a lot of
efficiency
* can be gained when a majority of the serialization that occurs has to do with a small
set
- * of known types such as {@link org.jboss.cache.Fqn} or {@link MethodCall}, and class
type information
+ * of known types such as {@link org.jboss.cache.Fqn} or {@link
org.jboss.cache.commands.ReplicableCommand}, and class type information
* can be replaced with simple magic numbers.
* <p/>
* Unknown types (typically user data) falls back to JBoss serialization.
@@ -23,7 +23,7 @@
* information to allow streams to interoperate between different versions of JBoss Cache
(see {@link VersionAwareMarshaller}
* <p/>
* This interface implements the JGroups building-block interface {@link
org.jgroups.blocks.RpcDispatcher.Marshaller} which
- * is used to marshall {@link MethodCall}s, their parameters and their response values.
+ * is used to marshall {@link org.jboss.cache.commands.ReplicableCommand}s, their
parameters and their response values.
* <p/>
* The interface is also used by the {@link org.jboss.cache.loader.CacheLoader} framework
to efficiently serialize data to be persisted, as well as
* the {@link org.jboss.cache.statetransfer.StateTransferManager} when serializing the
cache for transferring state en-masse.
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-05-08 09:16:18
UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-05-08 10:05:42
UTC (rev 5808)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.marshall;
-import org.apache.commons.logging.LogFactory;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -31,7 +30,6 @@
@Deprecated
public class MethodCall extends org.jgroups.blocks.MethodCall
{
- private static boolean trace = LogFactory.getLog(MethodCall.class).isTraceEnabled();
/**
* It's unclear why this class would be serialized.
*/
@@ -99,7 +97,7 @@
ret.append("; Args: (");
if (args != null && args.length > 0)
{
- if (trace)
+ if (log.isTraceEnabled())
{
boolean first = true;
for (Object arg : args)
Modified:
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -130,7 +130,7 @@
public byte[] getState()
{
MarshalledValueOutputStream out = null;
- byte[] result = null;
+ byte[] result;
ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
try
{
@@ -184,7 +184,7 @@
{
MarshalledValueOutputStream out = null;
String sourceRoot = state_id;
- byte[] result = null;
+ byte[] result;
boolean hasDifferentSourceAndIntegrationRoots =
state_id.indexOf(StateTransferManager.PARTIAL_STATE_DELIMITER) > 0;
if (hasDifferentSourceAndIntegrationRoots)
Modified:
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -278,27 +278,15 @@
}
}
+ @SuppressWarnings("unchecked")
private List<NodeData> readNodesAsList(ObjectInputStream in) throws Exception
{
Object obj = cache.getMarshaller().objectFromObjectStream(in);
if (obj instanceof NodeDataMarker) return null;
- List list = (List) obj;
- return list;
+ return (List<NodeData>) obj;
}
-// private NodeData readNode(ObjectInputStream in) throws IOException,
ClassNotFoundException
-// {
-// NodeData nd = (NodeData) in.readObject();
-// if (nd != null && nd.isExceptionMarker())
-// {
-// NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
-// throw new CacheException("State provider node " +
ndem.getCacheNodeIdentity()
-// + " threw exception during loadState", ndem.getCause());
-// }
-// return nd;
-// }
-
private NodeData integrateStateTransferChildren(NodeSPI parent, int offset,
Iterator<NodeData> nodeDataIterator)
throws IOException, ClassNotFoundException
{
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -17,7 +17,6 @@
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.marshall.MethodCall;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
@@ -65,7 +64,7 @@
private boolean forceSyncReplication = false;
/**
- * List<MethodCall> of modifications ({@link MethodCall}). They will be
replicated on TX commit
+ * List<ReversibleCommand> of modifications ({@link ReversibleCommand}).
They will be replicated on TX commit
*/
private final List<ReversibleCommand> modificationList = new
LinkedList<ReversibleCommand>();
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-05-08
09:16:18 UTC (rev 5807)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -272,7 +272,7 @@
if (entry != null)
entry.releaseAllLocksLIFO(gtx);
else
- log.error("No transaction entry present!!", new Throwable());
+ log.error("No transaction entry present!!");
}
@@ -411,7 +411,7 @@
public static boolean isActive(Transaction tx)
{
if (tx == null) return false;
- int status = -1;
+ int status;
try
{
status = tx.getStatus();
@@ -429,7 +429,7 @@
public static boolean isPreparing(Transaction tx)
{
if (tx == null) return false;
- int status = -1;
+ int status;
try
{
status = tx.getStatus();
Modified: core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-05-08
09:16:18 UTC (rev 5807)
+++
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-05-08
10:05:42 UTC (rev 5808)
@@ -53,7 +53,7 @@
expectedList.add(pessimisticInterceptor);
expectedList.add(callInterceptor);
- assert chain.getInterceptorsAsList().equals(expectedList);
+ assert chain.asList().equals(expectedList);
}
public void testAddAtPosition() throws Throwable