You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by il...@apache.org on 2011/08/02 17:19:56 UTC
svn commit: r1153162 - in /cocoon/cocoon3/trunk:
cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/
cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/
Author: ilgrosso
Date: Tue Aug 2 15:19:55 2011
New Revision: 1153162
URL: http://svn.apache.org/viewvc?rev=1153162&view=rev
Log:
Fixing some critical findbugs stuff
Modified:
cocoon/cocoon3/trunk/cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/ServletServiceMonitorInitializer.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
Modified: cocoon/cocoon3/trunk/cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/ServletServiceMonitorInitializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/ServletServiceMonitorInitializer.java?rev=1153162&r1=1153161&r2=1153162&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/ServletServiceMonitorInitializer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/servletservice/ServletServiceMonitorInitializer.java Tue Aug 2 15:19:55 2011
@@ -21,13 +21,11 @@ package org.apache.cocoon.monitoring.ser
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
-
import org.apache.cocoon.servletservice.ServletServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,50 +33,54 @@ import org.springframework.jmx.export.MB
public class ServletServiceMonitorInitializer {
- private static final Log LOG = LogFactory.getLog(ServletServiceMonitorInitializer.class);
+ private static final Log LOG = LogFactory.getLog(
+ ServletServiceMonitorInitializer.class);
- public ServletServiceMonitorInitializer(Map<String, Servlet> servlets, MBeanExporter exporter) {
- List<String> servletNames = new ArrayList<String>();
+ public ServletServiceMonitorInitializer(final Map<String, Servlet> servlets,
+ final MBeanExporter exporter) {
+
+ final List<String> servletNames = new ArrayList<String>();
+ ServletConfig servletConfig;
+ ServletContext servletContext;
+ String servletName;
+ ServletServiceContext ssContext;
+ ObjectName name;
+ String stringName;
+ ServletServiceMonitor ssMonitor;
for (Servlet servlet : servlets.values()) {
- ServletConfig servletConfig = servlet.getServletConfig();
+ servletConfig = servlet.getServletConfig();
// get only ServletServices servlets
- ServletContext servletContext = servletConfig.getServletContext();
- String servletName = servletConfig.getServletName();
+ servletContext = servletConfig.getServletContext();
+ servletName = servletConfig.getServletName();
if (!(servletContext instanceof ServletServiceContext)) {
- LOG.info(servletName + " isn't Servlet-Service servlet, it will be ignored.");
+ LOG.info(servletName
+ + " isn't Servlet-Service servlet, it will be ignored.");
continue;
}
- ServletServiceContext servletServiceContext = (ServletServiceContext) servletContext;
- ObjectName name = null;
- String stringName = "org.apache.cocoon:group=ServletServices,name=["
- + this.getMountPath(servletServiceContext) + "] " + servletName;
+ ssContext = (ServletServiceContext) servletContext;
+ stringName = "org.apache.cocoon:group=ServletServices,name=["
+ + this.getMountPath(ssContext) + "] "
+ + servletName;
try {
name = new ObjectName(stringName);
} catch (MalformedObjectNameException e) {
- LOG.error("The string passed as a parameter does not have the right format.", e);
- continue;
- } catch (NullPointerException e) {
- LOG.fatal("Should never happened. Value of name parameter always is different than null.", e);
- continue;
- }
-
- if (name == null) {
- LOG.error("ObjectName is null, something strange happen. Should never happen.");
+ LOG.error("The string passed as a parameter "
+ + "does not have the right format.", e);
continue;
}
- ServletServiceMonitor servletServiceMonitor = new ServletServiceMonitor(servlet);
+ ssMonitor = new ServletServiceMonitor(servlet);
if (!servletNames.contains(stringName)) {
- exporter.registerManagedResource(servletServiceMonitor, name);
+ exporter.registerManagedResource(ssMonitor, name);
servletNames.add(stringName);
}
}
}
- private String getMountPath(ServletServiceContext servletServiceContext) {
- String mountPath = servletServiceContext.getMountPath();
+ private String getMountPath(final ServletServiceContext ssContext) {
+ final String mountPath = ssContext.getMountPath();
if (mountPath != null && !mountPath.startsWith("/")) {
return "/" + mountPath;
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java?rev=1153162&r1=1153161&r2=1153162&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompoundCacheKey.java Tue Aug 2 15:19:55 2011
@@ -35,12 +35,12 @@ public class CompoundCacheKey extends Ab
private final List<CacheKey> cacheKeys = new LinkedList<CacheKey>();
- public void addCacheKey(CacheKey cacheKey) {
+ public void addCacheKey(final CacheKey cacheKey) {
this.cacheKeys.add(cacheKey);
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (LOG.isDebugEnabled()) {
LOG.debug("Comparing two cache keys: ");
LOG.debug(" this=" + this);
@@ -51,7 +51,7 @@ public class CompoundCacheKey extends Ab
return false;
}
- CompoundCacheKey other = (CompoundCacheKey) obj;
+ final CompoundCacheKey other = (CompoundCacheKey) obj;
if (this.cacheKeys.size() != other.cacheKeys.size()) {
return false;
}
@@ -78,14 +78,13 @@ public class CompoundCacheKey extends Ab
@Override
public int hashCode() {
- MurmurHashCodeBuilder murmurHashCodeBuilder =
- new MurmurHashCodeBuilder();
+ final MurmurHashCodeBuilder hashCodeBuild = new MurmurHashCodeBuilder();
for (CacheKey cacheKey : this.cacheKeys) {
- murmurHashCodeBuilder.append(cacheKey.hashCode());
+ hashCodeBuild.append(cacheKey.hashCode());
}
- return murmurHashCodeBuilder.toHashCode();
+ return hashCodeBuild.toHashCode();
}
/**
@@ -95,7 +94,7 @@ public class CompoundCacheKey extends Ab
*/
@Override
public boolean isValid(final CacheKey cacheKey) {
- if (!this.equals(cacheKey)) {
+ if (!(cacheKey instanceof CompoundCacheKey) || !this.equals(cacheKey)) {
return false;
}
@@ -103,9 +102,11 @@ public class CompoundCacheKey extends Ab
final Iterator<CacheKey> myIterator = this.cacheKeys.iterator();
final Iterator<CacheKey> otherIterator = other.cacheKeys.iterator();
+ CacheKey myCacheKey;
+ CacheKey otherCacheKey;
while (myIterator.hasNext()) {
- CacheKey myCacheKey = myIterator.next();
- CacheKey otherCacheKey = otherIterator.next();
+ myCacheKey = myIterator.next();
+ otherCacheKey = otherIterator.next();
if (!myCacheKey.isValid(otherCacheKey)) {
if (LOG.isDebugEnabled()) {
@@ -123,8 +124,9 @@ public class CompoundCacheKey extends Ab
public long getLastModified() {
long lastModified = 0;
+ long eachLastModified;
for (CacheKey eachKey : this.cacheKeys) {
- long eachLastModified = eachKey.getLastModified();
+ eachLastModified = eachKey.getLastModified();
if (eachLastModified == -1) {
return -1;
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java?rev=1153162&r1=1153161&r2=1153162&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java Tue Aug 2 15:19:55 2011
@@ -33,7 +33,7 @@ public class TimestampCacheKey extends A
private final URL url;
- public TimestampCacheKey(URL url, long timestamp) {
+ public TimestampCacheKey(final URL url, final long timestamp) {
super();
this.url = url;
@@ -41,7 +41,7 @@ public class TimestampCacheKey extends A
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (!(obj instanceof TimestampCacheKey)) {
return false;
}
@@ -66,7 +66,9 @@ public class TimestampCacheKey extends A
@Override
public boolean isValid(final CacheKey cacheKey) {
- if (!this.equals(cacheKey)) {
+ if (!(cacheKey instanceof TimestampCacheKey)
+ || !this.equals(cacheKey)) {
+
return false;
}