This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 513a158 Code clean-up. Add braces for clarity.
513a158 is described below
commit 513a158ee793b52cc1c0fac7780423760818b631
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 25 09:15:13 2021 +0100
Code clean-up. Add braces for clarity.
---
.../apache/catalina/core/ApplicationContext.java | 22 +-
.../catalina/core/ApplicationFilterChain.java | 15 +-
.../catalina/core/ApplicationFilterConfig.java | 6 +-
.../catalina/core/ApplicationFilterFactory.java | 27 ++-
.../catalina/core/ApplicationHttpRequest.java | 27 ++-
.../catalina/core/ApplicationHttpResponse.java | 54 +++--
.../apache/catalina/core/ApplicationRequest.java | 9 +-
.../apache/catalina/core/ApplicationResponse.java | 18 +-
.../org/apache/catalina/core/AsyncContextImpl.java | 4 +-
java/org/apache/catalina/core/ContainerBase.java | 42 ++--
.../catalina/core/NamingContextListener.java | 28 ++-
java/org/apache/catalina/core/StandardContext.java | 245 ++++++++++++++-------
java/org/apache/catalina/core/StandardEngine.java | 18 +-
java/org/apache/catalina/core/StandardHost.java | 18 +-
.../org/apache/catalina/core/StandardPipeline.java | 22 +-
java/org/apache/catalina/core/StandardServer.java | 15 +-
java/org/apache/catalina/core/StandardService.java | 18 +-
.../catalina/core/StandardThreadExecutor.java | 3 +-
java/org/apache/catalina/core/StandardWrapper.java | 54 +++--
.../apache/catalina/core/StandardWrapperValve.java | 12 +-
.../core/ThreadLocalLeakPreventionListener.java | 4 +-
java/org/apache/catalina/ha/ClusterListener.java | 13 +-
.../apache/catalina/ha/backend/CollectedInfo.java | 11 +-
.../catalina/ha/backend/HeartbeatListener.java | 5 +-
.../catalina/ha/backend/MultiCastSender.java | 3 +-
java/org/apache/catalina/ha/backend/TcpSender.java | 7 +-
.../catalina/ha/context/ReplicatedContext.java | 14 +-
.../apache/catalina/ha/deploy/FarmWarDeployer.java | 79 ++++---
.../catalina/ha/deploy/FileMessageFactory.java | 15 +-
java/org/apache/catalina/ha/deploy/WarWatcher.java | 18 +-
.../apache/catalina/ha/session/BackupManager.java | 15 +-
.../catalina/ha/session/ClusterManagerBase.java | 14 +-
.../ha/session/ClusterSessionListener.java | 10 +-
.../apache/catalina/ha/session/DeltaManager.java | 45 ++--
.../apache/catalina/ha/session/DeltaRequest.java | 44 ++--
.../apache/catalina/ha/session/DeltaSession.java | 45 ++--
.../apache/catalina/ha/tcp/SimpleTcpCluster.java | 82 +++++--
37 files changed, 734 insertions(+), 347 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationContext.java
b/java/org/apache/catalina/core/ApplicationContext.java
index 5085f91..3eebb1e 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -330,14 +330,17 @@ public class ApplicationContext implements ServletContext
{
@Override
public String getMimeType(String file) {
- if (file == null)
+ if (file == null) {
return null;
+ }
int period = file.lastIndexOf('.');
- if (period < 0)
+ if (period < 0) {
return null;
+ }
String extension = file.substring(period + 1);
- if (extension.length() < 1)
+ if (extension.length() < 1) {
return null;
+ }
return context.findMimeMapping(extension);
}
@@ -353,13 +356,15 @@ public class ApplicationContext implements ServletContext
{
public RequestDispatcher getNamedDispatcher(String name) {
// Validate the name argument
- if (name == null)
+ if (name == null) {
return null;
+ }
// Create and return a corresponding request dispatcher
Wrapper wrapper = (Wrapper) context.findChild(name);
- if (wrapper == null)
+ if (wrapper == null) {
return null;
+ }
return new ApplicationDispatcher(wrapper, null, null, null, null,
null, name);
@@ -1134,7 +1139,9 @@ public class ApplicationContext implements ServletContext
{
match = true;
}
- if (match) return;
+ if (match) {
+ return;
+ }
if (t instanceof ServletContextListener) {
throw new IllegalArgumentException(sm.getString(
@@ -1369,8 +1376,9 @@ public class ApplicationContext implements ServletContext
{
*/
void setAttributeReadOnly(String name) {
- if (attributes.containsKey(name))
+ if (attributes.containsKey(name)) {
readOnlyAttributes.put(name, name);
+ }
}
diff --git a/java/org/apache/catalina/core/ApplicationFilterChain.java
b/java/org/apache/catalina/core/ApplicationFilterChain.java
index f9e69ec..c323064 100644
--- a/java/org/apache/catalina/core/ApplicationFilterChain.java
+++ b/java/org/apache/catalina/core/ApplicationFilterChain.java
@@ -145,14 +145,15 @@ public final class ApplicationFilterChain implements
FilterChain {
);
} catch( PrivilegedActionException pe) {
Exception e = pe.getException();
- if (e instanceof ServletException)
+ if (e instanceof ServletException) {
throw (ServletException) e;
- else if (e instanceof IOException)
+ } else if (e instanceof IOException) {
throw (IOException) e;
- else if (e instanceof RuntimeException)
+ } else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
- else
+ } else {
throw new ServletException(e.getMessage(), e);
+ }
}
} else {
internalDoFilter(request,response);
@@ -269,9 +270,11 @@ public final class ApplicationFilterChain implements
FilterChain {
void addFilter(ApplicationFilterConfig filterConfig) {
// Prevent the same filter being added multiple times
- for(ApplicationFilterConfig filter:filters)
- if(filter==filterConfig)
+ for(ApplicationFilterConfig filter:filters) {
+ if(filter==filterConfig) {
return;
+ }
+ }
if (n == filters.length) {
ApplicationFilterConfig[] newFilters =
diff --git a/java/org/apache/catalina/core/ApplicationFilterConfig.java
b/java/org/apache/catalina/core/ApplicationFilterConfig.java
index e4fec4f..33ec91d 100644
--- a/java/org/apache/catalina/core/ApplicationFilterConfig.java
+++ b/java/org/apache/catalina/core/ApplicationFilterConfig.java
@@ -242,8 +242,9 @@ public final class ApplicationFilterConfig implements
FilterConfig, Serializable
NamingException, IllegalArgumentException, SecurityException {
// Return the existing filter instance, if any
- if (this.filter != null)
+ if (this.filter != null) {
return this.filter;
+ }
// Identify the class loader we will be using
String filterClass = filterDef.getFilterClass();
@@ -371,9 +372,10 @@ public final class ApplicationFilterConfig implements
FilterConfig, Serializable
if (oname != null) {
try {
Registry.getRegistry(null, null).unregisterComponent(oname);
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("applicationFilterConfig.jmxUnregister",
getFilterClass(), getFilterName()));
+ }
} catch(Exception ex) {
log.warn(sm.getString("applicationFilterConfig.jmxUnregisterFail",
getFilterClass(), getFilterName()), ex);
diff --git a/java/org/apache/catalina/core/ApplicationFilterFactory.java
b/java/org/apache/catalina/core/ApplicationFilterFactory.java
index 7883213..62bae04 100644
--- a/java/org/apache/catalina/core/ApplicationFilterFactory.java
+++ b/java/org/apache/catalina/core/ApplicationFilterFactory.java
@@ -54,8 +54,9 @@ public final class ApplicationFilterFactory {
Wrapper wrapper, Servlet servlet) {
// If there is no servlet to execute, return null
- if (servlet == null)
+ if (servlet == null) {
return null;
+ }
// Create and initialize a filter chain object
ApplicationFilterChain filterChain = null;
@@ -85,8 +86,9 @@ public final class ApplicationFilterFactory {
FilterMap filterMaps[] = context.findFilterMaps();
// If there are no filter mappings, we are done
- if ((filterMaps == null) || (filterMaps.length == 0))
+ if ((filterMaps == null) || (filterMaps.length == 0)) {
return filterChain;
+ }
// Acquire the information we will need to match filter mappings
DispatcherType dispatcher =
@@ -105,8 +107,9 @@ public final class ApplicationFilterFactory {
if (!matchDispatcher(filterMap, dispatcher)) {
continue;
}
- if (!matchFiltersURL(filterMap, requestPath))
+ if (!matchFiltersURL(filterMap, requestPath)) {
continue;
+ }
ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
context.findFilterConfig(filterMap.getFilterName());
if (filterConfig == null) {
@@ -121,8 +124,9 @@ public final class ApplicationFilterFactory {
if (!matchDispatcher(filterMap, dispatcher)) {
continue;
}
- if (!matchFiltersServlet(filterMap, servletName))
+ if (!matchFiltersServlet(filterMap, servletName)) {
continue;
+ }
ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
context.findFilterConfig(filterMap.getFilterName());
if (filterConfig == null) {
@@ -152,11 +156,13 @@ public final class ApplicationFilterFactory {
// Check the specific "*" special URL pattern, which also matches
// named dispatches
- if (filterMap.getMatchAllUrlPatterns())
+ if (filterMap.getMatchAllUrlPatterns()) {
return true;
+ }
- if (requestPath == null)
+ if (requestPath == null) {
return false;
+ }
// Match on context relative request path
String[] testPaths = filterMap.getURLPatterns();
@@ -183,16 +189,19 @@ public final class ApplicationFilterFactory {
*/
private static boolean matchFiltersURL(String testPath, String
requestPath) {
- if (testPath == null)
+ if (testPath == null) {
return false;
+ }
// Case 1 - Exact Match
- if (testPath.equals(requestPath))
+ if (testPath.equals(requestPath)) {
return true;
+ }
// Case 2 - Path Match ("/.../*")
- if (testPath.equals("/*"))
+ if (testPath.equals("/*")) {
return true;
+ }
if (testPath.endsWith("/*")) {
if (testPath.regionMatches(0, requestPath, 0,
testPath.length() - 2)) {
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java
b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 70498be..8279f94 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -279,8 +279,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
@Override
public void removeAttribute(String name) {
- if (!removeSpecial(name))
+ if (!removeSpecial(name)) {
getRequest().removeAttribute(name);
+ }
}
@@ -319,8 +320,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
@Override
public RequestDispatcher getRequestDispatcher(String path) {
- if (context == null)
+ if (context == null) {
return null;
+ }
if (path == null) {
return null;
@@ -340,8 +342,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// Convert a request-relative path to a context-relative one
String servletPath =
(String) getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
- if (servletPath == null)
+ if (servletPath == null) {
servletPath = getServletPath();
+ }
// Add the path info, if there is any
String pathInfo = getPathInfo();
@@ -541,8 +544,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
if (crossContext) {
// There cannot be a session if no context has been assigned yet
- if (context == null)
+ if (context == null) {
return null;
+ }
// Return the current session if it exists and is valid
if (session != null && session.isValid()) {
@@ -599,13 +603,16 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
if (crossContext) {
String requestedSessionId = getRequestedSessionId();
- if (requestedSessionId == null)
+ if (requestedSessionId == null) {
return false;
- if (context == null)
+ }
+ if (context == null) {
return false;
+ }
Manager manager = context.getManager();
- if (manager == null)
+ if (manager == null) {
return false;
+ }
Session session = null;
try {
session = manager.findSession(requestedSessionId);
@@ -781,8 +788,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
protected boolean isSpecial(String name) {
for (String special : specials) {
- if (special.equals(name))
+ if (special.equals(name)) {
return true;
+ }
}
return false;
@@ -875,8 +883,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
*/
private void mergeParameters() {
- if ((queryParamString == null) || (queryParamString.length() < 1))
+ if ((queryParamString == null) || (queryParamString.length() < 1)) {
return;
+ }
// Parse the query string from the dispatch target
Parameters paramParser = new Parameters();
diff --git a/java/org/apache/catalina/core/ApplicationHttpResponse.java
b/java/org/apache/catalina/core/ApplicationHttpResponse.java
index c9b76c7..08b1ffb 100644
--- a/java/org/apache/catalina/core/ApplicationHttpResponse.java
+++ b/java/org/apache/catalina/core/ApplicationHttpResponse.java
@@ -80,8 +80,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
public void reset() {
// If already committed, the wrapped response will throw ISE
- if (!included || getResponse().isCommitted())
+ if (!included || getResponse().isCommitted()) {
getResponse().reset();
+ }
}
@@ -95,8 +96,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setContentLength(int len) {
- if (!included)
+ if (!included) {
getResponse().setContentLength(len);
+ }
}
@@ -110,8 +112,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setContentLengthLong(long len) {
- if (!included)
+ if (!included) {
getResponse().setContentLengthLong(len);
+ }
}
@@ -124,8 +127,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setContentType(String type) {
- if (!included)
+ if (!included) {
getResponse().setContentType(type);
+ }
}
@@ -138,8 +142,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setLocale(Locale loc) {
- if (!included)
+ if (!included) {
getResponse().setLocale(loc);
+ }
}
@@ -151,8 +156,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
*/
@Override
public void setBufferSize(int size) {
- if (!included)
+ if (!included) {
getResponse().setBufferSize(size);
+ }
}
@@ -167,8 +173,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void addCookie(Cookie cookie) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).addCookie(cookie);
+ }
}
@@ -182,8 +189,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void addDateHeader(String name, long value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).addDateHeader(name, value);
+ }
}
@@ -197,8 +205,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void addHeader(String name, String value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).addHeader(name, value);
+ }
}
@@ -212,8 +221,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void addIntHeader(String name, int value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).addIntHeader(name, value);
+ }
}
@@ -228,8 +238,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void sendError(int sc) throws IOException {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).sendError(sc);
+ }
}
@@ -245,8 +256,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void sendError(int sc, String msg) throws IOException {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).sendError(sc, msg);
+ }
}
@@ -261,8 +273,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void sendRedirect(String location) throws IOException {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).sendRedirect(location);
+ }
}
@@ -276,8 +289,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setDateHeader(String name, long value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).setDateHeader(name, value);
+ }
}
@@ -291,8 +305,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setHeader(String name, String value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).setHeader(name, value);
+ }
}
@@ -306,8 +321,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setIntHeader(String name, int value) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).setIntHeader(name, value);
+ }
}
@@ -320,8 +336,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setStatus(int sc) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).setStatus(sc);
+ }
}
@@ -340,8 +357,9 @@ class ApplicationHttpResponse extends
HttpServletResponseWrapper {
@Override
public void setStatus(int sc, String msg) {
- if (!included)
+ if (!included) {
((HttpServletResponse) getResponse()).setStatus(sc, msg);
+ }
}
diff --git a/java/org/apache/catalina/core/ApplicationRequest.java
b/java/org/apache/catalina/core/ApplicationRequest.java
index b44506c..cfdb891 100644
--- a/java/org/apache/catalina/core/ApplicationRequest.java
+++ b/java/org/apache/catalina/core/ApplicationRequest.java
@@ -135,8 +135,9 @@ class ApplicationRequest extends ServletRequestWrapper {
synchronized (attributes) {
attributes.remove(name);
- if (!isSpecial(name))
+ if (!isSpecial(name)) {
getRequest().removeAttribute(name);
+ }
}
}
@@ -154,8 +155,9 @@ class ApplicationRequest extends ServletRequestWrapper {
synchronized (attributes) {
attributes.put(name, value);
- if (!isSpecial(name))
+ if (!isSpecial(name)) {
getRequest().setAttribute(name, value);
+ }
}
}
@@ -200,8 +202,9 @@ class ApplicationRequest extends ServletRequestWrapper {
protected boolean isSpecial(String name) {
for (String special : specials) {
- if (special.equals(name))
+ if (special.equals(name)) {
return true;
+ }
}
return false;
diff --git a/java/org/apache/catalina/core/ApplicationResponse.java
b/java/org/apache/catalina/core/ApplicationResponse.java
index 9157b34..8ecfe03 100644
--- a/java/org/apache/catalina/core/ApplicationResponse.java
+++ b/java/org/apache/catalina/core/ApplicationResponse.java
@@ -78,8 +78,9 @@ class ApplicationResponse extends ServletResponseWrapper {
public void reset() {
// If already committed, the wrapped response will throw ISE
- if (!included || getResponse().isCommitted())
+ if (!included || getResponse().isCommitted()) {
getResponse().reset();
+ }
}
@@ -93,8 +94,9 @@ class ApplicationResponse extends ServletResponseWrapper {
@Override
public void setContentLength(int len) {
- if (!included)
+ if (!included) {
getResponse().setContentLength(len);
+ }
}
@@ -108,8 +110,9 @@ class ApplicationResponse extends ServletResponseWrapper {
@Override
public void setContentLengthLong(long len) {
- if (!included)
+ if (!included) {
getResponse().setContentLengthLong(len);
+ }
}
@@ -122,8 +125,9 @@ class ApplicationResponse extends ServletResponseWrapper {
@Override
public void setContentType(String type) {
- if (!included)
+ if (!included) {
getResponse().setContentType(type);
+ }
}
@@ -135,8 +139,9 @@ class ApplicationResponse extends ServletResponseWrapper {
*/
@Override
public void setLocale(Locale loc) {
- if (!included)
+ if (!included) {
getResponse().setLocale(loc);
+ }
}
@@ -147,8 +152,9 @@ class ApplicationResponse extends ServletResponseWrapper {
*/
@Override
public void setBufferSize(int size) {
- if (!included)
+ if (!included) {
getResponse().setBufferSize(size);
+ }
}
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java
b/java/org/apache/catalina/core/AsyncContextImpl.java
index b332922..ad01ce4 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -397,7 +397,9 @@ public class AsyncContextImpl implements AsyncContext,
AsyncContextCallback {
public void setErrorState(Throwable t, boolean fireOnError) {
- if (t!=null) request.setAttribute(RequestDispatcher.ERROR_EXCEPTION,
t);
+ if (t!=null) {
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
+ }
request.getCoyoteRequest().action(ActionCode.ASYNC_ERROR, null);
if (fireOnError) {
diff --git a/java/org/apache/catalina/core/ContainerBase.java
b/java/org/apache/catalina/core/ContainerBase.java
index 69620a1..d7d6bac 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -325,8 +325,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
*/
@Override
public Log getLogger() {
- if (logger != null)
+ if (logger != null) {
return logger;
+ }
logger = LogFactory.getLog(getLogName());
return logger;
}
@@ -370,11 +371,13 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
Lock readLock = clusterLock.readLock();
readLock.lock();
try {
- if (cluster != null)
+ if (cluster != null) {
return cluster;
+ }
- if (parent != null)
+ if (parent != null) {
return parent.getCluster();
+ }
return null;
} finally {
@@ -411,8 +414,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
try {
// Change components if necessary
oldCluster = this.cluster;
- if (oldCluster == cluster)
+ if (oldCluster == cluster) {
return;
+ }
this.cluster = cluster;
// Stop the old component if necessary
@@ -426,8 +430,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
}
// Start the new component if necessary
- if (cluster != null)
+ if (cluster != null) {
cluster.setContainer(this);
+ }
if (getState().isAvailable() && (cluster != null) &&
(cluster instanceof Lifecycle)) {
@@ -542,8 +547,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
*/
@Override
public ClassLoader getParentClassLoader() {
- if (parentClassLoader != null)
+ if (parentClassLoader != null) {
return parentClassLoader;
+ }
if (parent != null) {
return parent.getParentClassLoader();
}
@@ -591,10 +597,12 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
Lock l = realmLock.readLock();
l.lock();
try {
- if (realm != null)
+ if (realm != null) {
return realm;
- if (parent != null)
+ }
+ if (parent != null) {
return parent.getRealm();
+ }
return null;
} finally {
l.unlock();
@@ -625,8 +633,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
try {
// Change components if necessary
Realm oldRealm = this.realm;
- if (oldRealm == realm)
+ if (oldRealm == realm) {
return;
+ }
this.realm = realm;
// Stop the old component if necessary
@@ -640,8 +649,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
}
// Start the new component if necessary
- if (realm != null)
+ if (realm != null) {
realm.setContainer(this);
+ }
if (getState().isAvailable() && (realm != null) &&
(realm instanceof Lifecycle)) {
try {
@@ -698,9 +708,10 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
}
synchronized(children) {
- if (children.get(child.getName()) != null)
+ if (children.get(child.getName()) != null) {
throw new IllegalArgumentException(
sm.getString("containerBase.child.notUnique",
child.getName()));
+ }
child.setParent(this); // May throw IAE
children.put(child.getName(), child);
}
@@ -826,8 +837,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
}
synchronized(children) {
- if (children.get(child.getName()) == null)
+ if (children.get(child.getName()) == null) {
return;
+ }
children.remove(child.getName());
}
@@ -1119,8 +1131,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
@Override
public void backgroundProcess() {
- if (!getState().isAvailable())
+ if (!getState().isAvailable()) {
return;
+ }
Cluster cluster = getClusterInternal();
if (cluster != null) {
@@ -1187,8 +1200,9 @@ public abstract class ContainerBase extends
LifecycleMBeanBase
@Override
public void fireContainerEvent(String type, Object data) {
- if (listeners.size() < 1)
+ if (listeners.size() < 1) {
return;
+ }
ContainerEvent event = new ContainerEvent(this, type, data);
// Note for each uses an iterator internally so this is safe
diff --git a/java/org/apache/catalina/core/NamingContextListener.java
b/java/org/apache/catalina/core/NamingContextListener.java
index b0a5009..96c560a 100644
--- a/java/org/apache/catalina/core/NamingContextListener.java
+++ b/java/org/apache/catalina/core/NamingContextListener.java
@@ -226,8 +226,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType())) {
- if (initialized)
+ if (initialized) {
return;
+ }
try {
Hashtable<String, Object> contextEnv = new Hashtable<>();
@@ -289,8 +290,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
} else if (Lifecycle.CONFIGURE_STOP_EVENT.equals(event.getType())) {
- if (!initialized)
+ if (!initialized) {
return;
+ }
try {
// Setting the context in read/write mode
@@ -350,8 +352,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (!initialized)
+ if (!initialized) {
return;
+ }
Object source = event.getSource();
if (source == namingResources) {
@@ -515,8 +518,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
int i;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Creating JNDI naming context");
+ }
if (namingResources == null) {
namingResources = new NamingResourcesImpl();
@@ -632,8 +636,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
",name=" + quotedResourceName);
} else if (container instanceof Context) {
String contextName = ((Context)container).getName();
- if (!contextName.startsWith("/"))
+ if (!contextName.startsWith("/")) {
contextName = "/" + contextName;
+ }
Host host = (Host) ((Context)container).getParent();
name = new ObjectName(domain + ":type=DataSource" +
",host=" + host.getName() +
@@ -857,10 +862,11 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
log.error(sm.getString("naming.wsdlFailed", e));
}
}
- if (wsdlURL == null)
+ if (wsdlURL == null) {
service.setWsdlfile(null);
- else
+ } else {
service.setWsdlfile(wsdlURL.toString());
+ }
}
if (service.getJaxrpcmappingfile() != null) {
@@ -889,10 +895,11 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
log.error(sm.getString("naming.wsdlFailed", e));
}
}
- if (jaxrpcURL == null)
+ if (jaxrpcURL == null) {
service.setJaxrpcmappingfile(null);
- else
+ } else {
service.setJaxrpcmappingfile(jaxrpcURL.toString());
+ }
}
// Create a reference to the resource.
@@ -1063,8 +1070,9 @@ public class NamingContextListener implements
LifecycleListener, PropertyChangeL
"UserTransaction".equals(resourceLink.getName())
? compCtx : envCtx;
try {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(" Adding resource link " + resourceLink.getName());
+ }
createSubcontexts(envCtx, resourceLink.getName());
ctx.bind(resourceLink.getName(), ref);
} catch (NamingException e) {
diff --git a/java/org/apache/catalina/core/StandardContext.java
b/java/org/apache/catalina/core/StandardContext.java
index 4256193..a12ed93 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -1205,8 +1205,9 @@ public class StandardContext extends ContainerBase
Pipeline pipeline = getPipeline();
if (pipeline != null) {
Valve basic = pipeline.getBasic();
- if (basic instanceof Authenticator)
+ if (basic instanceof Authenticator) {
return (Authenticator) basic;
+ }
for (Valve valve : pipeline.getValves()) {
if (valve instanceof Authenticator) {
return (Authenticator) valve;
@@ -1515,8 +1516,9 @@ public class StandardContext extends ContainerBase
CharsetMapper oldCharsetMapper = this.charsetMapper;
this.charsetMapper = mapper;
- if( mapper != null )
+ if( mapper != null ) {
this.charsetMapperClass= mapper.getClass().getName();
+ }
support.firePropertyChange("charsetMapper", oldCharsetMapper,
this.charsetMapper);
@@ -1920,8 +1922,9 @@ public class StandardContext extends ContainerBase
try {
// Change components if necessary
oldLoader = this.loader;
- if (oldLoader == loader)
+ if (oldLoader == loader) {
return;
+ }
this.loader = loader;
// Stop the old component if necessary
@@ -1935,8 +1938,9 @@ public class StandardContext extends ContainerBase
}
// Start the new component if necessary
- if (loader != null)
+ if (loader != null) {
loader.setContext(this);
+ }
if (getState().isAvailable() && (loader != null) &&
(loader instanceof Lifecycle)) {
try {
@@ -1975,8 +1979,9 @@ public class StandardContext extends ContainerBase
try {
// Change components if necessary
oldManager = this.manager;
- if (oldManager == manager)
+ if (oldManager == manager) {
return;
+ }
this.manager = manager;
// Stop the old component if necessary
@@ -2051,15 +2056,17 @@ public class StandardContext extends ContainerBase
public void setLoginConfig(LoginConfig config) {
// Validate the incoming property value
- if (config == null)
+ if (config == null) {
throw new IllegalArgumentException
(sm.getString("standardContext.loginConfig.required"));
+ }
String loginPage = config.getLoginPage();
if ((loginPage != null) && !loginPage.startsWith("/")) {
if (isServlet22()) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("standardContext.loginConfig.loginWarning",
loginPage));
+ }
config.setLoginPage("/" + loginPage);
} else {
throw new IllegalArgumentException
@@ -2070,9 +2077,10 @@ public class StandardContext extends ContainerBase
String errorPage = config.getErrorPage();
if ((errorPage != null) && !errorPage.startsWith("/")) {
if (isServlet22()) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("standardContext.loginConfig.errorWarning",
errorPage));
+ }
config.setErrorPage("/" + errorPage);
} else {
throw new IllegalArgumentException
@@ -2214,9 +2222,10 @@ public class StandardContext extends ContainerBase
@Override
public void setPublicId(String publicId) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Setting deployment descriptor public ID to '" +
publicId + "'");
+ }
String oldPublicId = this.publicId;
this.publicId = publicId;
@@ -2271,8 +2280,9 @@ public class StandardContext extends ContainerBase
*/
@Override
public ClassLoader getParentClassLoader() {
- if (parentClassLoader != null)
+ if (parentClassLoader != null) {
return parentClassLoader;
+ }
if (getPrivileged()) {
return this.getClass().getClassLoader();
} else if (parent != null) {
@@ -2365,8 +2375,9 @@ public class StandardContext extends ContainerBase
public ServletContext getServletContext() {
if (context == null) {
context = new ApplicationContext(this);
- if (altDDName != null)
+ if (altDDName != null) {
context.setAttribute(Globals.ALT_DD_ATTR,altDDName);
+ }
}
return context.getFacade();
}
@@ -2563,8 +2574,9 @@ public class StandardContext extends ContainerBase
}
oldResources = this.resources;
- if (oldResources == resources)
+ if (oldResources == resources) {
return;
+ }
this.resources = resources;
if (oldResources != null) {
@@ -2899,8 +2911,9 @@ public class StandardContext extends ContainerBase
synchronized (applicationParametersLock) {
String newName = parameter.getName();
for (ApplicationParameter p : applicationParameters) {
- if (newName.equals(p.getName()) && !p.getOverride())
+ if (newName.equals(p.getName()) && !p.getOverride()) {
return;
+ }
}
ApplicationParameter results[] = Arrays.copyOf(
applicationParameters, applicationParameters.length + 1);
@@ -2971,11 +2984,12 @@ public class StandardContext extends ContainerBase
String patterns[] = collection.findPatterns();
for (int j = 0; j < patterns.length; j++) {
patterns[j] = adjustURLPattern(patterns[j]);
- if (!validateURLPattern(patterns[j]))
+ if (!validateURLPattern(patterns[j])) {
throw new IllegalArgumentException
(sm.getString
("standardContext.securityConstraint.pattern",
patterns[j]));
+ }
}
if (collection.findMethods().length > 0 &&
collection.findOmittedMethods().length > 0) {
@@ -3003,15 +3017,17 @@ public class StandardContext extends ContainerBase
@Override
public void addErrorPage(ErrorPage errorPage) {
// Validate the input parameters
- if (errorPage == null)
+ if (errorPage == null) {
throw new IllegalArgumentException
(sm.getString("standardContext.errorPage.required"));
+ }
String location = errorPage.getLocation();
if ((location != null) && !location.startsWith("/")) {
if (isServlet22()) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("standardContext.errorPage.warning",
location));
+ }
errorPage.setLocation("/" + location);
} else {
throw new IllegalArgumentException
@@ -3089,15 +3105,17 @@ public class StandardContext extends ContainerBase
String filterName = filterMap.getFilterName();
String[] servletNames = filterMap.getServletNames();
String[] urlPatterns = filterMap.getURLPatterns();
- if (findFilterDef(filterName) == null)
+ if (findFilterDef(filterName) == null) {
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.name", filterName));
+ }
if (!filterMap.getMatchAllServletNames() &&
!filterMap.getMatchAllUrlPatterns() &&
- (servletNames.length == 0) && (urlPatterns.length == 0))
+ (servletNames.length == 0) && (urlPatterns.length == 0)) {
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
+ }
for (String urlPattern : urlPatterns) {
if (!validateURLPattern(urlPattern)) {
throw new IllegalArgumentException
@@ -3234,13 +3252,15 @@ public class StandardContext extends ContainerBase
public void addServletMappingDecoded(String pattern, String name,
boolean jspWildCard) {
// Validate the proposed mapping
- if (findChild(name) == null)
+ if (findChild(name) == null) {
throw new IllegalArgumentException
(sm.getString("standardContext.servletMap.name", name));
+ }
String adjustedPattern = adjustURLPattern(pattern);
- if (!validateURLPattern(adjustedPattern))
+ if (!validateURLPattern(adjustedPattern)) {
throw new IllegalArgumentException
(sm.getString("standardContext.servletMap.pattern",
adjustedPattern));
+ }
// Add this mapping to our registered set
synchronized (servletMappingsLock) {
@@ -3296,8 +3316,9 @@ public class StandardContext extends ContainerBase
results[welcomeFiles.length] = name;
welcomeFiles = results;
}
- if(this.getState().equals(LifecycleState.STARTED))
+ if(this.getState().equals(LifecycleState.STARTED)) {
fireContainerEvent(ADD_WELCOME_FILE_EVENT, name);
+ }
}
@@ -3580,10 +3601,11 @@ public class StandardContext extends ContainerBase
synchronized (roleMappings) {
realRole = roleMappings.get(role);
}
- if (realRole != null)
+ if (realRole != null) {
return realRole;
- else
+ } else {
return role;
+ }
}
@@ -3598,8 +3620,9 @@ public class StandardContext extends ContainerBase
synchronized (securityRolesLock) {
for (String securityRole : securityRoles) {
- if (role.equals(securityRole))
+ if (role.equals(securityRole)) {
return true;
+ }
}
}
return false;
@@ -3657,8 +3680,9 @@ public class StandardContext extends ContainerBase
synchronized (welcomeFilesLock) {
for (String welcomeFile : welcomeFiles) {
- if (name.equals(welcomeFile))
+ if (name.equals(welcomeFile)) {
return true;
+ }
}
}
return false;
@@ -3733,13 +3757,15 @@ public class StandardContext extends ContainerBase
public synchronized void reload() {
// Validate our current component state
- if (!getState().isAvailable())
+ if (!getState().isAvailable()) {
throw new IllegalStateException
(sm.getString("standardContext.notStarted", getName()));
+ }
- if(log.isInfoEnabled())
+ if(log.isInfoEnabled()) {
log.info(sm.getString("standardContext.reloadingStarted",
getName()));
+ }
// Stop accepting requests temporarily.
setPaused(true);
@@ -3760,9 +3786,10 @@ public class StandardContext extends ContainerBase
setPaused(false);
- if(log.isInfoEnabled())
+ if(log.isInfoEnabled()) {
log.info(sm.getString("standardContext.reloadingCompleted",
getName()));
+ }
}
@@ -3786,15 +3813,17 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified listener
int j = 0;
String results[] = new String[applicationListeners.length - 1];
for (int i = 0; i < applicationListeners.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = applicationListeners[i];
+ }
}
applicationListeners = results;
@@ -3825,16 +3854,18 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified parameter
int j = 0;
ApplicationParameter results[] =
new ApplicationParameter[applicationParameters.length - 1];
for (int i = 0; i < applicationParameters.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = applicationParameters[i];
+ }
}
applicationParameters = results;
@@ -3886,16 +3917,18 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified constraint
int j = 0;
SecurityConstraint results[] =
new SecurityConstraint[constraints.length - 1];
for (int i = 0; i < constraints.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = constraints[i];
+ }
}
constraints = results;
@@ -4029,15 +4062,17 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified security role
int j = 0;
String results[] = new String[securityRoles.length - 1];
for (int i = 0; i < securityRoles.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = securityRoles[i];
+ }
}
securityRoles = results;
@@ -4089,15 +4124,17 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified watched resource
int j = 0;
String results[] = new String[watchedResources.length - 1];
for (int i = 0; i < watchedResources.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = watchedResources[i];
+ }
}
watchedResources = results;
@@ -4127,23 +4164,26 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified welcome file
int j = 0;
String results[] = new String[welcomeFiles.length - 1];
for (int i = 0; i < welcomeFiles.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = welcomeFiles[i];
+ }
}
welcomeFiles = results;
}
// Inform interested listeners
- if(this.getState().equals(LifecycleState.STARTED))
+ if(this.getState().equals(LifecycleState.STARTED)) {
fireContainerEvent(REMOVE_WELCOME_FILE_EVENT, name);
+ }
}
@@ -4168,15 +4208,17 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified lifecycle listener
int j = 0;
String results[] = new String[wrapperLifecycles.length - 1];
for (int i = 0; i < wrapperLifecycles.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = wrapperLifecycles[i];
+ }
}
wrapperLifecycles = results;
@@ -4208,15 +4250,17 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified listener
int j = 0;
String results[] = new String[wrapperListeners.length - 1];
for (int i = 0; i < wrapperListeners.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = wrapperListeners[i];
+ }
}
wrapperListeners = results;
@@ -4265,8 +4309,9 @@ public class StandardContext extends ContainerBase
if (children != null) {
for (Container child : children) {
time = ((StandardWrapper) child).getMaxTime();
- if (time > result)
+ if (time > result) {
result = time;
+ }
}
}
@@ -4289,8 +4334,9 @@ public class StandardContext extends ContainerBase
if (children != null) {
for (Container child : children) {
time = ((StandardWrapper) child).getMinTime();
- if (result < 0 || time < result)
+ if (result < 0 || time < result) {
result = time;
+ }
}
}
@@ -4472,8 +4518,9 @@ public class StandardContext extends ContainerBase
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified filter mapping
FilterMap results[] = new FilterMap[array.length - 1];
@@ -4535,14 +4582,16 @@ public class StandardContext extends ContainerBase
*/
public boolean filterStop() {
- if (getLogger().isDebugEnabled())
+ if (getLogger().isDebugEnabled()) {
getLogger().debug("Stopping filters");
+ }
// Release all Filter and FilterConfig instances
synchronized (filterConfigs) {
for (Entry<String, ApplicationFilterConfig> entry :
filterConfigs.entrySet()) {
- if (getLogger().isDebugEnabled())
+ if (getLogger().isDebugEnabled()) {
getLogger().debug(" Stopping filter '" + entry.getKey() +
"'");
+ }
ApplicationFilterConfig filterConfig = entry.getValue();
filterConfig.release();
}
@@ -4573,17 +4622,19 @@ public class StandardContext extends ContainerBase
*/
public boolean listenerStart() {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Configuring application event listeners");
+ }
// Instantiate the required listeners
String listeners[] = findApplicationListeners();
Object results[] = new Object[listeners.length];
boolean ok = true;
for (int i = 0; i < results.length; i++) {
- if (getLogger().isDebugEnabled())
+ if (getLogger().isDebugEnabled()) {
getLogger().debug(" Configuring event listener class '" +
listeners[i] + "'");
+ }
try {
String listener = listeners[i];
results[i] = getInstanceManager().newInstance(listener);
@@ -4634,8 +4685,9 @@ public class StandardContext extends ContainerBase
// Send application start events
- if (getLogger().isDebugEnabled())
+ if (getLogger().isDebugEnabled()) {
getLogger().debug("Sending application start events");
+ }
// Ensure context is not null
getServletContext();
@@ -4685,8 +4737,9 @@ public class StandardContext extends ContainerBase
*/
public boolean listenerStop() {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Sending application stop events");
+ }
boolean ok = true;
Object listeners[] = getApplicationLifecycleListeners();
@@ -4698,8 +4751,9 @@ public class StandardContext extends ContainerBase
}
for (int i = 0; i < listeners.length; i++) {
int j = (listeners.length - 1) - i;
- if (listeners[j] == null)
+ if (listeners[j] == null) {
continue;
+ }
if (listeners[j] instanceof ServletContextListener) {
ServletContextListener listener =
(ServletContextListener) listeners[j];
@@ -4740,8 +4794,9 @@ public class StandardContext extends ContainerBase
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
int j = (listeners.length - 1) - i;
- if (listeners[j] == null)
+ if (listeners[j] == null) {
continue;
+ }
try {
if (getInstanceManager() != null) {
getInstanceManager().destroyInstance(listeners[j]);
@@ -4877,8 +4932,9 @@ public class StandardContext extends ContainerBase
@Override
protected synchronized void startInternal() throws LifecycleException {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug("Starting " + getBaseName());
+ }
// Send j2ee.state.starting notification
if (this.getObjectName() != null) {
@@ -4901,8 +4957,9 @@ public class StandardContext extends ContainerBase
// Add missing components as necessary
if (getResources() == null) { // (1) Required by Loader
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Configuring default Resources");
+ }
try {
setResources(new StandardRoot(this));
@@ -4962,8 +5019,9 @@ public class StandardContext extends ContainerBase
}
// Standard container startup
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Processing standard container startup");
+ }
// Binding thread
@@ -5167,8 +5225,9 @@ public class StandardContext extends ContainerBase
// Set available status depending upon startup success
if (ok) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Starting completed");
+ }
} else {
log.error(sm.getString("standardContext.startFailed", getName()));
}
@@ -5370,8 +5429,9 @@ public class StandardContext extends ContainerBase
setCharsetMapper(null);
// Normal container shutdown processing
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Processing standard container shutdown");
+ }
// JNDI resources are unbound in CONFIGURE_STOP_EVENT so stop
// naming resources before they are unbound since NamingResources
@@ -5390,8 +5450,9 @@ public class StandardContext extends ContainerBase
}
// Clear all application-originated servlet context attributes
- if (context != null)
+ if (context != null) {
context.clearAttributes();
+ }
Realm realm = getRealmInternal();
if (realm instanceof Lifecycle) {
@@ -5437,8 +5498,9 @@ public class StandardContext extends ContainerBase
//reset the instance manager
setInstanceManager(null);
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Stopping complete");
+ }
}
@@ -5490,8 +5552,9 @@ public class StandardContext extends ContainerBase
@Override
public void backgroundProcess() {
- if (!getState().isAvailable())
+ if (!getState().isAvailable()) {
return;
+ }
Loader loader = getLoader();
if (loader != null) {
@@ -5565,8 +5628,9 @@ public class StandardContext extends ContainerBase
postConstructMethods.clear();
preDestroyMethods.clear();
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug("resetContext " + getObjectName());
+ }
}
@@ -5583,15 +5647,19 @@ public class StandardContext extends ContainerBase
*/
protected String adjustURLPattern(String urlPattern) {
- if (urlPattern == null)
+ if (urlPattern == null) {
return urlPattern;
- if (urlPattern.startsWith("/") || urlPattern.startsWith("*."))
+ }
+ if (urlPattern.startsWith("/") || urlPattern.startsWith("*.")) {
return urlPattern;
- if (!isServlet22())
+ }
+ if (!isServlet22()) {
return urlPattern;
- if(log.isDebugEnabled())
+ }
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("standardContext.urlPattern.patternWarning",
urlPattern));
+ }
return "/" + urlPattern;
}
@@ -5896,10 +5964,12 @@ public class StandardContext extends ContainerBase
for (int i = 0; i < instances.length; i++) {
int j = (instances.length -1) -i;
- if (instances[j] == null)
+ if (instances[j] == null) {
continue;
- if (!(instances[j] instanceof ServletRequestListener))
+ }
+ if (!(instances[j] instanceof ServletRequestListener)) {
continue;
+ }
ServletRequestListener listener =
(ServletRequestListener) instances[j];
@@ -5921,12 +5991,14 @@ public class StandardContext extends ContainerBase
@Override
public void addPostConstructMethod(String clazz, String method) {
- if (clazz == null || method == null)
+ if (clazz == null || method == null) {
throw new IllegalArgumentException(
sm.getString("standardContext.postconstruct.required"));
- if (postConstructMethods.get(clazz) != null)
+ }
+ if (postConstructMethods.get(clazz) != null) {
throw new IllegalArgumentException(sm.getString(
"standardContext.postconstruct.duplicate", clazz));
+ }
postConstructMethods.put(clazz, method);
fireContainerEvent("addPostConstructMethod", clazz);
@@ -5942,12 +6014,14 @@ public class StandardContext extends ContainerBase
@Override
public void addPreDestroyMethod(String clazz, String method) {
- if (clazz == null || method == null)
+ if (clazz == null || method == null) {
throw new IllegalArgumentException(
sm.getString("standardContext.predestroy.required"));
- if (preDestroyMethods.get(clazz) != null)
+ }
+ if (preDestroyMethods.get(clazz) != null) {
throw new IllegalArgumentException(sm.getString(
"standardContext.predestroy.duplicate", clazz));
+ }
preDestroyMethods.put(clazz, method);
fireContainerEvent("addPreDestroyMethod", clazz);
@@ -6009,18 +6083,22 @@ public class StandardContext extends ContainerBase
engineName = parentEngine.getName();
}
}
- if ((hostName == null) || (hostName.length() < 1))
+ if ((hostName == null) || (hostName.length() < 1)) {
hostName = "_";
- if ((engineName == null) || (engineName.length() < 1))
+ }
+ if ((engineName == null) || (engineName.length() < 1)) {
engineName = "_";
+ }
String temp = getBaseName();
- if (temp.startsWith("/"))
+ if (temp.startsWith("/")) {
temp = temp.substring(1);
+ }
temp = temp.replace('/', '_');
temp = temp.replace('\\', '_');
- if (temp.length() < 1)
+ if (temp.length() < 1) {
temp = ContextName.ROOT_NAME;
+ }
if (hostWorkDir != null ) {
workDir = hostWorkDir + File.separator + temp;
} else {
@@ -6077,8 +6155,9 @@ public class StandardContext extends ContainerBase
*/
private boolean validateURLPattern(String urlPattern) {
- if (urlPattern == null)
+ if (urlPattern == null) {
return false;
+ }
if (urlPattern.indexOf('\n') >= 0 || urlPattern.indexOf('\r') >= 0) {
return false;
}
@@ -6089,14 +6168,16 @@ public class StandardContext extends ContainerBase
if (urlPattern.indexOf('/') < 0) {
checkUnusualURLPattern(urlPattern);
return true;
- } else
+ } else {
return false;
+ }
}
if (urlPattern.startsWith("/") && !urlPattern.contains("*.")) {
checkUnusualURLPattern(urlPattern);
return true;
- } else
+ } else {
return false;
+ }
}
diff --git a/java/org/apache/catalina/core/StandardEngine.java
b/java/org/apache/catalina/core/StandardEngine.java
index f60c2e8..c29892b 100644
--- a/java/org/apache/catalina/core/StandardEngine.java
+++ b/java/org/apache/catalina/core/StandardEngine.java
@@ -211,9 +211,10 @@ public class StandardEngine extends ContainerBase
implements Engine {
@Override
public void addChild(Container child) {
- if (!(child instanceof Host))
+ if (!(child instanceof Host)) {
throw new IllegalArgumentException
(sm.getString("standardEngine.notHost"));
+ }
super.addChild(child);
}
@@ -336,8 +337,9 @@ public class StandardEngine extends ContainerBase
implements Engine {
*/
@Override
public ClassLoader getParentClassLoader() {
- if (parentClassLoader != null)
+ if (parentClassLoader != null) {
return parentClassLoader;
+ }
if (service != null) {
return service.getParentClassLoader();
}
@@ -454,7 +456,9 @@ public class StandardEngine extends ContainerBase
implements Engine {
@Override
public void lifecycleEvent(LifecycleEvent event) {
- if (disabled) return;
+ if (disabled) {
+ return;
+ }
String type = event.getType();
if (Lifecycle.AFTER_START_EVENT.equals(type) ||
@@ -470,7 +474,9 @@ public class StandardEngine extends ContainerBase
implements Engine {
@Override
public void propertyChange(PropertyChangeEvent evt) {
- if (disabled) return;
+ if (disabled) {
+ return;
+ }
if ("defaultHost".equals(evt.getPropertyName())) {
// Force re-calculation and disable listener since it won't
// be re-used
@@ -482,7 +488,9 @@ public class StandardEngine extends ContainerBase
implements Engine {
@Override
public void containerEvent(ContainerEvent event) {
// Only useful for hosts
- if (disabled) return;
+ if (disabled) {
+ return;
+ }
if (Container.ADD_CHILD_EVENT.equals(event.getType())) {
Context context = (Context) event.getData();
if (context.getPath().isEmpty()) {
diff --git a/java/org/apache/catalina/core/StandardHost.java
b/java/org/apache/catalina/core/StandardHost.java
index 31bdc94..07df3d9 100644
--- a/java/org/apache/catalina/core/StandardHost.java
+++ b/java/org/apache/catalina/core/StandardHost.java
@@ -347,8 +347,9 @@ public class StandardHost extends ContainerBase implements
Host {
path = xmlDir.toString();
}
File file = new File(path);
- if (!file.isAbsolute())
+ if (!file.isAbsolute()) {
file = new File(getCatalinaBase(), path);
+ }
try {
file = file.getCanonicalFile();
} catch (IOException e) {// ignore
@@ -564,9 +565,10 @@ public class StandardHost extends ContainerBase implements
Host {
@Override
public void setName(String name) {
- if (name == null)
+ if (name == null) {
throw new IllegalArgumentException
(sm.getString("standardHost.nullName"));
+ }
name = name.toLowerCase(Locale.ENGLISH); // Internally all names
are lower case
@@ -703,8 +705,9 @@ public class StandardHost extends ContainerBase implements
Host {
synchronized (aliasesLock) {
// Skip duplicate aliases
for (String s : aliases) {
- if (s.equals(alias))
+ if (s.equals(alias)) {
return;
+ }
}
// Add this alias to the list
String newAliases[] = Arrays.copyOf(aliases, aliases.length + 1);
@@ -726,9 +729,10 @@ public class StandardHost extends ContainerBase implements
Host {
@Override
public void addChild(Container child) {
- if (!(child instanceof Context))
+ if (!(child instanceof Context)) {
throw new IllegalArgumentException
(sm.getString("standardHost.notContext"));
+ }
child.addLifecycleListener(new MemoryLeakTrackingListener());
@@ -822,15 +826,17 @@ public class StandardHost extends ContainerBase
implements Host {
break;
}
}
- if (n < 0)
+ if (n < 0) {
return;
+ }
// Remove the specified alias
int j = 0;
String results[] = new String[aliases.length - 1];
for (int i = 0; i < aliases.length; i++) {
- if (i != n)
+ if (i != n) {
results[j++] = aliases[i];
+ }
}
aliases = results;
diff --git a/java/org/apache/catalina/core/StandardPipeline.java
b/java/org/apache/catalina/core/StandardPipeline.java
index 16143bb..7ffcb69 100644
--- a/java/org/apache/catalina/core/StandardPipeline.java
+++ b/java/org/apache/catalina/core/StandardPipeline.java
@@ -172,8 +172,9 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
current = basic;
}
while (current != null) {
- if (current instanceof Lifecycle)
+ if (current instanceof Lifecycle) {
((Lifecycle) current).start();
+ }
current = current.getNext();
}
@@ -199,8 +200,9 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
current = basic;
}
while (current != null) {
- if (current instanceof Lifecycle)
+ if (current instanceof Lifecycle) {
((Lifecycle) current).stop();
+ }
current = current.getNext();
}
}
@@ -254,8 +256,9 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
// Change components if necessary
Valve oldBasic = this.basic;
- if (oldBasic == valve)
+ if (oldBasic == valve) {
return;
+ }
// Stop the old component if necessary
if (oldBasic != null) {
@@ -276,8 +279,9 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
}
// Start the new component if necessary
- if (valve == null)
+ if (valve == null) {
return;
+ }
if (valve instanceof Contained) {
((Contained) valve).setContainer(this.container);
}
@@ -328,8 +332,9 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
public void addValve(Valve valve) {
// Validate that we can add this Valve
- if (valve instanceof Contained)
+ if (valve instanceof Contained) {
((Contained) valve).setContainer(this.container);
+ }
// Start the new component if necessary
if (getState().isAvailable()) {
@@ -428,10 +433,13 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
current = current.getNext();
}
- if (first == basic) first = null;
+ if (first == basic) {
+ first = null;
+ }
- if (valve instanceof Contained)
+ if (valve instanceof Contained) {
((Contained) valve).setContainer(null);
+ }
if (valve instanceof Lifecycle) {
// Stop this valve if necessary
diff --git a/java/org/apache/catalina/core/StandardServer.java
b/java/org/apache/catalina/core/StandardServer.java
index fa213f7..6ab79fc 100644
--- a/java/org/apache/catalina/core/StandardServer.java
+++ b/java/org/apache/catalina/core/StandardServer.java
@@ -630,8 +630,9 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
// Read a set of characters from the socket
int expected = 1024; // Cut off to avoid DoS attack
while (expected < shutdown.length()) {
- if (random == null)
+ if (random == null) {
random = new Random();
+ }
expected += (random.nextInt() % 1024);
}
while (expected > 0) {
@@ -665,8 +666,9 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
if (match) {
log.info(sm.getString("standardServer.shutdownViaPort"));
break;
- } else
+ } else {
log.warn(sm.getString("standardServer.invalidShutdownCommand",
command.toString()));
+ }
}
} finally {
ServerSocket serverSocket = awaitSocket;
@@ -744,8 +746,9 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
break;
}
}
- if (j < 0)
+ if (j < 0) {
return;
+ }
try {
services[j].stop();
} catch (LifecycleException e) {
@@ -754,8 +757,9 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
int k = 0;
Service results[] = new Service[services.length - 1];
for (int i = 0; i < services.length; i++) {
- if (i != j)
+ if (i != j) {
results[k++] = services[i];
+ }
}
services = results;
@@ -1073,8 +1077,9 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
*/
@Override
public ClassLoader getParentClassLoader() {
- if (parentClassLoader != null)
+ if (parentClassLoader != null) {
return parentClassLoader;
+ }
if (catalina != null) {
return catalina.getParentClassLoader();
}
diff --git a/java/org/apache/catalina/core/StandardService.java
b/java/org/apache/catalina/core/StandardService.java
index 17ae30b..6a58e49 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -294,8 +294,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
break;
}
}
- if (j < 0)
+ if (j < 0) {
return;
+ }
if (connectors[j].getState().isAvailable()) {
try {
connectors[j].stop();
@@ -309,8 +310,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
int k = 0;
Connector results[] = new Connector[connectors.length - 1];
for (int i = 0; i < connectors.length; i++) {
- if (i != j)
+ if (i != j) {
results[k++] = connectors[i];
+ }
}
connectors = results;
@@ -386,8 +388,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
public Executor getExecutor(String executorName) {
synchronized (executors) {
for (Executor executor: executors) {
- if (executorName.equals(executor.getName()))
+ if (executorName.equals(executor.getName())) {
return executor;
+ }
}
}
return null;
@@ -423,8 +426,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
@Override
protected void startInternal() throws LifecycleException {
- if(log.isInfoEnabled())
+ if(log.isInfoEnabled()) {
log.info(sm.getString("standardService.start.name", this.name));
+ }
setState(LifecycleState.STARTING);
// Start our defined Container first
@@ -487,8 +491,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
}
}
- if(log.isInfoEnabled())
+ if(log.isInfoEnabled()) {
log.info(sm.getString("standardService.stop.name", this.name));
+ }
setState(LifecycleState.STOPPING);
// Stop our defined Container once the Connectors are all paused
@@ -588,8 +593,9 @@ public class StandardService extends LifecycleMBeanBase
implements Service {
*/
@Override
public ClassLoader getParentClassLoader() {
- if (parentClassLoader != null)
+ if (parentClassLoader != null) {
return parentClassLoader;
+ }
if (server != null) {
return server.getParentClassLoader();
}
diff --git a/java/org/apache/catalina/core/StandardThreadExecutor.java
b/java/org/apache/catalina/core/StandardThreadExecutor.java
index 9ab3e7d..66fc7d0 100644
--- a/java/org/apache/catalina/core/StandardThreadExecutor.java
+++ b/java/org/apache/catalina/core/StandardThreadExecutor.java
@@ -315,8 +315,9 @@ public class StandardThreadExecutor extends
LifecycleMBeanBase
@Override
public boolean resizePool(int corePoolSize, int maximumPoolSize) {
- if (executor == null)
+ if (executor == null) {
return false;
+ }
executor.setCorePoolSize(corePoolSize);
executor.setMaximumPoolSize(maximumPoolSize);
diff --git a/java/org/apache/catalina/core/StandardWrapper.java
b/java/org/apache/catalina/core/StandardWrapper.java
index f6c6b39..733deff 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -310,10 +310,11 @@ public class StandardWrapper extends ContainerBase
@Override
public void setAvailable(long available) {
long oldAvailable = this.available;
- if (available > System.currentTimeMillis())
+ if (available > System.currentTimeMillis()) {
this.available = available;
- else
+ } else {
this.available = 0L;
+ }
support.firePropertyChange("available", Long.valueOf(oldAvailable),
Long.valueOf(this.available));
}
@@ -427,9 +428,10 @@ public class StandardWrapper extends ContainerBase
public void setParent(Container container) {
if ((container != null) &&
- !(container instanceof Context))
+ !(container instanceof Context)) {
throw new IllegalArgumentException
(sm.getString("standardWrapper.notContext"));
+ }
if (container instanceof StandardContext) {
swallowOutput = ((StandardContext)container).getSwallowOutput();
unloadDelay = ((StandardContext)container).getUnloadDelay();
@@ -532,15 +534,16 @@ public class StandardWrapper extends ContainerBase
@Override
public boolean isUnavailable() {
- if (!isEnabled())
+ if (!isEnabled()) {
return true;
- else if (available == 0L)
+ } else if (available == 0L) {
return false;
- else if (available <= System.currentTimeMillis()) {
+ } else if (available <= System.currentTimeMillis()) {
available = 0L;
return false;
- } else
+ } else {
return true;
+ }
}
@@ -617,8 +620,9 @@ public class StandardWrapper extends ContainerBase
public void backgroundProcess() {
super.backgroundProcess();
- if (!getState().isAvailable())
+ if (!getState().isAvailable()) {
return;
+ }
if (getServlet() instanceof PeriodicEventListener) {
((PeriodicEventListener) getServlet()).periodicEvent();
@@ -640,8 +644,9 @@ public class StandardWrapper extends ContainerBase
do {
loops++;
rootCauseCheck = rootCause.getCause();
- if (rootCauseCheck != null)
+ if (rootCauseCheck != null) {
rootCause = rootCauseCheck;
+ }
} while (rootCauseCheck != null && (loops < 20));
return rootCause;
}
@@ -696,8 +701,9 @@ public class StandardWrapper extends ContainerBase
} finally {
mappingsLock.writeLock().unlock();
}
- if(parent.getState().equals(LifecycleState.STARTED))
+ if(parent.getState().equals(LifecycleState.STARTED)) {
fireContainerEvent(ADD_MAPPING_EVENT, mapping);
+ }
}
@@ -1020,8 +1026,9 @@ public class StandardWrapper extends ContainerBase
public synchronized Servlet loadServlet() throws ServletException {
// Nothing to do if we already have an instance or an instance pool
- if (!singleThreadModel && (instance != null))
+ if (!singleThreadModel && (instance != null)) {
return instance;
+ }
PrintStream out = System.out;
if (swallowOutput) {
@@ -1112,7 +1119,9 @@ public class StandardWrapper extends ContainerBase
private synchronized void initServlet(Servlet servlet)
throws ServletException {
- if (instanceInitialized && !singleThreadModel) return;
+ if (instanceInitialized && !singleThreadModel) {
+ return;
+ }
// Call the initialization method of this servlet
try {
@@ -1186,8 +1195,9 @@ public class StandardWrapper extends ContainerBase
} finally {
mappingsLock.writeLock().unlock();
}
- if(parent.getState().equals(LifecycleState.STARTED))
+ if(parent.getState().equals(LifecycleState.STARTED)) {
fireContainerEvent(REMOVE_MAPPING_EVENT, mapping);
+ }
}
@@ -1221,14 +1231,16 @@ public class StandardWrapper extends ContainerBase
@Override
public void unavailable(UnavailableException unavailable) {
getServletContext().log(sm.getString("standardWrapper.unavailable",
getName()));
- if (unavailable == null)
+ if (unavailable == null) {
setAvailable(Long.MAX_VALUE);
- else if (unavailable.isPermanent())
+ } else if (unavailable.isPermanent()) {
setAvailable(Long.MAX_VALUE);
- else {
+ } else {
int unavailableSeconds = unavailable.getUnavailableSeconds();
if (unavailableSeconds <= 0)
+ {
unavailableSeconds = 60; // Arbitrary default
+ }
setAvailable(System.currentTimeMillis() +
(unavailableSeconds * 1000L));
}
@@ -1250,8 +1262,9 @@ public class StandardWrapper extends ContainerBase
public synchronized void unload() throws ServletException {
// Nothing to do if we have never loaded the instance
- if (!singleThreadModel && (instance == null))
+ if (!singleThreadModel && (instance == null)) {
return;
+ }
unloading = true;
// Loaf a while if the current instance is allocated
@@ -1413,12 +1426,13 @@ public class StandardWrapper extends ContainerBase
*/
@Override
public ServletContext getServletContext() {
- if (parent == null)
+ if (parent == null) {
return null;
- else if (!(parent instanceof Context))
+ } else if (!(parent instanceof Context)) {
return null;
- else
+ } else {
return ((Context) parent).getServletContext();
+ }
}
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java
b/java/org/apache/catalina/core/StandardWrapperValve.java
index b9a3a36..b47be92 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -165,7 +165,9 @@ final class StandardWrapperValve
MessageBytes requestPathMB = request.getRequestPathMB();
DispatcherType dispatcherType = DispatcherType.REQUEST;
- if (request.getDispatcherType()==DispatcherType.ASYNC) dispatcherType
= DispatcherType.ASYNC;
+ if (request.getDispatcherType()==DispatcherType.ASYNC) {
+ dispatcherType = DispatcherType.ASYNC;
+ }
request.setAttribute(Globals.DISPATCHER_TYPE_ATTR,dispatcherType);
request.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR,
requestPathMB);
@@ -295,8 +297,12 @@ final class StandardWrapperValve
long time=t2-t1;
processingTime += time;
- if( time > maxTime) maxTime=time;
- if( time < minTime) minTime=time;
+ if( time > maxTime) {
+ maxTime=time;
+ }
+ if( time < minTime) {
+ minTime=time;
+ }
}
}
diff --git
a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
index 58c4857..f81c9fa 100644
--- a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
@@ -115,7 +115,9 @@ public class ThreadLocalLeakPreventionListener extends
FrameworkListener {
* of its parent Service.
*/
private void stopIdleThreads(Context context) {
- if (serverStopping) return;
+ if (serverStopping) {
+ return;
+ }
if (!(context instanceof StandardContext) ||
!((StandardContext) context).getRenewThreadsWhenStoppingContext())
{
diff --git a/java/org/apache/catalina/ha/ClusterListener.java
b/java/org/apache/catalina/ha/ClusterListener.java
index 348b136..9a3687e 100644
--- a/java/org/apache/catalina/ha/ClusterListener.java
+++ b/java/org/apache/catalina/ha/ClusterListener.java
@@ -57,12 +57,13 @@ public abstract class ClusterListener implements
ChannelListener {
public void setCluster(CatalinaCluster cluster) {
if (log.isDebugEnabled()) {
- if (cluster != null)
+ if (cluster != null) {
log.debug("add ClusterListener " + this.toString() +
" to cluster" + cluster);
- else
+ } else {
log.debug("remove ClusterListener " + this.toString() +
" from cluster");
+ }
}
this.cluster = cluster;
}
@@ -71,11 +72,15 @@ public abstract class ClusterListener implements
ChannelListener {
@Override
public final void messageReceived(Serializable msg, Member member) {
- if ( msg instanceof ClusterMessage )
messageReceived((ClusterMessage)msg);
+ if ( msg instanceof ClusterMessage ) {
+ messageReceived((ClusterMessage)msg);
+ }
}
@Override
public final boolean accept(Serializable msg, Member member) {
- if ( msg instanceof ClusterMessage ) return true;
+ if ( msg instanceof ClusterMessage ) {
+ return true;
+ }
return false;
}
diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java
b/java/org/apache/catalina/ha/backend/CollectedInfo.java
index c409898..58533a4 100644
--- a/java/org/apache/catalina/ha/backend/CollectedInfo.java
+++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java
@@ -79,16 +79,19 @@ public class CollectedInfo {
String [] elenames = name.split("-");
String sport = elenames[elenames.length-1];
iport = Integer.parseInt(sport);
- if (elenames.length == 4)
+ if (elenames.length == 4) {
shost = elenames[2];
+ }
- if (port==0 && host==null)
+ if (port==0 && host==null) {
break; /* Done: take the first one */
+ }
if (iport==port) {
- if (host == null)
+ if (host == null) {
break; /* Done: return the first with the right port */
- else if (shost != null && shost.compareTo(host) == 0)
+ } else if (shost != null && shost.compareTo(host) == 0) {
break; /* Done port and host are the expected ones */
+ }
}
objName = null;
shost = null;
diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
index 169b3f8..e78eef7 100644
--- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
+++ b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
@@ -167,10 +167,11 @@ public class HeartbeatListener implements
LifecycleListener {
if (Lifecycle.PERIODIC_EVENT.equals(event.getType())) {
if (sender == null) {
- if (proxyList == null)
+ if (proxyList == null) {
sender = new MultiCastSender();
- else
+ } else {
sender = new TcpSender();
+ }
}
/* Read busy and ready */
diff --git a/java/org/apache/catalina/ha/backend/MultiCastSender.java
b/java/org/apache/catalina/ha/backend/MultiCastSender.java
index 50edc0a..1e00ee8 100644
--- a/java/org/apache/catalina/ha/backend/MultiCastSender.java
+++ b/java/org/apache/catalina/ha/backend/MultiCastSender.java
@@ -55,8 +55,9 @@ public class MultiCastSender
InetAddress addr =
InetAddress.getByName(config.getHost());
InetSocketAddress addrs = new InetSocketAddress(addr,
config.getMultiport());
s = new MulticastSocket(addrs);
- } else
+ } else {
s = new MulticastSocket(config.getMultiport());
+ }
s.setTimeToLive(config.getTtl());
s.joinGroup(group);
diff --git a/java/org/apache/catalina/ha/backend/TcpSender.java
b/java/org/apache/catalina/ha/backend/TcpSender.java
index 7e1bda9..85c4d75 100644
--- a/java/org/apache/catalina/ha/backend/TcpSender.java
+++ b/java/org/apache/catalina/ha/backend/TcpSender.java
@@ -104,8 +104,9 @@ public class TcpSender
connections[i].bind(addrs);
addrs = new InetSocketAddress(proxies[i].address,
proxies[i].port);
connections[i].connect(addrs);
- } else
+ } else {
connections[i] = new Socket(proxies[i].address,
proxies[i].port);
+ }
connectionReaders[i] = new BufferedReader(new
InputStreamReader(connections[i].getInputStream()));
connectionWriters[i] = new BufferedWriter(new
OutputStreamWriter(connections[i].getOutputStream()));
} catch (Exception ex) {
@@ -114,7 +115,9 @@ public class TcpSender
}
}
if (connections[i] == null)
+ {
continue; // try next proxy in the list
+ }
BufferedWriter writer = connectionWriters[i];
try {
writer.write(requestLine);
@@ -131,7 +134,9 @@ public class TcpSender
close(i);
}
if (connections[i] == null)
+ {
continue; // try next proxy in the list
+ }
/* Read httpd answer */
String responseStatus = connectionReaders[i].readLine();
diff --git a/java/org/apache/catalina/ha/context/ReplicatedContext.java
b/java/org/apache/catalina/ha/context/ReplicatedContext.java
index c4bb759..dc45707 100644
--- a/java/org/apache/catalina/ha/context/ReplicatedContext.java
+++ b/java/org/apache/catalina/ha/context/ReplicatedContext.java
@@ -106,8 +106,12 @@ public class ReplicatedContext extends StandardContext
implements MapOwner {
Loader loader = null;
ClassLoader classLoader = null;
loader = this.getLoader();
- if (loader != null) classLoader = loader.getClassLoader();
- if ( classLoader == null ) classLoader =
Thread.currentThread().getContextClassLoader();
+ if (loader != null) {
+ classLoader = loader.getClassLoader();
+ }
+ if ( classLoader == null ) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
return new ClassLoader[] {classLoader};
} else {
@@ -119,8 +123,9 @@ public class ReplicatedContext extends StandardContext
implements MapOwner {
public ServletContext getServletContext() {
if (context == null) {
context = new ReplApplContext(this);
- if (getAltDDName() != null)
+ if (getAltDDName() != null) {
context.setAttribute(Globals.ALT_DD_ATTR,getAltDDName());
+ }
}
return ((ReplApplContext)context).getFacade();
@@ -169,8 +174,9 @@ public class ReplicatedContext extends StandardContext
implements MapOwner {
}
if ( (!getParent().getState().isAvailable()) ||
"org.apache.jasper.runtime.JspApplicationContextImpl".equals(name) ){
tomcatAttributes.put(name,value);
- } else
+ } else {
super.setAttribute(name,value);
+ }
}
@Override
diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index c16c3e0..da1081c 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -135,8 +135,9 @@ public class FarmWarDeployer extends ClusterListener
/*--Logic---------------------------------------------------*/
@Override
public void start() throws Exception {
- if (started)
+ if (started) {
return;
+ }
Container hcontainer = getCluster().getContainer();
if(!(hcontainer instanceof Host)) {
log.error(sm.getString("farmWarDeployer.hostOnly"));
@@ -180,8 +181,9 @@ public class FarmWarDeployer extends ClusterListener
getCluster().addClusterListener(this);
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.started"));
+ }
}
/*
@@ -199,8 +201,9 @@ public class FarmWarDeployer extends ClusterListener
watcher = null;
}
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.stopped"));
+ }
}
/**
@@ -215,16 +218,18 @@ public class FarmWarDeployer extends ClusterListener
try {
if (msg instanceof FileMessage) {
FileMessage fmsg = (FileMessage) msg;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.msgRxDeploy",
fmsg.getContextName(), fmsg.getFileName()));
+ }
FileMessageFactory factory = getFactory(fmsg);
// TODO correct second try after app is in service!
if (factory.writeMessage(fmsg)) {
//last message received war file is completed
String name = factory.getFile().getName();
- if (!name.endsWith(".war"))
+ if (!name.endsWith(".war")) {
name = name + ".war";
+ }
File deployable = new File(getDeployDirFile(), name);
try {
String contextName = fmsg.getContextName();
@@ -240,14 +245,16 @@ public class FarmWarDeployer extends ClusterListener
removeServiced(contextName);
}
check(contextName);
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString(
"farmWarDeployer.deployEnd",
contextName));
- } else
+ }
+ } else {
log.error(sm.getString(
"farmWarDeployer.servicingDeploy",
contextName, name));
+ }
} catch (Exception ex) {
log.error(sm.getString("farmWarDeployer.fileMessageError"), ex);
} finally {
@@ -258,23 +265,26 @@ public class FarmWarDeployer extends ClusterListener
try {
UndeployMessage umsg = (UndeployMessage) msg;
String contextName = umsg.getContextName();
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.msgRxUndeploy",
contextName));
+ }
if (tryAddServiced(contextName)) {
try {
remove(contextName);
} finally {
removeServiced(contextName);
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString(
"farmWarDeployer.undeployEnd",
contextName));
- } else
+ }
+ } else {
log.error(sm.getString(
"farmWarDeployer.servicingUndeploy",
contextName));
+ }
} catch (Exception ex) {
log.error(sm.getString("farmWarDeployer.undeployMessageError"), ex);
}
@@ -355,29 +365,34 @@ public class FarmWarDeployer extends ClusterListener
@Override
public void install(String contextName, File webapp) throws IOException {
Member[] members = getCluster().getMembers();
- if (members.length == 0) return;
+ if (members.length == 0) {
+ return;
+ }
Member localMember = getCluster().getLocalMember();
FileMessageFactory factory =
FileMessageFactory.getInstance(webapp, false);
FileMessage msg = new FileMessage(localMember, webapp.getName(),
contextName);
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.sendStart", contextName,
webapp));
+ }
msg = factory.readMessage(msg);
while (msg != null) {
for (Member member : members) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.sendFragment",
contextName, webapp, member));
+ }
getCluster().send(msg, member);
}
msg = factory.readMessage(msg);
}
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString(
"farmWarDeployer.sendEnd", contextName, webapp));
+ }
}
/**
@@ -405,14 +420,16 @@ public class FarmWarDeployer extends ClusterListener
public void remove(String contextName, boolean undeploy)
throws IOException {
if (getCluster().getMembers().length > 0) {
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.removeStart",
contextName));
+ }
Member localMember = getCluster().getLocalMember();
UndeployMessage msg = new UndeployMessage(localMember, System
.currentTimeMillis(), "Undeploy:" + contextName + ":"
+ System.currentTimeMillis(), contextName);
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.removeTxMsg",
contextName));
+ }
cluster.send(msg);
}
// remove locally
@@ -425,9 +442,10 @@ public class FarmWarDeployer extends ClusterListener
removeServiced(contextName);
}
check(contextName);
- } else
+ } else {
log.error(sm.getString("farmWarDeployer.removeFailRemote",
contextName));
+ }
} catch (Exception ex) {
log.error(sm.getString("farmWarDeployer.removeFailLocal",
@@ -448,13 +466,15 @@ public class FarmWarDeployer extends ClusterListener
File deployWar = new File(getDeployDirFile(), newWar.getName());
ContextName cn = new ContextName(deployWar.getName(), true);
if (deployWar.exists() && deployWar.lastModified() >
newWar.lastModified()) {
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.alreadyDeployed",
cn.getName()));
+ }
return;
}
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.modInstall",
cn.getName(), deployWar.getAbsolutePath()));
+ }
// install local
if (tryAddServiced(cn.getName())) {
try {
@@ -482,9 +502,10 @@ public class FarmWarDeployer extends ClusterListener
public void fileRemoved(File removeWar) {
try {
ContextName cn = new ContextName(removeWar.getName(), true);
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.removeLocal",
cn.getName()));
+ }
remove(cn.getName(), true);
} catch (Exception x) {
log.error(sm.getString("farmWarDeployer.removeLocalFail"), x);
@@ -501,9 +522,10 @@ public class FarmWarDeployer extends ClusterListener
// Stop the context first to be nicer
Context context = (Context) host.findChild(contextName);
if (context != null) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("farmWarDeployer.undeployLocal",
contextName));
+ }
context.stop();
String baseName = context.getBaseName();
File war = new File(host.getAppBaseFile(), baseName + ".war");
@@ -624,7 +646,9 @@ public class FarmWarDeployer extends ClusterListener
}
public File getDeployDirFile() {
- if (deployDirFile != null) return deployDirFile;
+ if (deployDirFile != null) {
+ return deployDirFile;
+ }
File dir = getAbsolutePath(getDeployDir());
this.deployDirFile = dir;
@@ -640,7 +664,9 @@ public class FarmWarDeployer extends ClusterListener
}
public File getTempDirFile() {
- if (tempDirFile != null) return tempDirFile;
+ if (tempDirFile != null) {
+ return tempDirFile;
+ }
File dir = getAbsolutePath(getTempDir());
this.tempDirFile = dir;
@@ -656,7 +682,9 @@ public class FarmWarDeployer extends ClusterListener
}
public File getWatchDirFile() {
- if (watchDirFile != null) return watchDirFile;
+ if (watchDirFile != null) {
+ return watchDirFile;
+ }
File dir = getAbsolutePath(getWatchDir());
this.watchDirFile = dir;
@@ -733,8 +761,9 @@ public class FarmWarDeployer extends ClusterListener
byte[] buf = new byte[4096];
while (true) {
int len = is.read(buf);
- if (len < 0)
+ if (len < 0) {
break;
+ }
os.write(buf, 0, len);
}
} catch (IOException e) {
diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
index ed0cdca..61d90ff 100644
--- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
+++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
@@ -150,13 +150,15 @@ public class FileMessageFactory {
throws FileNotFoundException, IOException {
this.file = f;
this.openForWrite = openForWrite;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("open file " + f + " write " + openForWrite);
+ }
if (openForWrite) {
- if (!file.exists())
+ if (!file.exists()) {
if (!file.createNewFile()) {
throw new IOException(sm.getString("fileNewFail", file));
}
+ }
out = new FileOutputStream(f);
} else {
size = file.length();
@@ -238,9 +240,10 @@ public class FileMessageFactory {
if (!openForWrite) {
throw new
IllegalArgumentException(sm.getString("fileMessageFactory.cannotWrite"));
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Message " + msg + " data " +
HexUtils.toHexString(msg.getData())
+ " data length " + msg.getDataLength() + " out " + out);
+ }
if (msg.getMessageNumber() <= lastMessageProcessed.get()) {
// Duplicate of message already processed
@@ -297,16 +300,18 @@ public class FileMessageFactory {
* Closes the factory, its streams and sets all its references to null
*/
public void cleanup() {
- if (in != null)
+ if (in != null) {
try {
in.close();
} catch (IOException ignore) {
}
- if (out != null)
+ }
+ if (out != null) {
try {
out.close();
} catch (IOException ignore) {
}
+ }
in = null;
out = null;
size = 0;
diff --git a/java/org/apache/catalina/ha/deploy/WarWatcher.java
b/java/org/apache/catalina/ha/deploy/WarWatcher.java
index 81cac16..6b732b8 100644
--- a/java/org/apache/catalina/ha/deploy/WarWatcher.java
+++ b/java/org/apache/catalina/ha/deploy/WarWatcher.java
@@ -68,8 +68,9 @@ public class WarWatcher {
* check for modification and send notification to listener
*/
public void check() {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("warWatcher.checkingWars", watchDir));
+ }
File[] list = watchDir.listFiles(new WarFilter());
if (list == null) {
log.warn(sm.getString("warWatcher.cantListWatchDir",
@@ -79,9 +80,10 @@ public class WarWatcher {
}
//first make sure all the files are listed in our current status
for (File file : list) {
- if (!file.exists())
+ if (!file.exists()) {
log.warn(sm.getString("warWatcher.listedFileDoesNotExist",
file, watchDir));
+ }
addWarInfo(file);
}
@@ -91,9 +93,10 @@ public class WarWatcher {
currentStatus.entrySet().iterator(); i.hasNext();) {
Map.Entry<String,WarInfo> entry = i.next();
WarInfo info = entry.getValue();
- if(log.isTraceEnabled())
+ if(log.isTraceEnabled()) {
log.trace(sm.getString("warWatcher.checkingWar",
info.getWar()));
+ }
int check = info.check();
if (check == 1) {
listener.fileModified(info.getWar());
@@ -102,10 +105,11 @@ public class WarWatcher {
//no need to keep in memory
i.remove();
}
- if(log.isTraceEnabled())
+ if(log.isTraceEnabled()) {
log.trace(sm.getString("warWatcher.checkWarResult",
Integer.valueOf(check),
info.getWar()));
+ }
}
}
@@ -139,8 +143,9 @@ public class WarWatcher {
protected static class WarFilter implements java.io.FilenameFilter {
@Override
public boolean accept(File path, String name) {
- if (name == null)
+ if (name == null) {
return false;
+ }
return name.endsWith(".war");
}
}
@@ -158,8 +163,9 @@ public class WarWatcher {
public WarInfo(File war) {
this.war = war;
this.lastChecked = war.lastModified();
- if (!war.exists())
+ if (!war.exists()) {
lastState = -1;
+ }
}
public boolean modified() {
diff --git a/java/org/apache/catalina/ha/session/BackupManager.java
b/java/org/apache/catalina/ha/session/BackupManager.java
index bd3ac83..72f67a9 100644
--- a/java/org/apache/catalina/ha/session/BackupManager.java
+++ b/java/org/apache/catalina/ha/session/BackupManager.java
@@ -91,7 +91,9 @@ public class BackupManager extends ClusterManagerBase
@Override
public ClusterMessage requestCompleted(String sessionId) {
- if (!getState().isAvailable()) return null;
+ if (!getState().isAvailable()) {
+ return null;
+ }
LazyReplicatedMap<String,Session> map =
(LazyReplicatedMap<String,Session>)sessions;
map.replicate(sessionId,false);
@@ -143,7 +145,9 @@ public class BackupManager extends ClusterManagerBase
super.startInternal();
try {
- if (cluster == null) throw new
LifecycleException(sm.getString("backupManager.noCluster", getName()));
+ if (cluster == null) {
+ throw new
LifecycleException(sm.getString("backupManager.noCluster", getName()));
+ }
LazyReplicatedMap<String,Session> map = new LazyReplicatedMap<>(
this, cluster.getChannel(), rpcTimeout, getMapName(),
getClassLoaders(), terminateOnStartFailure);
@@ -159,7 +163,9 @@ public class BackupManager extends ClusterManagerBase
public String getMapName() {
String name = cluster.getManagerName(getName(),this)+"-"+"map";
- if ( log.isDebugEnabled() ) log.debug("Backup manager, Setting map
name to:"+name);
+ if ( log.isDebugEnabled() ) {
+ log.debug("Backup manager, Setting map name to:"+name);
+ }
return name;
}
@@ -177,8 +183,9 @@ public class BackupManager extends ClusterManagerBase
@Override
protected synchronized void stopInternal() throws LifecycleException {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("backupManager.stopped", getName()));
+ }
setState(LifecycleState.STOPPING);
diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index 08a6763..89bbf28 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -184,8 +184,10 @@ public abstract class ClusterManagerBase extends
ManagerBase implements ClusterM
Valve[] valves = cluster.getValves();
if(valves != null && valves.length > 0) {
for(int i=0; replicationValve == null && i < valves.length
; i++ ){
- if(valves[i] instanceof ReplicationValve)
replicationValve =
- (ReplicationValve)valves[i] ;
+ if(valves[i] instanceof ReplicationValve) {
+ replicationValve =
+ (ReplicationValve)valves[i] ;
+ }
}//for
if(replicationValve == null && log.isDebugEnabled()) {
@@ -208,12 +210,16 @@ public abstract class ClusterManagerBase extends
ManagerBase implements ClusterM
setCluster((CatalinaCluster)cluster);
}
}
- if (cluster != null) cluster.registerManager(this);
+ if (cluster != null) {
+ cluster.registerManager(this);
+ }
}
@Override
protected void stopInternal() throws LifecycleException {
- if (cluster != null) cluster.removeManager(this);
+ if (cluster != null) {
+ cluster.removeManager(this);
+ }
replicationValve = null;
super.stopInternal();
}
diff --git a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
index 68aa806..9dbd2ee 100644
--- a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
+++ b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
@@ -62,13 +62,14 @@ public class ClusterSessionListener extends ClusterListener
{
if (ctxname == null) {
for (Map.Entry<String, ClusterManager> entry :
managers.entrySet()) {
- if (entry.getValue() != null)
+ if (entry.getValue() != null) {
entry.getValue().messageDataReceived(msg);
- else {
+ } else {
//this happens a lot before the system has started
// up
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("clusterSessionListener.noManager", entry.getKey()));
+ }
}
}
} else {
@@ -76,8 +77,9 @@ public class ClusterSessionListener extends ClusterListener {
if (mgr != null) {
mgr.messageDataReceived(msg);
} else {
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
log.warn(sm.getString("clusterSessionListener.noManager", ctxname));
+ }
// A no context manager message is replied in order to
avoid
// timeout of GET_ALL_SESSIONS sync phase.
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 608ae8f..0385bc0 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -423,9 +423,10 @@ public class DeltaManager extends ClusterManagerBase{
if (distribute) {
sendCreateSession(session.getId(), session);
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("deltaManager.createSession.newSession",
session.getId(), Integer.valueOf(sessions.size())));
+ }
return session;
}
@@ -484,14 +485,18 @@ public class DeltaManager extends ClusterManagerBase{
protected String rotateSessionId(Session session, boolean notify) {
String orgSessionID = session.getId();
String newId = super.rotateSessionId(session);
- if (notify) sendChangeSessionId(session.getId(), orgSessionID);
+ if (notify) {
+ sendChangeSessionId(session.getId(), orgSessionID);
+ }
return newId;
}
protected void changeSessionId(Session session, String newId, boolean
notify) {
String orgSessionID = session.getId();
super.changeSessionId(session, newId);
- if (notify) sendChangeSessionId(session.getId(), orgSessionID);
+ if (notify) {
+ sendChangeSessionId(session.getId(), orgSessionID);
+ }
}
protected void sendChangeSessionId(String newSessionID, String
orgSessionID) {
@@ -699,9 +704,10 @@ public class DeltaManager extends ClusterManagerBase{
receiverQueue = true ;
}
cluster.send(msg, mbr, Channel.SEND_OPTIONS_ASYNCHRONOUS);
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("deltaManager.waitForSessionState",
getName(), mbr,
Integer.valueOf(getStateTransferTimeout())));
+ }
// FIXME At sender ack mode this method check only the state
// transfer and resend is a problem!
waitForSendAllSessions(beforeSendTime);
@@ -731,7 +737,9 @@ public class DeltaManager extends ClusterManagerBase{
}
}
} else {
- if (log.isInfoEnabled())
log.info(sm.getString("deltaManager.noMembers", getName()));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("deltaManager.noMembers", getName()));
+ }
}
}
@@ -742,7 +750,9 @@ public class DeltaManager extends ClusterManagerBase{
protected Member findSessionMasterMember() {
Member mbr = null;
Member mbrs[] = cluster.getMembers();
- if(mbrs.length != 0 ) mbr = mbrs[0];
+ if(mbrs.length != 0 ) {
+ mbr = mbrs[0];
+ }
if(mbr == null && log.isWarnEnabled()) {
log.warn(sm.getString("deltaManager.noMasterMember",getName(),
""));
}
@@ -789,13 +799,15 @@ public class DeltaManager extends ClusterManagerBase{
log.error(sm.getString("deltaManager.noSessionState", getName(),
new Date(beforeSendTime), Long.valueOf(reqNow -
beforeSendTime)));
}else if (isNoContextManagerReceived()) {
- if (log.isWarnEnabled())
+ if (log.isWarnEnabled()) {
log.warn(sm.getString("deltaManager.noContextManager",
getName(),
new Date(beforeSendTime), Long.valueOf(reqNow -
beforeSendTime)));
+ }
} else {
- if (log.isInfoEnabled())
+ if (log.isInfoEnabled()) {
log.info(sm.getString("deltaManager.sessionReceived",
getName(),
new Date(beforeSendTime), Long.valueOf(reqNow -
beforeSendTime)));
+ }
}
}
@@ -809,18 +821,22 @@ public class DeltaManager extends ClusterManagerBase{
@Override
protected synchronized void stopInternal() throws LifecycleException {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("deltaManager.stopped", getName()));
+ }
setState(LifecycleState.STOPPING);
// Expire all active sessions
- if (log.isInfoEnabled())
log.info(sm.getString("deltaManager.expireSessions", getName()));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("deltaManager.expireSessions", getName()));
+ }
Session sessions[] = findSessions();
for (Session value : sessions) {
DeltaSession session = (DeltaSession) value;
- if (!session.isValid())
+ if (!session.isValid()) {
continue;
+ }
try {
session.expire(true, isExpireSessionsOnShutdown());
} catch (Throwable t) {
@@ -941,7 +957,9 @@ public class DeltaManager extends ClusterManagerBase{
log.debug(sm.getString("deltaManager.createMessage.delta",
getName(), sessionId));
}
}
- if (!expires) session.setPrimarySession(true);
+ if (!expires) {
+ session.setPrimarySession(true);
+ }
//check to see if we need to send out an access message
if (!expires && (msg == null)) {
long replDelta = System.currentTimeMillis() -
session.getLastTimeReplicated();
@@ -1341,9 +1359,10 @@ public class DeltaManager extends ClusterManagerBase{
*/
protected void handleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg,
Member sender) {
counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER++ ;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("deltaManager.receiveMessage.noContextManager",
getName(), sender.getHost(),
Integer.valueOf(sender.getPort())));
+ }
noContextManagerReceived = true ;
}
diff --git a/java/org/apache/catalina/ha/session/DeltaRequest.java
b/java/org/apache/catalina/ha/session/DeltaRequest.java
index b4aa789..c691e6d 100644
--- a/java/org/apache/catalina/ha/session/DeltaRequest.java
+++ b/java/org/apache/catalina/ha/session/DeltaRequest.java
@@ -75,8 +75,9 @@ public class DeltaRequest implements Externalizable {
public DeltaRequest(String sessionId, boolean recordAllActions) {
this.recordAllActions=recordAllActions;
- if(sessionId != null)
+ if(sessionId != null) {
setSessionId(sessionId);
+ }
}
@@ -104,10 +105,12 @@ public class DeltaRequest implements Externalizable {
if (p != null) {
if (p instanceof GenericPrincipal) {
gp = (GenericPrincipal) p;
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug(sm.getString("deltaRequest.showPrincipal",
p.getName() , getSessionId()));
- } else
+ }
+ } else {
log.error(sm.getString("deltaRequest.wrongPrincipalClass",p.getClass().getName()));
+ }
}
addAction(TYPE_PRINCIPAL, action, NAME_PRINCIPAL, gp);
}
@@ -160,28 +163,36 @@ public class DeltaRequest implements Externalizable {
}
public void execute(DeltaSession session, boolean notifyListeners) {
- if ( !this.sessionId.equals( session.getId() ) )
+ if ( !this.sessionId.equals( session.getId() ) ) {
throw new
java.lang.IllegalArgumentException(sm.getString("deltaRequest.ssid.mismatch"));
+ }
session.access();
for (AttributeInfo info : actions) {
switch (info.getType()) {
case TYPE_ATTRIBUTE:
if (info.getAction() == ACTION_SET) {
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled()) {
log.trace("Session.setAttribute('" +
info.getName() + "', '" + info.getValue() + "')");
+ }
session.setAttribute(info.getName(), info.getValue(),
notifyListeners, false);
} else {
- if (log.isTraceEnabled())
log.trace("Session.removeAttribute('" + info.getName() + "')");
+ if (log.isTraceEnabled()) {
+ log.trace("Session.removeAttribute('" +
info.getName() + "')");
+ }
session.removeAttribute(info.getName(),
notifyListeners, false);
}
break;
case TYPE_ISNEW:
- if (log.isTraceEnabled()) log.trace("Session.setNew('" +
info.getValue() + "')");
+ if (log.isTraceEnabled()) {
+ log.trace("Session.setNew('" + info.getValue() + "')");
+ }
session.setNew(((Boolean) info.getValue()).booleanValue(),
false);
break;
case TYPE_MAXINTERVAL:
- if (log.isTraceEnabled())
log.trace("Session.setMaxInactiveInterval('" + info.getValue() + "')");
+ if (log.isTraceEnabled()) {
+ log.trace("Session.setMaxInactiveInterval('" +
info.getValue() + "')");
+ }
session.setMaxInactiveInterval(((Integer)
info.getValue()).intValue(), false);
break;
case TYPE_PRINCIPAL:
@@ -255,10 +266,11 @@ public class DeltaRequest implements Externalizable {
sessionId = in.readUTF();
recordAllActions = in.readBoolean();
int cnt = in.readInt();
- if (actions == null)
+ if (actions == null) {
actions = new LinkedList<>();
- else
+ } else {
actions.clear();
+ }
for (int i = 0; i < cnt; i++) {
AttributeInfo info = null;
if (this.actionPool.size() > 0) {
@@ -365,7 +377,9 @@ public class DeltaRequest implements Externalizable {
@Override
public boolean equals(Object o) {
- if ( ! (o instanceof AttributeInfo ) ) return false;
+ if ( ! (o instanceof AttributeInfo ) ) {
+ return false;
+ }
AttributeInfo other = (AttributeInfo)o;
return other.getName().equals(this.getName());
}
@@ -381,7 +395,9 @@ public class DeltaRequest implements Externalizable {
action = in.readInt();
name = in.readUTF();
boolean hasValue = in.readBoolean();
- if ( hasValue ) value = in.readObject();
+ if ( hasValue ) {
+ value = in.readObject();
+ }
}
@Override
@@ -395,7 +411,9 @@ public class DeltaRequest implements Externalizable {
out.writeInt(getAction());
out.writeUTF(getName());
out.writeBoolean(getValue()!=null);
- if (getValue()!=null) out.writeObject(getValue());
+ if (getValue()!=null) {
+ out.writeObject(getValue());
+ }
}
@Override
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 966ff6b..4134e52 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -202,8 +202,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
ClassLoader contextLoader =
Thread.currentThread().getContextClassLoader();
try {
ClassLoader[] loaders = getClassLoaders();
- if (loaders != null && loaders.length > 0)
+ if (loaders != null && loaders.length > 0) {
Thread.currentThread().setContextClassLoader(loaders[0]);
+ }
getDeltaRequest().readExternal(stream);
getDeltaRequest().execute(this,
((ClusterManager)getManager()).isNotifyListenersOnReplication());
} finally {
@@ -405,8 +406,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
lockInternal();
try {
super.setPrincipal(principal);
- if (addDeltaRequest)
+ if (addDeltaRequest) {
deltaRequest.setPrincipal(principal);
+ }
} finally {
unlockInternal();
}
@@ -499,17 +501,20 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
// Check to see if session has already been invalidated.
// Do not check expiring at this point as expire should not return
until
// isValid is false
- if (!isValid)
+ if (!isValid) {
return;
+ }
synchronized (this) {
// Check again, now we are inside the sync so this code only runs
once
// Double check locking - isValid needs to be volatile
- if (!isValid)
+ if (!isValid) {
return;
+ }
- if (manager == null)
+ if (manager == null) {
return;
+ }
String expiredId = getIdInternal();
@@ -526,11 +531,12 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
super.expire(notify);
if (notifyCluster) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(sm.getString("deltaSession.notifying",
((ClusterManager)manager).getName(),
Boolean.valueOf(isPrimarySession()),
expiredId));
+ }
if ( manager instanceof DeltaManager ) {
( (DeltaManager) manager).sessionExpired(expiredId);
}
@@ -747,7 +753,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
public void removeAttribute(String name, boolean notify,boolean
addDeltaRequest) {
// Validate our current state
- if (!isValid()) throw new
IllegalStateException(sm.getString("standardSession.removeAttribute.ise"));
+ if (!isValid()) {
+ throw new
IllegalStateException(sm.getString("standardSession.removeAttribute.ise"));
+ }
removeAttributeInternal(name, notify, addDeltaRequest);
}
@@ -778,7 +786,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
public void setAttribute(String name, Object value, boolean notify,boolean
addDeltaRequest) {
// Name cannot be null
- if (name == null) throw new
IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
+ if (name == null) {
+ throw new
IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
+ }
// Null value is the same as removeAttribute()
if (value == null) {
@@ -839,10 +849,14 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
// setId((String) stream.readObject());
id = (String) stream.readObject();
- if (log.isDebugEnabled())
log.debug(sm.getString("deltaSession.readSession", id));
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("deltaSession.readSession", id));
+ }
// Deserialize the attribute count and attribute values
- if (attributes == null) attributes = new ConcurrentHashMap<>();
+ if (attributes == null) {
+ attributes = new ConcurrentHashMap<>();
+ }
int n = ( (Integer) stream.readObject()).intValue();
boolean isValidSave = isValid;
isValid = true;
@@ -864,8 +878,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
continue;
}
// ConcurrentHashMap does not allow null keys or values
- if(null != value)
+ if(null != value) {
attributes.put(name, value);
+ }
}
isValid = isValidSave;
@@ -937,7 +952,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
}
stream.writeObject(id);
- if (log.isDebugEnabled())
log.debug(sm.getString("deltaSession.writeSession", id));
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("deltaSession.writeSession", id));
+ }
// Accumulate the names of serializable and non-serializable attributes
String keys[] = keys();
@@ -987,7 +1004,9 @@ public class DeltaSession extends StandardSession
implements Externalizable,Clus
try {
// Remove this attribute from our collection
Object value = attributes.get(name);
- if (value == null) return;
+ if (value == null) {
+ return;
+ }
super.removeAttributeInternal(name,notify);
if (addDeltaRequest && !exclude(name, null)) {
diff --git a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
index 8eaf9ad..93d8527 100644
--- a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
+++ b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
@@ -197,8 +197,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
*/
@Override
public String getClusterName() {
- if(clusterName == null && container != null)
+ if(clusterName == null && container != null) {
return container.getName() ;
+ }
return clusterName;
}
@@ -252,8 +253,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
*/
@Override
public void addValve(Valve valve) {
- if (valve instanceof ClusterValve && (!valves.contains(valve)))
+ if (valve instanceof ClusterValve && (!valves.contains(valve))) {
valves.add(valve);
+ }
}
/**
@@ -275,8 +277,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
ClusterListener[] listener = new
ClusterListener[clusterListeners.size()];
clusterListeners.toArray(listener);
return listener;
- } else
+ } else {
return new ClusterListener[0];
+ }
}
@@ -428,7 +431,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
log.error(sm.getString("simpleTcpCluster.clustermanager.cloneFailed"), x);
manager = new org.apache.catalina.ha.session.DeltaManager();
} finally {
- if ( manager != null) manager.setCluster(this);
+ if ( manager != null) {
+ manager.setCluster(this);
+ }
}
return manager;
}
@@ -474,7 +479,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
@Override
public String getManagerName(String name, Manager manager) {
String clusterName = name ;
- if (clusterName == null) clusterName = manager.getContext().getName();
+ if (clusterName == null) {
+ clusterName = manager.getContext().getName();
+ }
if (getContainer() instanceof Engine) {
Context context = manager.getContext();
Container host = context.getParent();
@@ -503,10 +510,14 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
*/
@Override
public void backgroundProcess() {
- if (clusterDeployer != null) clusterDeployer.backgroundProcess();
+ if (clusterDeployer != null) {
+ clusterDeployer.backgroundProcess();
+ }
//send a heartbeat through the channel
- if ( isHeartbeatBackgroundEnabled() && channel !=null )
channel.heartbeat();
+ if ( isHeartbeatBackgroundEnabled() && channel !=null ) {
+ channel.heartbeat();
+ }
// periodic event
fireLifecycleEvent(Lifecycle.PERIODIC_EVENT, null);
@@ -541,7 +552,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
@Override
protected void startInternal() throws LifecycleException {
- if (log.isInfoEnabled())
log.info(sm.getString("simpleTcpCluster.start"));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("simpleTcpCluster.start"));
+ }
try {
checkDefaults();
@@ -550,7 +563,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
channel.addChannelListener(this);
channel.setName(getClusterName() + "-Channel");
channel.start(channelStartOptions);
- if (clusterDeployer != null) clusterDeployer.start();
+ if (clusterDeployer != null) {
+ clusterDeployer.start();
+ }
registerMember(channel.getLocalMember(false));
} catch (Exception x) {
log.error(sm.getString("simpleTcpCluster.startUnable"), x);
@@ -568,13 +583,19 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
addValve(new JvmRouteBinderValve());
addValve(new ReplicationValve());
}
- if ( clusterDeployer != null ) clusterDeployer.setCluster(this);
- if ( channel == null ) channel = new GroupChannel();
+ if ( clusterDeployer != null ) {
+ clusterDeployer.setCluster(this);
+ }
+ if ( channel == null ) {
+ channel = new GroupChannel();
+ }
if ( channel instanceof GroupChannel &&
!((GroupChannel)channel).getInterceptors().hasNext()) {
channel.addInterceptor(new MessageDispatchInterceptor());
channel.addInterceptor(new TcpFailureDetector());
}
- if (heartbeatBackgroundEnabled) channel.setHeartbeat(false);
+ if (heartbeatBackgroundEnabled) {
+ channel.setHeartbeat(false);
+ }
}
/**
@@ -584,9 +605,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
if(container != null ) {
for (Valve v : valves) {
ClusterValve valve = (ClusterValve) v;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Invoking addValve on " + getContainer()
+ " with class=" + valve.getClass().getName());
+ }
if (valve != null) {
container.getPipeline().addValve(valve);
valve.setCluster(this);
@@ -601,9 +623,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
protected void unregisterClusterValve() {
for (Valve v : valves) {
ClusterValve valve = (ClusterValve) v;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Invoking removeValve on " + getContainer()
+ " with class=" + valve.getClass().getName());
+ }
if (valve != null) {
container.getPipeline().removeValve(valve);
valve.setCluster(null);
@@ -625,10 +648,14 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
setState(LifecycleState.STOPPING);
unregisterMember(channel.getLocalMember(false));
- if (clusterDeployer != null) clusterDeployer.stop();
+ if (clusterDeployer != null) {
+ clusterDeployer.stop();
+ }
this.managers.clear();
try {
- if ( clusterDeployer != null ) clusterDeployer.setCluster(null);
+ if ( clusterDeployer != null ) {
+ clusterDeployer.setCluster(null);
+ }
channel.stop(channelStartOptions);
channel.removeChannelListener(this);
channel.removeMembershipListener(this);
@@ -689,14 +716,16 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
if (dest != null) {
if (!getLocalMember().equals(dest)) {
channel.send(new Member[] {dest}, msg, sendOptions);
- } else
+ } else {
log.error(sm.getString("simpleTcpCluster.unableSend.localMember", msg));
+ }
} else {
Member[] destmembers = channel.getMembers();
- if (destmembers.length>0)
+ if (destmembers.length>0) {
channel.send(destmembers,msg, sendOptions);
- else if (log.isDebugEnabled())
+ } else if (log.isDebugEnabled()) {
log.debug("No members in cluster, ignoring message:"+msg);
+ }
}
} catch (Exception x) {
log.error(sm.getString("simpleTcpCluster.sendFailed"), x);
@@ -712,7 +741,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
public void memberAdded(Member member) {
try {
hasMembers = channel.hasMembers();
- if (log.isInfoEnabled())
log.info(sm.getString("simpleTcpCluster.member.added", member));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("simpleTcpCluster.member.added",
member));
+ }
// Notify our interested LifecycleListeners
fireLifecycleEvent(BEFORE_MEMBERREGISTER_EVENT, member);
@@ -735,7 +766,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
public void memberDisappeared(Member member) {
try {
hasMembers = channel.hasMembers();
- if (log.isInfoEnabled())
log.info(sm.getString("simpleTcpCluster.member.disappeared", member));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("simpleTcpCluster.member.disappeared",
member));
+ }
// Notify our interested LifecycleListeners
fireLifecycleEvent(BEFORE_MEMBERUNREGISTER_EVENT, member);
@@ -773,11 +806,12 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
public void messageReceived(ClusterMessage message) {
- if (log.isDebugEnabled() && message != null)
+ if (log.isDebugEnabled() && message != null) {
log.debug("Assuming clocks are synched: Replication for "
+ message.getUniqueId() + " took="
+ (System.currentTimeMillis() - (message).getTimestamp())
+ " ms.");
+ }
//invoke all the listeners
boolean accepted = false;
@@ -849,7 +883,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
private void unregisterMember(Member member) {
- if (member == null) return;
+ if (member == null) {
+ return;
+ }
ObjectName oname = memberOnameMap.remove(member);
if (oname != null) {
unregister(oname);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]