You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2025/03/20 00:30:25 UTC
(tomcat) branch 10.1.x updated: Clenaups
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 71628d504d Clenaups
71628d504d is described below
commit 71628d504d57658ae233d8d2950659552c1e8652
Author: remm <re...@apache.org>
AuthorDate: Wed Mar 19 23:58:47 2025 +0100
Clenaups
Noticed unwanted jakarta changes during merge due to record refactoring.
---
java/org/apache/catalina/Container.java | 2 +-
java/org/apache/catalina/Context.java | 8 ++--
java/org/apache/catalina/Host.java | 6 +--
java/org/apache/catalina/LifecycleListener.java | 2 +-
java/org/apache/catalina/UserDatabase.java | 2 +-
java/org/apache/catalina/Valve.java | 2 +-
java/org/apache/catalina/WebResourceRoot.java | 14 +++----
java/org/apache/catalina/Wrapper.java | 4 +-
.../apache/catalina/ant/AbstractCatalinaTask.java | 16 ++------
.../catalina/ant/jmx/JMXAccessorCondition.java | 2 +-
.../catalina/ant/jmx/JMXAccessorInvokeTask.java | 22 +++++-----
.../catalina/ant/jmx/JMXAccessorQueryTask.java | 8 ++--
.../catalina/ant/jmx/JMXAccessorSetTask.java | 2 +-
.../apache/catalina/ant/jmx/JMXAccessorTask.java | 12 +++---
.../catalina/authenticator/AuthenticatorBase.java | 10 ++---
.../catalina/authenticator/BasicAuthenticator.java | 2 +-
.../apache/catalina/authenticator/Constants.java | 2 +-
.../authenticator/DigestAuthenticator.java | 4 +-
.../catalina/authenticator/FormAuthenticator.java | 16 ++++----
.../authenticator/NonLoginAuthenticator.java | 2 +-
.../catalina/authenticator/SingleSignOn.java | 4 +-
.../catalina/authenticator/SingleSignOnEntry.java | 6 +--
.../authenticator/SingleSignOnSessionKey.java | 10 +----
.../authenticator/SpnegoAuthenticator.java | 6 +--
.../jaspic/AuthConfigFactoryImpl.java | 28 ++++++-------
.../jaspic/PersistentProviderRegistrations.java | 2 +-
.../jaspic/SimpleAuthConfigProvider.java | 2 +-
.../jaspic/SimpleServerAuthConfig.java | 2 +-
.../jaspic/SimpleServerAuthContext.java | 2 +-
.../apache/catalina/connector/CoyoteAdapter.java | 12 +++---
.../org/apache/catalina/connector/InputBuffer.java | 2 +-
.../apache/catalina/connector/OutputBuffer.java | 2 +-
java/org/apache/catalina/connector/Request.java | 6 +--
.../apache/catalina/core/ApplicationContext.java | 4 +-
.../catalina/core/ApplicationDispatcher.java | 45 ++++++++-------------
.../catalina/core/ApplicationFilterConfig.java | 4 +-
.../apache/catalina/core/ApplicationResponse.java | 2 +-
.../apache/catalina/core/AprLifecycleListener.java | 26 ++++++------
.../catalina/core/DefaultInstanceManager.java | 6 ++-
.../core/JreMemoryLeakPreventionListener.java | 8 ++--
.../catalina/core/NamingContextListener.java | 8 ++--
java/org/apache/catalina/core/StandardServer.java | 4 +-
java/org/apache/catalina/core/StandardWrapper.java | 28 ++++++-------
.../catalina/filters/CsrfPreventionFilter.java | 8 ++--
.../catalina/filters/CsrfPreventionFilterBase.java | 6 +--
.../org/apache/catalina/filters/ExpiresFilter.java | 14 ++++---
java/org/apache/catalina/filters/FilterBase.java | 2 +-
.../apache/catalina/filters/RateLimitFilter.java | 4 +-
.../apache/catalina/filters/RemoteIpFilter.java | 28 ++++++-------
.../org/apache/catalina/filters/RequestFilter.java | 2 +-
.../catalina/filters/RestCsrfPreventionFilter.java | 2 +-
.../filters/SetCharacterEncodingFilter.java | 2 +-
java/org/apache/catalina/ha/ClusterDeployer.java | 4 +-
java/org/apache/catalina/ha/ClusterListener.java | 5 +--
java/org/apache/catalina/ha/ClusterValve.java | 2 +-
.../ha/authenticator/ClusterSingleSignOn.java | 2 +-
.../apache/catalina/ha/backend/CollectedInfo.java | 4 +-
.../catalina/ha/backend/HeartbeatListener.java | 2 +-
java/org/apache/catalina/ha/backend/TcpSender.java | 5 ++-
.../catalina/ha/context/ReplicatedContext.java | 4 +-
.../apache/catalina/ha/deploy/FarmWarDeployer.java | 7 ++--
.../org/apache/catalina/ha/deploy/FileMessage.java | 7 +---
.../catalina/ha/deploy/FileMessageFactory.java | 4 +-
.../apache/catalina/ha/deploy/UndeployMessage.java | 2 +-
java/org/apache/catalina/ha/deploy/WarWatcher.java | 2 +-
.../apache/catalina/ha/session/BackupManager.java | 3 +-
.../catalina/ha/session/ClusterManagerBase.java | 2 +-
.../apache/catalina/ha/session/DeltaManager.java | 12 +++---
.../apache/catalina/ha/session/DeltaRequest.java | 22 +++++-----
.../apache/catalina/ha/session/DeltaSession.java | 20 +++------
.../catalina/ha/session/JvmRouteBinderValve.java | 2 +-
.../apache/catalina/ha/session/SessionMessage.java | 2 +-
.../catalina/ha/session/SessionMessageImpl.java | 2 +-
.../apache/catalina/ha/tcp/ReplicationValve.java | 38 +++++++++--------
.../apache/catalina/ha/tcp/SimpleTcpCluster.java | 4 +-
.../apache/catalina/loader/JdbcLeakPrevention.java | 6 +--
java/org/apache/catalina/loader/WebappLoader.java | 14 +++----
.../catalina/manager/HTMLManagerServlet.java | 38 +++++------------
.../apache/catalina/manager/JMXProxyServlet.java | 4 +-
.../apache/catalina/manager/ManagerServlet.java | 6 +--
.../catalina/manager/StatusManagerServlet.java | 2 +-
.../manager/host/HTMLHostManagerServlet.java | 16 ++++----
.../catalina/manager/host/HostManagerServlet.java | 16 ++++----
.../apache/catalina/manager/util/SessionUtils.java | 13 ++----
java/org/apache/catalina/mapper/Mapper.java | 3 +-
.../catalina/mbeans/ContextEnvironmentMBean.java | 2 +-
.../catalina/mbeans/ContextResourceLinkMBean.java | 2 +-
.../catalina/mbeans/ContextResourceMBean.java | 2 +-
.../mbeans/DataSourceUserDatabaseMBean.java | 20 ++++-----
java/org/apache/catalina/mbeans/MBeanFactory.java | 2 +-
java/org/apache/catalina/mbeans/MBeanUtils.java | 4 +-
.../catalina/mbeans/SparseUserDatabaseMBean.java | 10 ++---
.../catalina/realm/AuthenticatedUserRealm.java | 2 +-
.../org/apache/catalina/realm/DataSourceRealm.java | 12 +++---
.../realm/DigestCredentialHandlerBase.java | 13 ++----
java/org/apache/catalina/realm/JAASRealm.java | 14 +++----
java/org/apache/catalina/realm/JNDIRealm.java | 8 ++--
java/org/apache/catalina/realm/LockOutRealm.java | 2 +-
java/org/apache/catalina/realm/MemoryRealm.java | 4 +-
java/org/apache/catalina/realm/NullRealm.java | 2 +-
java/org/apache/catalina/realm/RealmBase.java | 30 +++++++-------
.../catalina/realm/X509UsernameRetriever.java | 8 ++--
.../apache/catalina/security/SecurityListener.java | 4 +-
.../security/TLSCertificateReloadListener.java | 4 +-
java/org/apache/catalina/servlets/CGIServlet.java | 12 +++---
.../apache/catalina/servlets/DefaultServlet.java | 19 +++++----
.../apache/catalina/servlets/WebdavServlet.java | 6 +--
java/org/apache/catalina/session/Constants.java | 11 +----
.../apache/catalina/session/StandardManager.java | 2 +-
.../apache/catalina/session/StandardSession.java | 7 +---
.../apache/catalina/ssi/ExpressionParseTree.java | 2 +-
java/org/apache/catalina/ssi/SSIConditional.java | 4 --
.../apache/catalina/ssi/SSIConditionalState.java | 2 +-
java/org/apache/catalina/ssi/SSIFlastmod.java | 2 +-
java/org/apache/catalina/ssi/SSIFsize.java | 2 +-
java/org/apache/catalina/ssi/SSIServlet.java | 2 +-
.../catalina/ssi/SSIServletExternalResolver.java | 10 +----
java/org/apache/catalina/startup/Bootstrap.java | 13 +++---
java/org/apache/catalina/startup/Catalina.java | 2 +-
.../org/apache/catalina/startup/ContextConfig.java | 8 ++--
java/org/apache/catalina/startup/ExpandWar.java | 8 ++--
java/org/apache/catalina/startup/HostConfig.java | 29 ++++++-------
.../catalina/startup/PasswdUserDatabase.java | 2 +-
.../startup/SafeForkJoinWorkerThreadFactory.java | 2 +-
.../apache/catalina/startup/SetNextNamingRule.java | 8 +---
java/org/apache/catalina/startup/Tomcat.java | 10 ++---
java/org/apache/catalina/startup/Tool.java | 6 +--
.../storeconfig/CertificateStoreAppender.java | 2 +-
.../apache/catalina/storeconfig/ConnectorSF.java | 2 +-
.../storeconfig/ConnectorStoreAppender.java | 2 +-
.../apache/catalina/storeconfig/OpenSSLConfSF.java | 2 +-
.../catalina/storeconfig/SSLHostConfigSF.java | 2 +-
.../catalina/storeconfig/StoreContextAppender.java | 3 +-
java/org/apache/catalina/tribes/ByteMessage.java | 2 +-
java/org/apache/catalina/tribes/Channel.java | 14 +++----
.../apache/catalina/tribes/ChannelException.java | 2 +-
.../apache/catalina/tribes/ChannelInterceptor.java | 6 +--
java/org/apache/catalina/tribes/Member.java | 10 ++---
.../apache/catalina/tribes/MembershipService.java | 8 ++--
java/org/apache/catalina/tribes/UniqueId.java | 8 ++--
.../catalina/tribes/group/AbsoluteOrder.java | 10 +----
.../apache/catalina/tribes/group/GroupChannel.java | 17 ++++----
.../apache/catalina/tribes/group/RpcChannel.java | 2 +-
.../apache/catalina/tribes/group/RpcMessage.java | 11 +----
.../interceptors/DomainFilterInterceptor.java | 4 +-
.../group/interceptors/EncryptInterceptor.java | 4 +-
.../interceptors/MessageDispatchInterceptor.java | 2 +-
.../group/interceptors/NonBlockingCoordinator.java | 13 +++---
.../group/interceptors/OrderInterceptor.java | 7 ++--
.../group/interceptors/SimpleCoordinator.java | 2 +-
.../interceptors/StaticMembershipInterceptor.java | 14 +++----
.../interceptors/TwoPhaseCommitInterceptor.java | 3 +-
.../org/apache/catalina/tribes/io/ChannelData.java | 14 +++----
.../apache/catalina/tribes/io/ObjectReader.java | 2 +-
.../catalina/tribes/io/ReplicationStream.java | 8 ++--
.../org/apache/catalina/tribes/io/XByteBuffer.java | 28 ++++++-------
.../apache/catalina/tribes/jmx/JmxRegistry.java | 6 +--
.../catalina/tribes/membership/McastService.java | 2 +-
.../tribes/membership/McastServiceImpl.java | 13 ++----
.../catalina/tribes/membership/MemberImpl.java | 6 +--
.../catalina/tribes/membership/Membership.java | 16 ++++----
.../membership/StaticMembershipProvider.java | 12 ++----
.../membership/cloud/CloudMembershipProvider.java | 2 +-
.../membership/cloud/DNSMembershipProvider.java | 5 ++-
.../cloud/KubernetesMembershipProvider.java | 10 ++---
.../membership/cloud/TokenStreamProvider.java | 2 +-
.../tribes/tipis/AbstractReplicatedMap.java | 47 ++++++++--------------
.../catalina/tribes/tipis/LazyReplicatedMap.java | 4 +-
.../catalina/tribes/tipis/ReplicatedMap.java | 3 +-
.../catalina/tribes/transport/PooledSender.java | 23 ++++++-----
.../catalina/tribes/transport/ReceiverBase.java | 4 +-
.../catalina/tribes/transport/RxTaskPool.java | 10 +----
.../catalina/tribes/transport/SenderState.java | 2 +-
.../catalina/tribes/transport/nio/NioReceiver.java | 10 ++---
.../tribes/transport/nio/NioReplicationTask.java | 2 +-
.../catalina/tribes/transport/nio/NioSender.java | 13 ++----
.../tribes/transport/nio/ParallelNioSender.java | 2 +-
java/org/apache/catalina/tribes/util/Arrays.java | 2 +-
.../apache/catalina/tribes/util/StringManager.java | 14 +++----
.../apache/catalina/tribes/util/UUIDGenerator.java | 5 +--
.../catalina/users/DataSourceUserDatabase.java | 2 +-
.../users/DataSourceUserDatabaseFactory.java | 2 +-
.../apache/catalina/users/MemoryUserDatabase.java | 16 ++------
.../catalina/users/MemoryUserDatabaseFactory.java | 2 +-
java/org/apache/catalina/util/CharsetMapper.java | 2 +-
java/org/apache/catalina/util/Introspection.java | 2 +-
java/org/apache/catalina/util/LifecycleBase.java | 28 ++++++-------
.../apache/catalina/util/LifecycleMBeanBase.java | 20 +++++----
java/org/apache/catalina/util/NetMask.java | 4 +-
java/org/apache/catalina/util/RateLimiterBase.java | 2 +-
.../catalina/util/TimeBucketCounterBase.java | 2 +-
.../catalina/valves/AbstractAccessLogValve.java | 12 +++---
.../apache/catalina/valves/ErrorReportValve.java | 2 +-
.../apache/catalina/valves/JsonAccessLogValve.java | 3 +-
java/org/apache/catalina/valves/RemoteIpValve.java | 12 +++---
.../apache/catalina/valves/RequestFilterValve.java | 5 +--
.../apache/catalina/valves/rewrite/RewriteMap.java | 2 +-
.../catalina/valves/rewrite/RewriteRule.java | 4 +-
.../catalina/valves/rewrite/RewriteValve.java | 3 +-
.../webresources/AbstractFileResourceSet.java | 2 +-
.../apache/catalina/webresources/JarContents.java | 2 +-
.../catalina/webresources/JarWarResource.java | 5 +--
.../apache/catalina/webresources/StandardRoot.java | 2 +-
.../webresources/TomcatJarInputStream.java | 2 +-
.../TomcatURLStreamHandlerFactory.java | 4 +-
java/org/apache/coyote/AbstractProcessor.java | 8 ++--
java/org/apache/coyote/AbstractProcessorLight.java | 4 +-
java/org/apache/coyote/AbstractProtocol.java | 12 +++---
java/org/apache/coyote/ActionCode.java | 2 +-
java/org/apache/coyote/ErrorState.java | 2 +-
java/org/apache/coyote/Processor.java | 2 +-
java/org/apache/coyote/ProtocolHandler.java | 2 +-
java/org/apache/coyote/Request.java | 2 +-
java/org/apache/coyote/RequestInfo.java | 4 +-
.../org/apache/coyote/ajp/AbstractAjpProtocol.java | 4 +-
.../coyote/http11/AbstractHttp11Protocol.java | 4 +-
.../apache/coyote/http11/Http11InputBuffer.java | 4 +-
.../apache/coyote/http11/Http11OutputBuffer.java | 2 +-
java/org/apache/coyote/http11/Http11Processor.java | 2 +-
.../coyote/http11/filters/ChunkedInputFilter.java | 8 ++--
java/org/apache/coyote/http2/HpackDecoder.java | 6 +--
java/org/apache/coyote/http2/Http2Protocol.java | 2 +-
.../apache/coyote/http2/Http2UpgradeHandler.java | 4 +-
java/org/apache/coyote/http2/RecycledStream.java | 2 +-
java/org/apache/coyote/http2/Stream.java | 8 ++--
.../coyote/http2/WindowAllocationManager.java | 2 +-
.../modules/MbeansDescriptorsDigesterSource.java | 4 +-
.../MbeansDescriptorsIntrospectionSource.java | 2 +-
.../apache/tomcat/util/net/AbstractEndpoint.java | 12 +++---
java/org/apache/tomcat/util/security/Escape.java | 7 +---
.../catalina/core/TestApplicationFilterConfig.java | 2 +-
.../apache/catalina/mbeans/TestRegistration.java | 2 +-
232 files changed, 740 insertions(+), 950 deletions(-)
diff --git a/java/org/apache/catalina/Container.java b/java/org/apache/catalina/Container.java
index ede48b7984..c9b7e4baef 100644
--- a/java/org/apache/catalina/Container.java
+++ b/java/org/apache/catalina/Container.java
@@ -331,7 +331,7 @@ public interface Container extends Lifecycle {
/**
* Add a new child Container to those associated with this Container, if supported. Prior to adding this Container
* to the set of children, the child's <code>setParent()</code> method must be called, with this Container as an
- * argument. This method may thrown an <code>IllegalArgumentException</code> if this Container chooses not to be
+ * argument. This method may throw an <code>IllegalArgumentException</code> if this Container chooses not to be
* attached to the specified Container, in which case it is not added
*
* @param child New child Container to be added
diff --git a/java/org/apache/catalina/Context.java b/java/org/apache/catalina/Context.java
index 952d15f92c..921e396e4d 100644
--- a/java/org/apache/catalina/Context.java
+++ b/java/org/apache/catalina/Context.java
@@ -51,8 +51,8 @@ import org.apache.tomcat.util.http.CookieProcessor;
/**
* A <b>Context</b> is a Container that represents a servlet context, and therefore an individual web application, in
* the Catalina servlet engine. It is therefore useful in almost every deployment of Catalina (even if a Connector
- * attached to a web server (such as Apache) uses the web server's facilities to identify the appropriate Wrapper to
- * handle this request. It also provides a convenient mechanism to use Interceptors that see every request processed by
+ * attached to a web server such as Apache uses the web server's facilities to identify the appropriate Wrapper to
+ * handle this request). It also provides a convenient mechanism to use Interceptors that see every request processed by
* this particular web application.
* <p>
* The parent Container attached to a Context is generally a Host, but may be some other implementation, or may be
@@ -318,7 +318,7 @@ public interface Context extends Container, ContextBind {
* Configures if a / is added to the end of the session cookie path to ensure browsers, particularly IE, don't send
* a session cookie for context /foo with requests intended for context /foobar.
*
- * @param sessionCookiePathUsesTrailingSlash <code>true</code> if the slash is should be added, otherwise
+ * @param sessionCookiePathUsesTrailingSlash <code>true</code> if the slash should be added, otherwise
* <code>false</code>
*/
void setSessionCookiePathUsesTrailingSlash(boolean sessionCookiePathUsesTrailingSlash);
@@ -1109,7 +1109,7 @@ public interface Context extends Container, ContextBind {
* @return <code>true</code> if the specified welcome file is defined for this Context; otherwise return
* <code>false</code>.
*
- * @param name Welcome file to verify
+ * @param name the welcome file to verify
*/
boolean findWelcomeFile(String name);
diff --git a/java/org/apache/catalina/Host.java b/java/org/apache/catalina/Host.java
index 321875a8cf..14950fa93a 100644
--- a/java/org/apache/catalina/Host.java
+++ b/java/org/apache/catalina/Host.java
@@ -88,7 +88,7 @@ public interface Host extends Container {
/**
* @return an absolute {@link File} for the appBase of this Host. The file will be canonical if possible. There is
- * no guarantee that that the appBase exists.
+ * no guarantee that the appBase exists.
*/
File getAppBaseFile();
@@ -110,7 +110,7 @@ public interface Host extends Container {
/**
* @return an absolute {@link File} for the legacy (Java EE) appBase of this Host. The file will be canonical if
- * possible. There is no guarantee that that the appBase exists.
+ * possible. There is no guarantee that the appBase exists.
*/
File getLegacyAppBaseFile();
@@ -193,7 +193,7 @@ public interface Host extends Container {
/**
* @return the executor that is used for starting and stopping contexts. This is primarily for use by components
- * deploying contexts that want to do this in a multi-threaded manner.
+ * deploying contexts that want to do this in a multithreaded manner.
*/
ExecutorService getStartStopExecutor();
diff --git a/java/org/apache/catalina/LifecycleListener.java b/java/org/apache/catalina/LifecycleListener.java
index 50f38b16bc..11311e1f5b 100644
--- a/java/org/apache/catalina/LifecycleListener.java
+++ b/java/org/apache/catalina/LifecycleListener.java
@@ -18,7 +18,7 @@ package org.apache.catalina;
/**
- * Interface defining a listener for significant events (including "component start" and "component stop" generated by a
+ * Interface defining a listener for significant events (including "component start" and "component stop") generated by a
* component that implements the Lifecycle interface. The listener will be fired after the associated state change has
* taken place.
*
diff --git a/java/org/apache/catalina/UserDatabase.java b/java/org/apache/catalina/UserDatabase.java
index 00e67318b9..34826ba7c9 100644
--- a/java/org/apache/catalina/UserDatabase.java
+++ b/java/org/apache/catalina/UserDatabase.java
@@ -116,7 +116,7 @@ public interface UserDatabase {
/**
- * @return the {@link User} with the specified user name, if any; otherwise return <code>null</code>.
+ * @return the {@link User} with the specified username, if any; otherwise return <code>null</code>.
*
* @param username Name of the user to return
*/
diff --git a/java/org/apache/catalina/Valve.java b/java/org/apache/catalina/Valve.java
index 47c1f4c85b..bf82a535dd 100644
--- a/java/org/apache/catalina/Valve.java
+++ b/java/org/apache/catalina/Valve.java
@@ -81,7 +81,7 @@ public interface Valve {
* control to the caller.
* <li>Examine the properties of the specified Request and Response, wrap either or both of these objects to
* supplement their functionality, and pass them on.
- * <li>If the corresponding Response was not generated (and control was not returned, call the next Valve in the
+ * <li>If the corresponding Response was not generated (and control was not returned), call the next Valve in the
* pipeline (if there is one) by executing <code>getNext().invoke()</code>.
* <li>Examine, but not modify, the properties of the resulting Response (which was created by a subsequently
* invoked Valve or Container).
diff --git a/java/org/apache/catalina/WebResourceRoot.java b/java/org/apache/catalina/WebResourceRoot.java
index d2a9a34423..e473d53a06 100644
--- a/java/org/apache/catalina/WebResourceRoot.java
+++ b/java/org/apache/catalina/WebResourceRoot.java
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Set;
/**
- * Represents the complete set of resources for a web application. The resources for a web application comprise of
+ * Represents the complete set of resources for a web application. The resources for a web application consist of
* multiple ResourceSets and when looking for a Resource, the ResourceSets are processed in the following order:
* <ol>
* <li>Pre - Resources defined by the <PreResource> element in the web application's context.xml. Resources will
@@ -62,7 +62,7 @@ import java.util.Set;
* adds all sorts complications including: - which ResourceSet to write to - unexpected behaviour when deleting a
* resource from one ResourceSet since that may unmask a resource in a lower priority ResourceSet so what was a delete
* looks like a replace with the user having no idea where the 'new' resource came from - how to handle PUT when the
- * target is read-only but it could be written to a higher priority ResourceSet that is read-write
+ * target is read-only, but it could be written to a higher priority ResourceSet that is read-write
*/
public interface WebResourceRoot extends Lifecycle {
/**
@@ -95,7 +95,7 @@ public interface WebResourceRoot extends Lifecycle {
* calls to this method until the web application is reloaded. No guarantee is made as to what the search order for
* JAR files may be.
*
- * @param path The path of the class loader resource of interest relative to the the root of class loader resources
+ * @param path The path of the class loader resource of interest relative to the root of class loader resources
* for this web application.
*
* @return The object that represents the class loader resource at the given path
@@ -190,7 +190,7 @@ public interface WebResourceRoot extends Lifecycle {
* @param base The location of the resources
* @param archivePath The path within the resource to the archive where the content is to be found. If there is no
* archive then this should be <code>null</code>.
- * @param internalPath The path within the archive (or the resource if the archivePath is <code>null</code> where
+ * @param internalPath The path within the archive (or the resource if the archivePath is <code>null</code>) where
* the content is to be found. It must start with '/'.
*/
void createWebResourceSet(ResourceSetType type, String webAppMount, String base, String archivePath,
@@ -317,7 +317,7 @@ public interface WebResourceRoot extends Lifecycle {
/**
* Controls whether the track locked files feature is enabled. If enabled, all calls to methods that return objects
- * that lock a file and need to be closed to release that lock (e.g. {@link WebResource#getInputStream()} will
+ * that lock a file and need to be closed to release that lock (e.g. {@link WebResource#getInputStream()}) will
* perform a number of additional tasks.
* <ul>
* <li>The stack trace at the point where the method was called will be recorded and associated with the returned
@@ -393,7 +393,7 @@ public interface WebResourceRoot extends Lifecycle {
/**
* Obtain the current caching strategy.
* <p>
- * The default implementation returns {@code null}. Sub-classes wishing to utilise a {@link CacheStrategy} should
+ * The default implementation returns {@code null}. Subclasses wishing to utilise a {@link CacheStrategy} should
* provide an appropriate implementation.
*
* @return the current caching strategy or {@code null} if no strategy has been configured
@@ -405,7 +405,7 @@ public interface WebResourceRoot extends Lifecycle {
/**
* Set the current caching strategy.
* <p>
- * The default implementation is a NO-OP. Sub-classes wishing to utilise a {@link CacheStrategy} should provide an
+ * The default implementation is a NO-OP. Subclasses wishing to utilise a {@link CacheStrategy} should provide an
* appropriate implementation.
*
* @param strategy The new strategy to use or {@code null} for no strategy
diff --git a/java/org/apache/catalina/Wrapper.java b/java/org/apache/catalina/Wrapper.java
index 275649de8a..441acd39c2 100644
--- a/java/org/apache/catalina/Wrapper.java
+++ b/java/org/apache/catalina/Wrapper.java
@@ -293,14 +293,14 @@ public interface Wrapper extends Container {
/**
- * @return the multi-part configuration for the associated Servlet. If no multi-part configuration has been defined,
+ * @return the multipart configuration for the associated Servlet. If no multipart configuration has been defined,
* then <code>null</code> will be returned.
*/
MultipartConfigElement getMultipartConfigElement();
/**
- * Set the multi-part configuration for the associated Servlet. To clear the multi-part configuration specify
+ * Set the multipart configuration for the associated Servlet. To clear the multipart configuration specify
* <code>null</code> as the new value.
*
* @param multipartConfig The configuration associated with the Servlet
diff --git a/java/org/apache/catalina/ant/AbstractCatalinaTask.java b/java/org/apache/catalina/ant/AbstractCatalinaTask.java
index 810929a4d9..75e14bf234 100644
--- a/java/org/apache/catalina/ant/AbstractCatalinaTask.java
+++ b/java/org/apache/catalina/ant/AbstractCatalinaTask.java
@@ -169,7 +169,6 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
public void execute(String command, InputStream istream, String contentType, long contentLength)
throws BuildException {
- URLConnection conn = null;
InputStreamReader reader = null;
try {
// Set up authorization with our credentials
@@ -177,8 +176,7 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
// Create a connection for this command
URI uri = new URI(url + command);
- uri.parseServerAuthority();
- conn = uri.toURL().openConnection();
+ URLConnection conn = uri.parseServerAuthority().toURL().openConnection();
HttpURLConnection hconn = (HttpURLConnection) conn;
// Set up standard connection characteristics
@@ -209,13 +207,8 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
// Send the request data (if any)
if (istream != null) {
- try (OutputStream ostream = hconn.getOutputStream()) {
+ try (istream; OutputStream ostream = hconn.getOutputStream()) {
IOTools.flow(istream, ostream);
- } finally {
- try {
- istream.close();
- } catch (Exception e) {
- }
}
}
@@ -271,7 +264,6 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
} catch (IOException ioe) {
// Ignore
}
- reader = null;
}
if (istream != null) {
try {
@@ -294,12 +286,10 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
* appropriate Authorization when the next request is made (that includes a request body).
*/
private void preAuthenticate() throws IOException, URISyntaxException {
- URLConnection conn = null;
// Create a connection for this command
URI uri = new URI(url);
- uri.parseServerAuthority();
- conn = uri.toURL().openConnection();
+ URLConnection conn = uri.parseServerAuthority().toURL().openConnection();
HttpURLConnection hconn = (HttpURLConnection) conn;
// Set up standard connection characteristics
diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorCondition.java b/java/org/apache/catalina/ant/jmx/JMXAccessorCondition.java
index 9fe020b2ac..563bb1cd8f 100644
--- a/java/org/apache/catalina/ant/jmx/JMXAccessorCondition.java
+++ b/java/org/apache/catalina/ant/jmx/JMXAccessorCondition.java
@@ -171,7 +171,7 @@ public class JMXAccessorCondition extends JMXAccessorConditionBase {
* @return true if there is no unless condition, or there is a named property but it doesn't exist
*/
protected boolean testUnlessCondition() {
- if (unlessCondition == null || "".equals(unlessCondition)) {
+ if (unlessCondition == null || unlessCondition.isEmpty()) {
return true;
}
return getProject().getProperty(unlessCondition) == null;
diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorInvokeTask.java b/java/org/apache/catalina/ant/jmx/JMXAccessorInvokeTask.java
index 50f2d65064..872fa09f28 100644
--- a/java/org/apache/catalina/ant/jmx/JMXAccessorInvokeTask.java
+++ b/java/org/apache/catalina/ant/jmx/JMXAccessorInvokeTask.java
@@ -53,25 +53,23 @@ import org.apache.tools.ant.BuildException;
* </pre>
*
* </li>
- * <li>Create new AccessLogger at localhost <code>
+ * <li>Create new AccessLogger at localhost
+ * <pre>
* <jmx:invoke
* name="Catalina:type=MBeanFactory"
* operation="createAccessLoggerValve"
- * resultproperty="accessLoggerObjectName"
- * >
+ * resultproperty="accessLoggerObjectName">
* <arg value="Catalina:type=Host,host=localhost"/>
* </jmx:invoke>
- *
- * </code></li>
- * <li>Remove existing AccessLogger at localhost <code>
+ * </pre></li>
+ * <li>Remove existing AccessLogger at localhost
+ * <pre>
* <jmx:invoke
* name="Catalina:type=MBeanFactory"
- * operation="removeValve"
- * >
+ * operation="removeValve">
* <arg value="Catalina:type=Valve,name=AccessLogValve,host=localhost"/>
* </jmx:invoke>
- *
- * </code></li>
+ * </pre></li>
* </ul>
* <p>
* First call to a remote MBeanserver save the JMXConnection a referenz <em>jmx.server</em>
@@ -153,8 +151,8 @@ public class JMXAccessorInvokeTask extends JMXAccessorTask {
if (args == null) {
result = jmxServerConnection.invoke(new ObjectName(name), operation, null, null);
} else {
- Object argsA[] = new Object[args.size()];
- String sigA[] = new String[args.size()];
+ Object[] argsA = new Object[args.size()];
+ String[] sigA = new String[args.size()];
for (int i = 0; i < args.size(); i++) {
Arg arg = args.get(i);
if (arg.getType() == null) {
diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java b/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java
index 0098f6acb7..00e4acb05b 100644
--- a/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java
+++ b/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java
@@ -102,7 +102,7 @@ public class JMXAccessorQueryTask extends JMXAccessorTask {
*/
protected String jmxQuery(MBeanServerConnection jmxServerConnection, String qry) {
String isError = null;
- Set<ObjectName> names = null;
+ Set<ObjectName> names;
String resultproperty = getResultproperty();
try {
names = jmxServerConnection.queryNames(new ObjectName(qry), null);
@@ -118,7 +118,7 @@ public class JMXAccessorQueryTask extends JMXAccessorTask {
if (resultproperty != null) {
int oindex = 0;
- String pname = null;
+ String pname;
for (ObjectName oname : names) {
pname = resultproperty + "." + Integer.toString(oindex) + ".";
oindex++;
@@ -134,8 +134,8 @@ public class JMXAccessorQueryTask extends JMXAccessorTask {
protected void bindAttributes(MBeanServerConnection jmxServerConnection, String pname, ObjectName oname) {
try {
MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
- MBeanAttributeInfo attrs[] = minfo.getAttributes();
- Object value = null;
+ MBeanAttributeInfo[] attrs = minfo.getAttributes();
+ Object value;
for (MBeanAttributeInfo attr : attrs) {
if (!attr.isReadable()) {
diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorSetTask.java b/java/org/apache/catalina/ant/jmx/JMXAccessorSetTask.java
index fdb8270ca3..ec84247267 100644
--- a/java/org/apache/catalina/ant/jmx/JMXAccessorSetTask.java
+++ b/java/org/apache/catalina/ant/jmx/JMXAccessorSetTask.java
@@ -184,7 +184,7 @@ public class JMXAccessorSetTask extends JMXAccessorTask {
ObjectName oname = new ObjectName(name);
String mattrType = null;
MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
- MBeanAttributeInfo attrs[] = minfo.getAttributes();
+ MBeanAttributeInfo[] attrs = minfo.getAttributes();
for (int i = 0; mattrType == null && i < attrs.length; i++) {
if (attribute.equals(attrs[i].getName())) {
mattrType = attrs[i].getType();
diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorTask.java b/java/org/apache/catalina/ant/jmx/JMXAccessorTask.java
index 585461470d..e45a685a34 100644
--- a/java/org/apache/catalina/ant/jmx/JMXAccessorTask.java
+++ b/java/org/apache/catalina/ant/jmx/JMXAccessorTask.java
@@ -308,7 +308,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
public void execute() throws BuildException {
if (testIfCondition() && testUnlessCondition()) {
try {
- String error = null;
+ String error;
MBeanServerConnection jmxServerConnection = getJMXConnection();
error = jmxExecute(jmxServerConnection);
@@ -370,7 +370,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
* @return true if there is no if condition, or the named property exists
*/
protected boolean testIfCondition() {
- if (ifCondition == null || "".equals(ifCondition)) {
+ if (ifCondition == null || ifCondition.isEmpty()) {
return true;
}
return getProperty(ifCondition) != null;
@@ -382,7 +382,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
* @return true if there is no unless condition, or there is a named property but it doesn't exist
*/
protected boolean testUnlessCondition() {
- if (unlessCondition == null || "".equals(unlessCondition)) {
+ if (unlessCondition == null || unlessCondition.isEmpty()) {
return true;
}
return getProperty(unlessCondition) == null;
@@ -409,7 +409,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
public static MBeanServerConnection accessJMXConnection(Project project, String url, String host, String port,
String username, String password, String refId) throws MalformedURLException, IOException {
MBeanServerConnection jmxServerConnection = null;
- boolean isRef = project != null && refId != null && refId.length() > 0;
+ boolean isRef = project != null && refId != null && !refId.isEmpty();
if (isRef) {
Object pref = project.getReference(refId);
try {
@@ -442,7 +442,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
MBeanServerConnection jmxServerConnection = null;
if (isUseRef()) {
- Object pref = null;
+ Object pref;
if (getProject() != null) {
pref = getProject().getReference(getRef());
if (pref != null) {
@@ -639,7 +639,7 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
if (delim != null) {
StringTokenizer tokenizer = new StringTokenizer(result.toString(), delim);
int size = 0;
- for (; tokenizer.hasMoreTokens();) {
+ while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (setProperty(propertyPrefix + "." + size, token)) {
size++;
diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
index 9cc82f3c56..dff9aefbef 100644
--- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
+++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
@@ -143,7 +143,7 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticat
* Should a session always be used once a user is authenticated? This may offer some performance benefits since the
* session can then be used to cache the authenticated Principal, hence removing the need to authenticate the user
* via the Realm on every request. This may be of help for combinations such as BASIC authentication used with the
- * JNDIRealm or DataSourceRealms. However there will also be the performance cost of creating and GC'ing the
+ * JNDIRealm or DataSourceRealms. However, there will also be the performance cost of creating and GC'ing the
* session. By default, a session will not be created.
*/
protected boolean alwaysUseSession = false;
@@ -420,7 +420,7 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticat
}
/**
- * Sets the flag whether authentication information will be send to a reverse proxy on a forwarded request.
+ * Sets the flag whether authentication information will be sent to a reverse proxy on a forwarded request.
*
* @param sendAuthInfoResponseHeaders {@code true} if response headers shall be sent, {@code false} otherwise
*/
@@ -751,12 +751,12 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticat
// ------------------------------------------------------ Protected Methods
/**
- * Provided for sub-classes to implement their specific authentication mechanism.
+ * Provided for subclasses to implement their specific authentication mechanism.
*
* @param request The request that triggered the authentication
* @param response The response associated with the request
*
- * @return {@code true} if the the user was authenticated, otherwise {@code
+ * @return {@code true} if the user was authenticated, otherwise {@code
* false}, in which case an authentication challenge will have been written to the response
*
* @throws IOException If an I/O problem occurred during the authentication process
@@ -929,7 +929,7 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticat
Principal authorized = context.getRealm().authenticate(username);
if (authorized == null) {
// Realm doesn't recognise user. Create a user with no roles
- // from the authenticated user name
+ // from the authenticated username
if (log.isDebugEnabled()) {
log.debug(sm.getString("authenticator.check.authorizeFail", username));
}
diff --git a/java/org/apache/catalina/authenticator/BasicAuthenticator.java b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
index f0127a1c0d..1a1eb2cfb0 100644
--- a/java/org/apache/catalina/authenticator/BasicAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/BasicAuthenticator.java
@@ -52,7 +52,7 @@ public class BasicAuthenticator extends AuthenticatorBase {
public void setCharset(String charsetString) {
- // Only acceptable options are null, "" or "UTF-8" (case insensitive)
+ // Only acceptable options are null, "" or "UTF-8" (case-insensitive)
if (charsetString == null || charsetString.isEmpty()) {
charset = StandardCharsets.ISO_8859_1;
} else if ("UTF-8".equalsIgnoreCase(charsetString)) {
diff --git a/java/org/apache/catalina/authenticator/Constants.java b/java/org/apache/catalina/authenticator/Constants.java
index 5485782d5c..666ae89721 100644
--- a/java/org/apache/catalina/authenticator/Constants.java
+++ b/java/org/apache/catalina/authenticator/Constants.java
@@ -74,7 +74,7 @@ public class Constants {
/**
* If the <code>cache</code> property of the authenticator is set, and the current request is part of a session, the
- * user name used to authenticate this user will be cached under this key to avoid the need for repeated calls to
+ * username used to authenticate this user will be cached under this key to avoid the need for repeated calls to
* <code>Realm.authenticate()</code>.
*/
public static final String SESS_USERNAME_NOTE = "org.apache.catalina.session.USERNAME";
diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index 989a9885b6..7e83f6d670 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -375,7 +375,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
String ipTimeKey = request.getRemoteAddr() + ":" + currentTime + ":" + getKey();
- // Note: The digest used to generate the nonce is independent of the the digest used for authentication.
+ // Note: The digest used to generate the nonce is independent of the digest used for authentication.
byte[] buffer = ConcurrentMessageDigest.digest(NONCE_DIGEST, ipTimeKey.getBytes(StandardCharsets.ISO_8859_1));
String nonce = currentTime + ":" + HexUtils.toHexString(buffer);
@@ -637,7 +637,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
}
}
String serverIpTimeKey = request.getRemoteAddr() + ":" + nonceTime + ":" + key;
- // Note: The digest used to generate the nonce is independent of the the digest used for authentication/
+ // Note: The digest used to generate the nonce is independent of the digest used for authentication/
byte[] buffer =
ConcurrentMessageDigest.digest(NONCE_DIGEST, serverIpTimeKey.getBytes(StandardCharsets.ISO_8859_1));
String digestServerIpTimeKey = HexUtils.toHexString(buffer);
diff --git a/java/org/apache/catalina/authenticator/FormAuthenticator.java b/java/org/apache/catalina/authenticator/FormAuthenticator.java
index fb5febe264..ab99aa1987 100644
--- a/java/org/apache/catalina/authenticator/FormAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/FormAuthenticator.java
@@ -81,7 +81,7 @@ public class FormAuthenticator extends AuthenticatorBase {
// ------------------------------------------------------------- Properties
/**
- * Return the character encoding to use to read the user name and password.
+ * Return the character encoding to use to read the username and password.
*
* @return The name of the character encoding
*/
@@ -91,7 +91,7 @@ public class FormAuthenticator extends AuthenticatorBase {
/**
- * Set the character encoding to be used to read the user name and password.
+ * Set the character encoding to be used to read the username and password.
*
* @param encoding The name of the encoding to use
*/
@@ -136,7 +136,7 @@ public class FormAuthenticator extends AuthenticatorBase {
* Configures the maximum session timeout to be used during authentication if the authentication process creates a
* session.
*
- * @param authenticationSessionTimeout The maximum session timeout to use duriing authentication if the
+ * @param authenticationSessionTimeout The maximum session timeout to use during authentication if the
* authentication process creates a session
*/
public void setAuthenticationSessionTimeout(int authenticationSessionTimeout) {
@@ -227,7 +227,7 @@ public class FormAuthenticator extends AuthenticatorBase {
// No -- Save this request and redirect to the form login page
if (!loginAction) {
// If this request was to the root of the context without a trailing
- // '/', need to redirect to add it else the submit of the login form
+ // '/', need to redirect to add it else the submission of the login form
// may not go to the correct web application
if (request.getServletPath().isEmpty() && request.getPathInfo() == null) {
StringBuilder location = new StringBuilder(requestURI);
@@ -369,9 +369,7 @@ public class FormAuthenticator extends AuthenticatorBase {
Session session = request.getSessionInternal(false);
if (session != null) {
SavedRequest savedRequest = (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE);
- if (savedRequest != null && decodedRequestURI.equals(savedRequest.getDecodedRequestURI())) {
- return true;
- }
+ return savedRequest != null && decodedRequestURI.equals(savedRequest.getDecodedRequestURI());
}
return false;
@@ -510,7 +508,7 @@ public class FormAuthenticator extends AuthenticatorBase {
/**
* Does this request match the saved one (so that it must be the redirect we signaled after successful
- * authentication?
+ * authentication?)
*
* @param request The request to be verified
*
@@ -642,7 +640,7 @@ public class FormAuthenticator extends AuthenticatorBase {
// HttpInputBuffer. Processing the saved request body will overwrite
// these bytes. Configuring the HttpInputBuffer to retain these bytes as
// it would in a normal request would require some invasive API changes.
- // Therefore force the conversion to String now so the correct values
+ // Therefore, force the conversion to String now so the correct values
// are presented if the application requests them.
request.getCoyoteRequest().requestURI().toStringType();
request.getCoyoteRequest().queryString().toStringType();
diff --git a/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java b/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
index 2cf878f867..16f26046a4 100644
--- a/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
@@ -86,7 +86,7 @@ public final class NonLoginAuthenticator extends AuthenticatorBase {
}
// No Principal means the user is not already authenticated
- // and so will not be assigned any roles. It is safe to
+ // and so will not be assigned any roles. It is safe
// to say the user is now authenticated because access to
// protected resources will only be allowed with a matching role.
// i.e. SC_FORBIDDEN (403 status) will be generated later.
diff --git a/java/org/apache/catalina/authenticator/SingleSignOn.java b/java/org/apache/catalina/authenticator/SingleSignOn.java
index 11f079d467..6752362fb4 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOn.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOn.java
@@ -299,7 +299,7 @@ public class SingleSignOn extends ValveBase {
* Process a session destroyed event by removing references to that session from the caches and - if the session
* destruction is the result of a logout - destroy the associated SSO session.
*
- * @param ssoId The ID of the SSO session which which the destroyed session was associated
+ * @param ssoId The id of the SSO session with which the destroyed session was associated
* @param session The session that has been destroyed
*/
public void sessionDestroyed(String ssoId, Session session) {
@@ -556,7 +556,7 @@ public class SingleSignOn extends ValveBase {
// Remove the inactive session from SingleSignOnEntry
entry.removeSession(session);
- // If there are not sessions left in the SingleSignOnEntry,
+ // If there are no sessions left in the SingleSignOnEntry,
// deregister the entry.
if (entry.findSessions().isEmpty()) {
deregister(ssoId);
diff --git a/java/org/apache/catalina/authenticator/SingleSignOnEntry.java b/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
index 1465bb7675..7155455136 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOnEntry.java
@@ -104,7 +104,7 @@ public class SingleSignOnEntry implements Serializable {
/**
* Returns the HTTP Session identifiers associated with this SSO.
*
- * @return The identifiers for the HTTP sessions that are current associated with this SSo entry
+ * @return the identifiers for the HTTP sessions that are currently associated with this SSO entry
*/
public Set<SingleSignOnSessionKey> findSessions() {
return sessionKeys.keySet();
@@ -148,9 +148,9 @@ public class SingleSignOnEntry implements Serializable {
}
/**
- * Gets the user name provided by the user as part of the authentication process.
+ * Gets the username provided by the user as part of the authentication process.
*
- * @return The user name that was authenticated as part of the authentication that triggered the creation of the SSO
+ * @return The username that was authenticated as part of the authentication that triggered the creation of the SSO
* entry
*/
public String getUsername() {
diff --git a/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java b/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
index b740594a71..d2d0da2ddf 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOnSessionKey.java
@@ -101,14 +101,6 @@ public class SingleSignOnSessionKey implements Serializable {
// Session ID is 32. Standard text is 36. Host could easily be 20+.
// Context could be anything from 0 upwards. 128 seems like a reasonable
// size to accommodate most cases without being too big.
- StringBuilder sb = new StringBuilder(128);
- sb.append("Host: [");
- sb.append(hostName);
- sb.append("], Context: [");
- sb.append(contextName);
- sb.append("], SessionID: [");
- sb.append(sessionId);
- sb.append(']');
- return sb.toString();
+ return "Host: [" + hostName + "], Context: [" + contextName + "], SessionID: [" + sessionId + ']';
}
}
diff --git a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
index 95840af6a7..03bc77b1c6 100644
--- a/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
@@ -299,10 +299,10 @@ public class SpnegoAuthenticator extends AuthenticatorBase {
/**
* This class implements a hack around an incompatibility between the SPNEGO implementation in Windows and the
* SPNEGO implementation in Java 8 update 40 onwards. It was introduced by the change to fix this bug:
- * https://bugs.openjdk.java.net/browse/JDK-8048194 (note: the change applied is not the one suggested in the bug
- * report)
+ * <a href="https://bugs.openjdk.java.net/browse/JDK-8048194">JDK-8048194</a> (note: the change applied is not the
+ * one suggested in the bug report)
* <p>
- * It is not clear to me if Windows, Java or Tomcat is at fault here. I think it is Java but I could be wrong.
+ * It is not clear to me if Windows, Java or Tomcat is at fault here. I think it is Java, but I could be wrong.
* <p>
* This hack works by re-ordering the list of mechTypes in the NegTokenInit token.
*/
diff --git a/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java b/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
index 597c51fa31..e178596448 100644
--- a/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
+++ b/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
@@ -1,18 +1,18 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.catalina.authenticator.jaspic;
@@ -556,7 +556,7 @@ public class AuthConfigFactoryImpl extends AuthConfigFactory {
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject)
- throws AuthException {
+ throws AuthException {
return module.validateRequest(messageInfo, clientSubject, serviceSubject);
}
diff --git a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
index 9295eb81bf..ab9e442c50 100644
--- a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
+++ b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java b/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
index bbc64a330e..107357504a 100644
--- a/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
+++ b/java/org/apache/catalina/authenticator/jaspic/SimpleAuthConfigProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
index 23d76a0240..5bb29e0014 100644
--- a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
+++ b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthConfig.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
index dca6bd0450..0dd2cf0fbd 100644
--- a/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
+++ b/java/org/apache/catalina/authenticator/jaspic/SimpleServerAuthContext.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 57c4a1dae0..fc41998fec 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -137,7 +137,7 @@ public class CoyoteAdapter implements Adapter {
}
} else if (status == SocketEvent.ERROR) {
// An I/O error occurred on a non-container thread which means
- // that the socket needs to be closed so set success to false to
+ // that the socket needs to be closed so set success as false to
// trigger a close
success = false;
Throwable t = (Throwable) req.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
@@ -255,7 +255,7 @@ public class CoyoteAdapter implements Adapter {
if (error.get()) {
if (request.isAsyncCompleting() || request.isAsyncDispatching()) {
// Connection will be forcibly closed which will prevent completion/dispatch happening at the usual
- // point. Trigger post processing here.
+ // point. Trigger post-processing here.
res.action(ActionCode.ASYNC_POST_PROCESS, null);
}
success = false;
@@ -645,7 +645,7 @@ public class CoyoteAdapter implements Adapter {
// Character decoding
convertURI(decodedURI, request);
// URIEncoding values are limited to US-ASCII supersets.
- // Therefore it is not necessary to check that the URI remains
+ // Therefore, it is not necessary to check that the URI remains
// normalized after character decoding
} else {
response.sendError(400, sm.getString("coyoteAdapter.invalidURI"));
@@ -694,7 +694,7 @@ public class CoyoteAdapter implements Adapter {
}
while (mapRequired) {
- // This will map the the latest version by default
+ // This will map the latest version by default
connector.getService().getMapper().map(serverName, decodedURI, version, request.getMappingData());
// If there is no context at this point, either this is a 404
@@ -869,7 +869,7 @@ public class CoyoteAdapter implements Adapter {
// result preventing excessive calls to the Realm.
} else {
// The connector isn't configured for authorization. Create a
- // user without any roles using the supplied user name.
+ // user without any roles using the supplied username.
request.setUserPrincipal(new CoyotePrincipal(username));
}
}
@@ -1076,7 +1076,7 @@ public class CoyoteAdapter implements Adapter {
/**
- * Character conversion of the a US-ASCII MessageBytes.
+ * Character conversion of the US-ASCII MessageBytes.
*
* @param mb The MessageBytes instance containing the bytes that should be converted to chars
*/
diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java
index 566155d0a2..b5e6a38088 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -273,7 +273,7 @@ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, A
// threads for each stream. For HTTP/2 the two operations have to be
// performed atomically else it is possible for the connection thread to
// read more data in to the buffer after the stream thread checks for
- // available network data but before it registers for read.
+ // available network data, but before it registers for read.
if (availableInThisBuffer() > 0) {
return true;
}
diff --git a/java/org/apache/catalina/connector/OutputBuffer.java b/java/org/apache/catalina/connector/OutputBuffer.java
index 86adb9d4ad..1dd3b0e30f 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -329,7 +329,7 @@ public class OutputBuffer extends Writer {
try {
coyoteResponse.doWrite(buf);
} catch (CloseNowException e) {
- // Catch this sub-class as it requires specific handling.
+ // Catch this subclass as it requires specific handling.
// Examples where this exception is thrown:
// - HTTP/2 stream timeout
// Prevent further output for this response
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index 343c407887..216a7a067b 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -2257,9 +2257,7 @@ public class Request implements HttpServletRequest {
if ((session == null) || !session.isValid()) {
// Check for parallel deployment contexts
- if (getMappingData().contexts == null) {
- return false;
- } else {
+ if (getMappingData().contexts != null) {
for (int i = (getMappingData().contexts.length); i > 0; i--) {
Context ctxt = getMappingData().contexts[i - 1];
try {
@@ -2270,8 +2268,8 @@ public class Request implements HttpServletRequest {
// Ignore
}
}
- return false;
}
+ return false;
}
return true;
diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java
index 0c7fb244f4..3c1574c985 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -907,7 +907,7 @@ public class ApplicationContext implements ServletContext {
supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
}
- // SSL not enabled by default as it can only used on its own
+ // SSL not enabled by default as it can only be used on its own
// Context > Host > Engine > Service
Connector[] connectors = service.findConnectors();
// Need at least one SSL enabled connector to use the SSL session ID.
@@ -948,7 +948,7 @@ public class ApplicationContext implements ServletContext {
}
}
- // Check SSL has not be configured with anything else
+ // Check SSL has not been configured with anything else
if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
if (sessionTrackingModes.size() > 1) {
throw new IllegalArgumentException(
diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java
index 2f2cf47e0c..1a138cb2f4 100644
--- a/java/org/apache/catalina/core/ApplicationDispatcher.java
+++ b/java/org/apache/catalina/core/ApplicationDispatcher.java
@@ -286,25 +286,20 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
}
wrapResponse(state);
- // Handle an HTTP named dispatcher forward
+ ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
+ HttpServletRequest hrequest = state.hrequest;
if (servletPath == null && pathInfo == null) {
+ // Handle an HTTP named dispatcher forward
- ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
- HttpServletRequest hrequest = state.hrequest;
wrequest.setRequestURI(hrequest.getRequestURI());
wrequest.setContextPath(hrequest.getContextPath());
wrequest.setServletPath(hrequest.getServletPath());
wrequest.setPathInfo(hrequest.getPathInfo());
wrequest.setQueryString(hrequest.getQueryString());
- processRequest(request, response, state);
- }
-
- // Handle an HTTP path-based forward
- else {
+ } else {
+ // Handle an HTTP path-based forward
- ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
- HttpServletRequest hrequest = state.hrequest;
if (hrequest.getAttribute(FORWARD_REQUEST_URI) == null) {
wrequest.setAttribute(FORWARD_REQUEST_URI, hrequest.getRequestURI());
wrequest.setAttribute(FORWARD_CONTEXT_PATH, hrequest.getContextPath());
@@ -324,8 +319,8 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
}
wrequest.setMapping(mapping);
- processRequest(request, response, state);
}
+ processRequest(request, response, state);
if (request.isAsyncStarted()) {
// An async request was started during the forward, don't close the
@@ -354,7 +349,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
}
if (!finished) {
// Servlet SRV.6.2.2. The Request/Response may have been wrapped
- // and may no longer be instance of RequestFacade
+ // and may no longer be an instance of RequestFacade
if (wrapper.getLogger().isDebugEnabled()) {
wrapper.getLogger().debug(sm.getString("applicationDispatcher.customResponse", response.getClass()));
}
@@ -458,23 +453,17 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
// Create a wrapped response to use for this request
wrapResponse(state);
- // Handle an HTTP named dispatcher include
+ ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
if (name != null) {
+ // Handle an HTTP named dispatcher include
- ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
wrequest.setAttribute(Globals.NAMED_DISPATCHER_ATTR, name);
if (servletPath != null) {
wrequest.setServletPath(servletPath);
}
- wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.INCLUDE);
- wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
- invoke(state.outerRequest, state.outerResponse, state);
- }
-
- // Handle an HTTP path based include
- else {
+ } else {
+ // Handle an HTTP path based include
- ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
String contextPath = context.getPath();
if (requestURI != null) {
wrequest.setAttribute(INCLUDE_REQUEST_URI, requestURI);
@@ -496,10 +485,10 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
wrequest.setAttribute(INCLUDE_MAPPING, mapping);
}
- wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.INCLUDE);
- wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
- invoke(state.outerRequest, state.outerResponse, state);
}
+ wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.INCLUDE);
+ wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
+ invoke(state.outerRequest, state.outerResponse, state);
}
@@ -878,7 +867,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
ServletRequest originalRequest = ApplicationFilterChain.getLastServicedRequest();
ServletResponse originalResponse = ApplicationFilterChain.getLastServicedResponse();
- // Some forwards, eg from valves will not set original values
+ // Some forwards, e.g. from valves will not set original values
if (originalRequest == null || originalResponse == null) {
return;
}
@@ -892,7 +881,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
originalRequest = ((ServletRequestWrapper) originalRequest).getRequest();
}
// compare with the dispatched request
- while (!same) {
+ while (true) {
if (originalRequest.equals(dispatchedRequest)) {
same = true;
}
@@ -915,7 +904,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
originalResponse = ((ServletResponseWrapper) originalResponse).getResponse();
}
// compare with the dispatched response
- while (!same) {
+ while (true) {
if (originalResponse.equals(dispatchedResponse)) {
same = true;
}
diff --git a/java/org/apache/catalina/core/ApplicationFilterConfig.java b/java/org/apache/catalina/core/ApplicationFilterConfig.java
index cd7050ac9a..d0c62a7e5e 100644
--- a/java/org/apache/catalina/core/ApplicationFilterConfig.java
+++ b/java/org/apache/catalina/core/ApplicationFilterConfig.java
@@ -322,7 +322,7 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
}
try {
oname = new ObjectName(onameStr);
- Registry.getRegistry(null, null).registerComponent(this, oname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(this, oname, null);
} catch (Exception ex) {
log.warn(sm.getString("applicationFilterConfig.jmxRegisterFail", getFilterClass(), getFilterName()), ex);
}
@@ -333,7 +333,7 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
// unregister this component
if (oname != null) {
try {
- Registry.getRegistry(null, null).unregisterComponent(oname);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(oname);
if (log.isDebugEnabled()) {
log.debug(sm.getString("applicationFilterConfig.jmxUnregister", getFilterClass(), getFilterName()));
}
diff --git a/java/org/apache/catalina/core/ApplicationResponse.java b/java/org/apache/catalina/core/ApplicationResponse.java
index 2173f0a597..e793a27fb7 100644
--- a/java/org/apache/catalina/core/ApplicationResponse.java
+++ b/java/org/apache/catalina/core/ApplicationResponse.java
@@ -66,7 +66,7 @@ class ApplicationResponse extends ServletResponseWrapper {
/**
- * Disallow <code>reset()</code> calls on a included response.
+ * Disallow <code>reset()</code> calls on an included response.
*
* @exception IllegalStateException if the response has already been committed
*/
diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java b/java/org/apache/catalina/core/AprLifecycleListener.java
index 3841001ca2..1d6af1aca5 100644
--- a/java/org/apache/catalina/core/AprLifecycleListener.java
+++ b/java/org/apache/catalina/core/AprLifecycleListener.java
@@ -33,7 +33,7 @@ import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;
/**
- * Implementation of <code>LifecycleListener</code> that will init and and destroy APR.
+ * Implementation of <code>LifecycleListener</code> that will init and destroy APR.
* <p>
* This listener must only be nested within {@link Server} elements.
* <p>
@@ -149,9 +149,9 @@ public class AprLifecycleListener implements LifecycleListener {
try {
initializeSSL();
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
- log.error(sm.getString("aprListener.sslInit"), t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
+ log.error(sm.getString("aprListener.sslInit"), throwable);
}
}
// Failure to initialize FIPS mode is fatal
@@ -179,8 +179,8 @@ public class AprLifecycleListener implements LifecycleListener {
try {
terminateAPR();
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
log.info(sm.getString("aprListener.aprDestroy"));
}
}
@@ -223,9 +223,9 @@ public class AprLifecycleListener implements LifecycleListener {
return;
} catch (Throwable t) {
// Library present but failed to load
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
- log.warn(sm.getString("aprListener.aprInitError", t.getMessage()), t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
+ log.warn(sm.getString("aprListener.aprInitError", throwable.getMessage()), throwable);
return;
}
if (tcnMajor > 1 && "off".equalsIgnoreCase(SSLEngine)) {
@@ -234,8 +234,8 @@ public class AprLifecycleListener implements LifecycleListener {
// Tomcat Native 2.x onwards requires SSL
terminateAPR();
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
}
return;
}
@@ -247,8 +247,8 @@ public class AprLifecycleListener implements LifecycleListener {
// is below required.
terminateAPR();
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
}
return;
}
diff --git a/java/org/apache/catalina/core/DefaultInstanceManager.java b/java/org/apache/catalina/core/DefaultInstanceManager.java
index e89f8bf95b..5c8bca4e31 100644
--- a/java/org/apache/catalina/core/DefaultInstanceManager.java
+++ b/java/org/apache/catalina/core/DefaultInstanceManager.java
@@ -189,7 +189,8 @@ public class DefaultInstanceManager implements InstanceManager {
}
/**
- * Call postConstruct method on the specified instance recursively from deepest superclass to actual class.
+ * Call postConstruct method on the specified instance recursively from the deepest superclass
+ * to actual class.
*
* @param instance object to call postconstruct methods on
* @param clazz (super) class to examine for postConstruct annotation.
@@ -226,7 +227,8 @@ public class DefaultInstanceManager implements InstanceManager {
/**
- * Call preDestroy method on the specified instance recursively from deepest superclass to actual class.
+ * Call preDestroy method on the specified instance recursively from the deepest superclass
+ * to actual class.
*
* @param instance object to call preDestroy methods on
* @param clazz (super) class to examine for preDestroy annotation.
diff --git a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
index ac1c8573eb..bc631ac5bd 100644
--- a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
@@ -64,7 +64,7 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
}
/**
- * Protect against resources being read for JAR files and, as a side-effect, the JAR file becoming locked. Note this
+ * Protect against resources being read for JAR files and, as a side effect, the JAR file becoming locked. Note this
* disables caching for all {@link URLConnection}s, regardless of type. Defaults to <code>true</code>.
*/
private boolean urlCacheProtection = true;
@@ -78,9 +78,9 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
}
/**
- * The first access to {@link DriverManager} will trigger the loading of all {@link java.sql.Driver}s in the the
+ * The first access to {@link DriverManager} will trigger the loading of all {@link java.sql.Driver}s in the
* current class loader. The web application level memory leak protection can take care of this in most cases but
- * triggering the loading here has fewer side-effects.
+ * triggering the loading here has fewer side effects.
*/
private boolean driverManagerProtection = true;
@@ -94,7 +94,7 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
/**
* List of comma-separated fully qualified class names to load and initialize during the startup of this Listener.
- * This allows to pre-load classes that are known to provoke classloader leaks if they are loaded during a request
+ * This allows to preload classes that are known to provoke classloader leaks if they are loaded during a request
* processing.
*/
private String classesToInitialize = null;
diff --git a/java/org/apache/catalina/core/NamingContextListener.java b/java/org/apache/catalina/core/NamingContextListener.java
index f0880fd163..c375441fe5 100644
--- a/java/org/apache/catalina/core/NamingContextListener.java
+++ b/java/org/apache/catalina/core/NamingContextListener.java
@@ -297,7 +297,7 @@ public class NamingContextListener implements LifecycleListener, PropertyChangeL
// unregister mbeans.
if (!objectNames.isEmpty()) {
Collection<ObjectName> names = objectNames.values();
- Registry registry = Registry.getRegistry(null, null);
+ Registry registry = Registry.getRegistryNonNull(null, null);
for (ObjectName objectName : names) {
registry.unregisterComponent(objectName);
}
@@ -979,7 +979,7 @@ public class NamingContextListener implements LifecycleListener, PropertyChangeL
try {
ObjectName on = createObjectName(resource);
actualResource = envCtx.lookup(resource.getName());
- Registry.getRegistry(null, null).registerComponent(actualResource, on, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(actualResource, on, null);
objectNames.put(resource.getName(), on);
} catch (Exception e) {
log.warn(sm.getString("naming.jmxRegistrationFailed", e));
@@ -1170,7 +1170,7 @@ public class NamingContextListener implements LifecycleListener, PropertyChangeL
ObjectName on = objectNames.get(name);
if (on != null) {
- Registry.getRegistry(null, null).unregisterComponent(on);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(on);
}
}
@@ -1231,7 +1231,7 @@ public class NamingContextListener implements LifecycleListener, PropertyChangeL
/**
- * Gets look up reference from resource if exist.
+ * Gets look up reference from resource if it exists.
*
* @param resourceBase resource base object
*
diff --git a/java/org/apache/catalina/core/StandardServer.java b/java/org/apache/catalina/core/StandardServer.java
index 94fe83eaf3..6d1125c371 100644
--- a/java/org/apache/catalina/core/StandardServer.java
+++ b/java/org/apache/catalina/core/StandardServer.java
@@ -797,7 +797,7 @@ public final class StandardServer extends LifecycleMBeanBase implements Server {
try {
// Note: Hard-coded domain used since this object is per Server/JVM
ObjectName sname = new ObjectName("Catalina:type=StoreConfig");
- MBeanServer server = Registry.getRegistry(null, null).getMBeanServer();
+ MBeanServer server = Registry.getRegistryNonNull(null, null).getMBeanServer();
if (server.isRegistered(sname)) {
server.invoke(sname, "storeConfig", null, null);
} else {
@@ -824,7 +824,7 @@ public final class StandardServer extends LifecycleMBeanBase implements Server {
try {
// Note: Hard-coded domain used since this object is per Server/JVM
ObjectName sname = new ObjectName("Catalina:type=StoreConfig");
- MBeanServer server = Registry.getRegistry(null, null).getMBeanServer();
+ MBeanServer server = Registry.getRegistryNonNull(null, null).getMBeanServer();
if (server.isRegistered(sname)) {
server.invoke(sname, "store", new Object[] { context }, new String[] { "java.lang.String" });
} else {
diff --git a/java/org/apache/catalina/core/StandardWrapper.java b/java/org/apache/catalina/core/StandardWrapper.java
index cc6c953e3c..03a1f4e193 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -201,7 +201,7 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
protected boolean swallowOutput = false;
// To support jmx attributes
- protected StandardWrapperValve swValve;
+ StandardWrapperValve swValve;
protected long loadTime = 0;
protected int classLoadTime = 0;
@@ -721,7 +721,7 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
try {
jspMonitorON = new ObjectName(oname.toString());
- Registry.getRegistry(null, null).registerComponent(instance, jspMonitorON, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(instance, jspMonitorON, null);
} catch (Exception ex) {
log.warn(sm.getString("standardWrapper.jspMonitorError", instance));
}
@@ -767,18 +767,18 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
// Restore the context ClassLoader
throw new ServletException(sm.getString("standardWrapper.notServlet", servletClass), e);
} catch (Throwable e) {
- e = ExceptionUtils.unwrapInvocationTargetException(e);
- ExceptionUtils.handleThrowable(e);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(e);
+ ExceptionUtils.handleThrowable(throwable);
unavailable(null);
// Added extra log statement for Bugzilla 36630:
// https://bz.apache.org/bugzilla/show_bug.cgi?id=36630
if (log.isDebugEnabled()) {
- log.debug(sm.getString("standardWrapper.instantiate", servletClass), e);
+ log.debug(sm.getString("standardWrapper.instantiate", servletClass), throwable);
}
// Restore the context ClassLoader
- throw new ServletException(sm.getString("standardWrapper.instantiate", servletClass), e);
+ throw new ServletException(sm.getString("standardWrapper.instantiate", servletClass), throwable);
}
if (multipartConfigElement == null) {
@@ -967,11 +967,11 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
}
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
fireContainerEvent("unload", this);
unloading = false;
- throw new ServletException(sm.getString("standardWrapper.destroyException", getName()), t);
+ throw new ServletException(sm.getString("standardWrapper.destroyException", getName()), throwable);
} finally {
// Annotation processing
if (!((Context) getParent()).getIgnoreAnnotations()) {
@@ -1002,7 +1002,7 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
instance = null;
if (isJspServlet && jspMonitorON != null) {
- Registry.getRegistry(null, null).unregisterComponent(jspMonitorON);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(jspMonitorON);
}
unloading = false;
@@ -1229,11 +1229,11 @@ public class StandardWrapper extends ContainerBase implements ServletConfig, Wra
if (this.getObjectName() != null) {
Notification notification = new Notification("j2ee.state.stopped", this.getObjectName(), sequenceNumber++);
broadcaster.sendNotification(notification);
- }
- // Send j2ee.object.deleted notification
- Notification notification = new Notification("j2ee.object.deleted", this.getObjectName(), sequenceNumber++);
- broadcaster.sendNotification(notification);
+ // Send j2ee.object.deleted notification
+ notification = new Notification("j2ee.object.deleted", this.getObjectName(), sequenceNumber++);
+ broadcaster.sendNotification(notification);
+ }
}
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index ed9180a592..5c795af407 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -477,7 +477,7 @@ public class CsrfPreventionFilter extends CsrfPreventionFilterBase {
/**
- * Determines whether a nonce should be created. This method is provided primarily for the benefit of sub-classes
+ * Determines whether a nonce should be created. This method is provided primarily for the benefit of subclasses
* that wish to customise this behaviour.
*
* @param request The request that triggered the need to potentially create the nonce.
@@ -491,7 +491,7 @@ public class CsrfPreventionFilter extends CsrfPreventionFilterBase {
/**
* Create a new {@link NonceCache} and store in the {@link HttpSession}. This method is provided primarily for the
- * benefit of sub-classes that wish to customise this behaviour.
+ * benefit of subclasses that wish to customise this behaviour.
*
* @param request The request that triggered the need to create the nonce cache. Unused by the default
* implementation.
@@ -511,7 +511,7 @@ public class CsrfPreventionFilter extends CsrfPreventionFilterBase {
/**
* Obtain the {@link NonceCache} associated with the request and/or session. This method is provided primarily for
- * the benefit of sub-classes that wish to customise this behaviour.
+ * the benefit of subclasses that wish to customise this behaviour.
*
* @param request The request that triggered the need to obtain the nonce cache. Unused by the default
* implementation.
@@ -578,7 +578,7 @@ public class CsrfPreventionFilter extends CsrfPreventionFilterBase {
/*
* Return the specified URL with the nonce added to the query string.
*
- * @param url URL to be modified
+ * @param url the URL to be modified
*/
private String addNonce(String url) {
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilterBase.java b/java/org/apache/catalina/filters/CsrfPreventionFilterBase.java
index 09b7f9facb..f45a56f314 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilterBase.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilterBase.java
@@ -79,9 +79,7 @@ public abstract class CsrfPreventionFilterBase extends FilterBase {
Class<?> clazz = Class.forName(randomClass);
randomSource = (Random) clazz.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
- ServletException se =
- new ServletException(sm.getString("csrfPrevention.invalidRandomClass", randomClass), e);
- throw se;
+ throw new ServletException(sm.getString("csrfPrevention.invalidRandomClass", randomClass), e);
}
}
@@ -95,7 +93,7 @@ public abstract class CsrfPreventionFilterBase extends FilterBase {
* Generate a once time token (nonce) for authenticating subsequent requests. The nonce generation is a simplified
* version of ManagerBase.generateSessionId().
*
- * @param request The request. Unused in this method but present for the the benefit of sub-classes.
+ * @param request The request. Unused in this method but present for the benefit of subclasses.
*
* @return the generated nonce
*/
diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java b/java/org/apache/catalina/filters/ExpiresFilter.java
index c1ca9a92aa..9c4890af60 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -445,7 +445,7 @@ public class ExpiresFilter extends FilterBase {
/**
* Duration unit
*/
- protected enum DurationUnit {
+ public enum DurationUnit {
DAY(Calendar.DAY_OF_YEAR),
HOUR(Calendar.HOUR),
MINUTE(Calendar.MINUTE),
@@ -473,6 +473,9 @@ public class ExpiresFilter extends FilterBase {
* <p>
* Can be expressed like '{@code access plus 1 month 15 days 2 hours}'.
* </p>
+ *
+ * @param durations List of duration elements.
+ * @param startingPoint Starting point of the elapse to set in the response.
*/
protected static class ExpiresConfiguration {
/**
@@ -510,7 +513,7 @@ public class ExpiresFilter extends FilterBase {
* ({@link StartingPoint#ACCESS_TIME}) or the last time the HTML-page/servlet-response was modified (
* {@link StartingPoint#LAST_MODIFICATION_TIME}).
*/
- protected enum StartingPoint {
+ public enum StartingPoint {
ACCESS_TIME,
LAST_MODIFICATION_TIME
}
@@ -1031,7 +1034,7 @@ public class ExpiresFilter extends FilterBase {
private static final String PARAMETER_EXPIRES_EXCLUDED_RESPONSE_STATUS_CODES = "ExpiresExcludedResponseStatusCodes";
/**
- * Convert a comma delimited list of numbers into an {@code int[]}.
+ * Convert a comma-delimited list of numbers into an {@code int[]}.
*
* @param commaDelimitedInts can be {@code null}
*
@@ -1080,7 +1083,7 @@ public class ExpiresFilter extends FilterBase {
}
/**
- * Convert an array of ints into a comma delimited string
+ * Convert an array of ints into a comma-delimited string
*
* @param ints The int array
*
@@ -1372,8 +1375,7 @@ public class ExpiresFilter extends FilterBase {
ExpiresConfiguration expiresConfiguration = parseExpiresConfiguration(value);
this.expiresConfigurationByContentType.put(contentType, expiresConfiguration);
} else if (name.equalsIgnoreCase(PARAMETER_EXPIRES_DEFAULT)) {
- ExpiresConfiguration expiresConfiguration = parseExpiresConfiguration(value);
- this.defaultExpiresConfiguration = expiresConfiguration;
+ this.defaultExpiresConfiguration = parseExpiresConfiguration(value);
} else if (name.equalsIgnoreCase(PARAMETER_EXPIRES_EXCLUDED_RESPONSE_STATUS_CODES)) {
this.excludedResponseStatusCodes = commaDelimitedListToIntArray(value);
} else {
diff --git a/java/org/apache/catalina/filters/FilterBase.java b/java/org/apache/catalina/filters/FilterBase.java
index d2522f3327..9207397046 100644
--- a/java/org/apache/catalina/filters/FilterBase.java
+++ b/java/org/apache/catalina/filters/FilterBase.java
@@ -63,7 +63,7 @@ public abstract class FilterBase implements Filter {
/**
* Determines if an exception when calling a setter or an unknown configuration attribute triggers the failure of
- * the this filter which in turn will prevent the web application from starting.
+ * this filter which in turn will prevent the web application from starting.
*
* @return <code>true</code> if a problem should trigger the failure of this filter, else <code>false</code>
*/
diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java b/java/org/apache/catalina/filters/RateLimitFilter.java
index 7fef01a7f7..17f630b92f 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -55,7 +55,7 @@ import org.apache.tomcat.util.res.StringManager;
* </p>
* <p>
* It is common to set up different restrictions for different URIs. For example, a login page or authentication script
- * is typically expected to get far less requests than the rest of the application, so you can add a filter definition
+ * is typically expected to get far fewer requests than the rest of the application, so you can add a filter definition
* that would allow only 5 requests per 15 seconds and map those URIs to it.
* </p>
* <p>
@@ -74,7 +74,7 @@ import org.apache.tomcat.util.res.StringManager;
* the client IP address, so if for example you are using the <a href="#Remote_IP_Filter">Remote IP Filter</a>, then the
* filter mapping for the Rate Limit Filter must come <em>after</em> the mapping of the Remote IP Filter to ensure that
* each request has its IP address resolved before the Rate Limit Filter is applied. Failure to do so will count
- * requests from different IPs in the same bucket and will result in a self inflicted DoS attack.
+ * requests from different IPs in the same bucket and will result in a self-inflicted DoS attack.
* </p>
*/
public class RateLimitFilter extends FilterBase {
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java
index 1c2d8c8ee9..6a49e0ab43 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -75,7 +75,7 @@ import org.apache.tomcat.util.res.StringManager;
* proxies:
* </p>
* <ul>
- * <li>Loop on the comma delimited list of IPs and hostnames passed by the preceding load balancer or proxy in the given
+ * <li>Loop on the comma-delimited list of IPs and hostnames passed by the preceding load balancer or proxy in the given
* request's Http header named <code>$remoteIpHeader</code> (default value <code>x-forwarded-for</code>). Values are
* processed in right-to-left order.</li>
* <li>For each ip/host of the list:
@@ -151,7 +151,7 @@ import org.apache.tomcat.util.res.StringManager;
* </tr>
* <tr>
* <td>protocolHeaderHttpsValue</td>
- * <td>Value of the <code>protocolHeader</code> to indicate that it is an Https request</td>
+ * <td>Value of the <code>protocolHeader</code> to indicate that it is a Https request</td>
* <td>N/A</td>
* <td>String like <code>https</code> or <code>ON</code></td>
* <td><code>https</code></td>
@@ -194,7 +194,7 @@ import org.apache.tomcat.util.res.StringManager;
* <p>
* XForwardedFilter configuration:
* </p>
- * <code>
+ * <pre>
* <filter>
* <filter-name>RemoteIpFilter</filter-name>
* <filter-class>org.apache.catalina.filters.RemoteIpFilter</filter-class>
@@ -220,7 +220,7 @@ import org.apache.tomcat.util.res.StringManager;
* <filter-name>RemoteIpFilter</filter-name>
* <url-pattern>/*</url-pattern>
* <dispatcher>REQUEST</dispatcher>
- * </filter-mapping></code>
+ * </filter-mapping></pre>
* <table border="1">
* <caption>Request Values</caption>
* <tr>
@@ -273,7 +273,7 @@ import org.apache.tomcat.util.res.StringManager;
* <p>
* RemoteIpFilter configuration:
* </p>
- * <code>
+ * <pre>
* <filter>
* <filter-name>RemoteIpFilter</filter-name>
* <filter-class>org.apache.catalina.filters.RemoteIpFilter</filter-class>
@@ -299,7 +299,7 @@ import org.apache.tomcat.util.res.StringManager;
* <filter-name>RemoteIpFilter</filter-name>
* <url-pattern>/*</url-pattern>
* <dispatcher>REQUEST</dispatcher>
- * </filter-mapping></code>
+ * </filter-mapping></pre>
* <table border="1">
* <caption>Request Values</caption>
* <tr>
@@ -335,7 +335,7 @@ import org.apache.tomcat.util.res.StringManager;
* <p>
* RemoteIpFilter configuration:
* </p>
- * <code>
+ * <pre>
* <filter>
* <filter-name>RemoteIpFilter</filter-name>
* <filter-class>org.apache.catalina.filters.RemoteIpFilter</filter-class>
@@ -361,7 +361,7 @@ import org.apache.tomcat.util.res.StringManager;
* <filter-name>RemoteIpFilter</filter-name>
* <url-pattern>/*</url-pattern>
* <dispatcher>REQUEST</dispatcher>
- * </filter-mapping></code>
+ * </filter-mapping></pre>
* <table border="1">
* <caption>Request Values</caption>
* <tr>
@@ -398,7 +398,7 @@ import org.apache.tomcat.util.res.StringManager;
* <p>
* RemoteIpFilter configuration:
* </p>
- * <code>
+ * <pre>
* <filter>
* <filter-name>RemoteIpFilter</filter-name>
* <filter-class>org.apache.catalina.filters.RemoteIpFilter</filter-class>
@@ -424,7 +424,7 @@ import org.apache.tomcat.util.res.StringManager;
* <filter-name>RemoteIpFilter</filter-name>
* <url-pattern>/*</url-pattern>
* <dispatcher>REQUEST</dispatcher>
- * </filter-mapping></code>
+ * </filter-mapping></pre>
* <table border="1">
* <caption>Request Values</caption>
* <tr>
@@ -1227,7 +1227,7 @@ public class RemoteIpFilter extends GenericFilter {
/**
* <p>
- * Case insensitive value of the protocol header to indicate that the incoming http request uses HTTPS.
+ * Case-insensitive value of the protocol header to indicate that the incoming http request uses HTTPS.
* </p>
* <p>
* Default value : <code>https</code>
@@ -1250,7 +1250,7 @@ public class RemoteIpFilter extends GenericFilter {
* Name of the http header that holds the list of trusted proxies that has been traversed by the http request.
* </p>
* <p>
- * The value of this header can be comma delimited.
+ * The value of this header can be comma-delimited.
* </p>
* <p>
* Default value : <code>X-Forwarded-By</code>
@@ -1267,7 +1267,7 @@ public class RemoteIpFilter extends GenericFilter {
* Name of the http header from which the remote ip is extracted.
* </p>
* <p>
- * The value of this header can be comma delimited.
+ * The value of this header can be comma-delimited.
* </p>
* <p>
* Default value : <code>X-Forwarded-For</code>
@@ -1280,7 +1280,7 @@ public class RemoteIpFilter extends GenericFilter {
}
/**
- * Should this filter set request attributes for IP address, Hostname, protocol and port used for the request? This
+ * Should this filter set request attributes for IP address, Hostname, protocol and port used for the request? These
* are typically used in conjunction with an {@link AccessLog} which will otherwise log the original values. Default
* is <code>true</code>. The attributes set are:
* <ul>
diff --git a/java/org/apache/catalina/filters/RequestFilter.java b/java/org/apache/catalina/filters/RequestFilter.java
index fda518631b..c103e496aa 100644
--- a/java/org/apache/catalina/filters/RequestFilter.java
+++ b/java/org/apache/catalina/filters/RequestFilter.java
@@ -39,7 +39,7 @@ import jakarta.servlet.http.HttpServletResponse;
* <li>The subclass extracts the request property to be filtered, and calls the common <code>process()</code> method.
* <li>If there is a deny expression configured, the property will be compared to the expression. If a match is found,
* this request will be rejected with a "Forbidden" HTTP response.</li>
- * <li>If there is a allow expression configured, the property will be compared to the expression. If a match is found,
+ * <li>If there is an allow expression configured, the property will be compared to the expression. If a match is found,
* this request will be allowed to pass through to the next filter in the current pipeline.</li>
* <li>If a deny expression was specified but no allow expression, allow this request to pass through (because none of
* the deny expressions matched it).
diff --git a/java/org/apache/catalina/filters/RestCsrfPreventionFilter.java b/java/org/apache/catalina/filters/RestCsrfPreventionFilter.java
index 7ede4b1377..19b9cac8de 100644
--- a/java/org/apache/catalina/filters/RestCsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/RestCsrfPreventionFilter.java
@@ -86,7 +86,7 @@ public class RestCsrfPreventionFilter extends CsrfPreventionFilterBase {
m -> Objects.nonNull(m) && NON_MODIFYING_METHODS_PATTERN.matcher(m).matches();
private final Set<String> pathsAcceptingParams = new HashSet<>();
- private String pathsDelimiter = ",";
+ private static final String pathsDelimiter = ",";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
diff --git a/java/org/apache/catalina/filters/SetCharacterEncodingFilter.java b/java/org/apache/catalina/filters/SetCharacterEncodingFilter.java
index cb20a20e3a..42c94947d1 100644
--- a/java/org/apache/catalina/filters/SetCharacterEncodingFilter.java
+++ b/java/org/apache/catalina/filters/SetCharacterEncodingFilter.java
@@ -46,7 +46,7 @@ import org.apache.juli.logging.LogFactory;
* Although this filter can be used unchanged, it is also easy to subclass it and make the <code>selectEncoding()</code>
* method more intelligent about what encoding to choose, based on characteristics of the incoming request (such as the
* values of the <code>Accept-Language</code> and <code>User-Agent</code> headers, or a value stashed in the current
- * user's session.
+ * user's session).
* </p>
*/
public class SetCharacterEncodingFilter extends FilterBase {
diff --git a/java/org/apache/catalina/ha/ClusterDeployer.java b/java/org/apache/catalina/ha/ClusterDeployer.java
index 8e8e33d03e..6c74e71d16 100644
--- a/java/org/apache/catalina/ha/ClusterDeployer.java
+++ b/java/org/apache/catalina/ha/ClusterDeployer.java
@@ -80,9 +80,7 @@ public interface ClusterDeployer extends ChannelListener {
void backgroundProcess();
/**
- * Returns the cluster the cluster deployer is associated with
- *
- * @return CatalinaCluster
+ * @return the cluster the is associated with
*/
CatalinaCluster getCluster();
diff --git a/java/org/apache/catalina/ha/ClusterListener.java b/java/org/apache/catalina/ha/ClusterListener.java
index 4e52850550..ba3beb3061 100644
--- a/java/org/apache/catalina/ha/ClusterListener.java
+++ b/java/org/apache/catalina/ha/ClusterListener.java
@@ -71,10 +71,7 @@ public abstract class ClusterListener implements ChannelListener {
@Override
public final boolean accept(Serializable msg, Member member) {
- if (msg instanceof ClusterMessage) {
- return true;
- }
- return false;
+ return msg instanceof ClusterMessage;
}
diff --git a/java/org/apache/catalina/ha/ClusterValve.java b/java/org/apache/catalina/ha/ClusterValve.java
index d2c339ea7f..7ddf322a43 100644
--- a/java/org/apache/catalina/ha/ClusterValve.java
+++ b/java/org/apache/catalina/ha/ClusterValve.java
@@ -26,7 +26,7 @@ import org.apache.catalina.Valve;
*/
public interface ClusterValve extends Valve {
/**
- * Returns the cluster the cluster deployer is associated with
+ * Returns the cluster the valve is associated with
*
* @return CatalinaCluster
*/
diff --git a/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java b/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
index 6e8e9ab5a7..68c066d551 100644
--- a/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
+++ b/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
@@ -34,7 +34,7 @@ import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;
/**
- * A <strong>Valve</strong> that supports a "single sign on" user experience on each nodes of a cluster, where the
+ * A <strong>Valve</strong> that supports a "single sign on" user experience on each node of a cluster, where the
* security identity of a user who successfully authenticates to one web application is propagated to other web
* applications and to other nodes cluster in the same security domain. For successful use, the following requirements
* must be met:
diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java b/java/org/apache/catalina/ha/backend/CollectedInfo.java
index ab2436717c..58302f0691 100644
--- a/java/org/apache/catalina/ha/backend/CollectedInfo.java
+++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java
@@ -28,7 +28,7 @@ import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
/*
- * Listener to provider informations to mod_heartbeat.c
+ * Listener to provide information to mod_heartbeat.c
* *msg_format = "v=%u&ready=%u&busy=%u"; (message to send).
* send the multicast message using the format...
* what about the bind(IP. port) only IP makes sense (for the moment).
@@ -55,7 +55,7 @@ public class CollectedInfo {
public void init(String host, int port) throws Exception {
int iport = 0;
String shost = null;
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ mBeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
String onStr = "*:type=ThreadPool,*";
ObjectName objectName = new ObjectName(onStr);
Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
index 117b1faa93..3e16ff05c1 100644
--- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
+++ b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
@@ -24,7 +24,7 @@ import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
/*
- * Listener to provider informations to mod_heartbeat.c
+ * Listener to provide information to mod_heartbeat.c
* *msg_format = "v=%u&ready=%u&busy=%u"; (message to send).
* send the multicast message using the format...
* what about the bind(IP. port) only IP makes sense (for the moment).
diff --git a/java/org/apache/catalina/ha/backend/TcpSender.java b/java/org/apache/catalina/ha/backend/TcpSender.java
index 345224d3b5..543cfcb674 100644
--- a/java/org/apache/catalina/ha/backend/TcpSender.java
+++ b/java/org/apache/catalina/ha/backend/TcpSender.java
@@ -164,7 +164,7 @@ public class TcpSender implements Sender {
if (contentLength > 0) {
char[] buf = new char[512];
while (contentLength > 0) {
- int thisTime = (contentLength > buf.length) ? buf.length : contentLength;
+ int thisTime = Math.min(contentLength, buf.length);
int n = connectionReaders[i].read(buf, 0, thisTime);
if (n <= 0) {
log.error(sm.getString("tcpSender.readError"));
@@ -193,6 +193,7 @@ public class TcpSender implements Sender {
connectionReaders[i].close();
}
} catch (IOException e) {
+ // Ignore
}
connectionReaders[i] = null;
try {
@@ -200,6 +201,7 @@ public class TcpSender implements Sender {
connectionWriters[i].close();
}
} catch (IOException e) {
+ // Ignore
}
connectionWriters[i] = null;
try {
@@ -207,6 +209,7 @@ public class TcpSender implements Sender {
connections[i].close();
}
} catch (IOException e) {
+ // Ignore
}
connections[i] = null;
}
diff --git a/java/org/apache/catalina/ha/context/ReplicatedContext.java b/java/org/apache/catalina/ha/context/ReplicatedContext.java
index fbb06701d6..d1ea1565e3 100644
--- a/java/org/apache/catalina/ha/context/ReplicatedContext.java
+++ b/java/org/apache/catalina/ha/context/ReplicatedContext.java
@@ -98,7 +98,7 @@ public class ReplicatedContext extends StandardContext implements MapOwner {
}
public ClassLoader[] getClassLoaders() {
- Loader loader = null;
+ Loader loader;
ClassLoader classLoader = null;
loader = this.getLoader();
if (loader != null) {
@@ -192,7 +192,7 @@ public class ReplicatedContext extends StandardContext implements MapOwner {
public Enumeration<String> getAttributeNames() {
Set<String> names = new HashSet<>(attributes.keySet());
- return new MultiEnumeration<>(
+ return new MultiEnumeration<String>(
new Enumeration[] { super.getAttributeNames(), Collections.enumeration(names) });
}
}
diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index d80390555e..008a62813b 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -146,8 +146,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
return;
}
Engine engine = (Engine) econtainer;
- String hostname = null;
- hostname = host.getName();
+ String hostname = host.getName();
try {
oname = new ObjectName(engine.getName() + ":type=Deployer,host=" + hostname);
} catch (Exception e) {
@@ -164,7 +163,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
configBase = host.getConfigBaseFile();
// Retrieve the MBean server
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ mBeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
started = true;
count = 0;
@@ -488,7 +487,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
*/
protected void undeployDir(File dir) {
- String files[] = dir.list();
+ String[] files = dir.list();
if (files == null) {
files = new String[0];
}
diff --git a/java/org/apache/catalina/ha/deploy/FileMessage.java b/java/org/apache/catalina/ha/deploy/FileMessage.java
index bac4275131..6d3c28ac66 100644
--- a/java/org/apache/catalina/ha/deploy/FileMessage.java
+++ b/java/org/apache/catalina/ha/deploy/FileMessage.java
@@ -72,12 +72,7 @@ public class FileMessage extends ClusterMessageBase {
@Override
public String getUniqueId() {
- StringBuilder result = new StringBuilder(getFileName());
- result.append("#-#");
- result.append(getMessageNumber());
- result.append("#-#");
- result.append(System.currentTimeMillis());
- return result.toString();
+ return getFileName() + "#-#" + getMessageNumber() + "#-#" + System.currentTimeMillis();
}
diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
index fb831d1136..892f40d385 100644
--- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
+++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
@@ -121,7 +121,7 @@ public class FileMessageFactory {
/**
* The time this instance was last modified.
*/
- protected long lastModified = 0;
+ protected long lastModified;
/**
* The maximum time (in seconds) this instance will be allowed to exist from lastModifiedTime.
@@ -244,7 +244,7 @@ public class FileMessageFactory {
// Have received a new message. Update the last modified time (even if the message is being buffered for now).
lastModified = System.currentTimeMillis();
- FileMessage next = null;
+ FileMessage next;
synchronized (this) {
if (!isWriting) {
next = msgBuffer.get(Long.valueOf(lastMessageProcessed.get() + 1));
diff --git a/java/org/apache/catalina/ha/deploy/UndeployMessage.java b/java/org/apache/catalina/ha/deploy/UndeployMessage.java
index 63f22adb25..1fec2f6051 100644
--- a/java/org/apache/catalina/ha/deploy/UndeployMessage.java
+++ b/java/org/apache/catalina/ha/deploy/UndeployMessage.java
@@ -24,7 +24,7 @@ public class UndeployMessage implements ClusterMessage {
private Member address;
private long timestamp;
- private String uniqueId;
+ private final String uniqueId;
private final String contextName;
public UndeployMessage(Member address, long timestamp, String uniqueId, String contextName) {
diff --git a/java/org/apache/catalina/ha/deploy/WarWatcher.java b/java/org/apache/catalina/ha/deploy/WarWatcher.java
index bd9e4ad8e6..7c3ffd25b7 100644
--- a/java/org/apache/catalina/ha/deploy/WarWatcher.java
+++ b/java/org/apache/catalina/ha/deploy/WarWatcher.java
@@ -149,7 +149,7 @@ public class WarWatcher {
protected static class WarInfo {
protected final File war;
- protected long lastChecked = 0;
+ protected long lastChecked;
protected long lastState = 0;
diff --git a/java/org/apache/catalina/ha/session/BackupManager.java b/java/org/apache/catalina/ha/session/BackupManager.java
index ce02baaafc..ec6fd274e4 100644
--- a/java/org/apache/catalina/ha/session/BackupManager.java
+++ b/java/org/apache/catalina/ha/session/BackupManager.java
@@ -265,8 +265,7 @@ public class BackupManager extends ClusterManagerBase implements MapOwner, Distr
@Override
public Set<String> getSessionIdsFull() {
LazyReplicatedMap<String,Session> map = (LazyReplicatedMap<String,Session>) sessions;
- Set<String> sessionIds = new HashSet<>(map.keySetFull());
- return sessionIds;
+ return new HashSet<>(map.keySetFull());
}
}
diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index b642178f4b..77c989add4 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -60,7 +60,7 @@ public abstract class ClusterManagerBase extends ManagerBase implements ClusterM
*/
private boolean recordAllActions = false;
- private SynchronizedStack<DeltaRequest> deltaRequestPool = new SynchronizedStack<>();
+ private final SynchronizedStack<DeltaRequest> deltaRequestPool = new SynchronizedStack<>();
protected SynchronizedStack<DeltaRequest> getDeltaRequestPool() {
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java b/java/org/apache/catalina/ha/session/DeltaManager.java
index 6fe54b1de9..cf4ace54cf 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -736,7 +736,7 @@ public class DeltaManager extends ClusterManagerBase {
*/
protected Member findSessionMasterMember() {
Member mbr = null;
- Member mbrs[] = cluster.getMembers();
+ Member[] mbrs = cluster.getMembers();
if (mbrs.length != 0) {
mbr = mbrs[0];
}
@@ -777,6 +777,7 @@ public class DeltaManager extends ClusterManagerBase {
try {
Thread.sleep(100);
} catch (Exception sleep) {
+ // Ignore
}
} while ((!getStateTransferred()) && (!isNoContextManagerReceived()));
reqNow = System.currentTimeMillis();
@@ -819,7 +820,7 @@ public class DeltaManager extends ClusterManagerBase {
if (log.isInfoEnabled()) {
log.info(sm.getString("deltaManager.expireSessions", getName()));
}
- Session sessions[] = findSessions();
+ Session[] sessions = findSessions();
for (Session value : sessions) {
DeltaSession session = (DeltaSession) value;
if (!session.isValid()) {
@@ -883,7 +884,7 @@ public class DeltaManager extends ClusterManagerBase {
* @return a SessionMessage to be sent,
*/
public ClusterMessage requestCompleted(String sessionId, boolean expires) {
- DeltaSession session = null;
+ DeltaSession session;
SessionMessage msg = null;
try {
session = (DeltaSession) findSession(sessionId);
@@ -1004,7 +1005,7 @@ public class DeltaManager extends ClusterManagerBase {
* Expire all find sessions.
*/
public void expireAllLocalSessions() {
- Session sessions[] = findSessions();
+ Session[] sessions = findSessions();
int expireDirect = 0;
int expireIndirect = 0;
@@ -1166,7 +1167,7 @@ public class DeltaManager extends ClusterManagerBase {
}
/**
- * handle receive session is expire at other node ( expire session also here)
+ * handle receive session is expired at other node ( expire session also here)
*
* @param msg Session message
* @param sender Member which sent the message
@@ -1266,6 +1267,7 @@ public class DeltaManager extends ClusterManagerBase {
try {
Thread.sleep(getSendAllSessionsWaitTime());
} catch (Exception sleep) {
+ // Ignore
}
}
}
diff --git a/java/org/apache/catalina/ha/session/DeltaRequest.java b/java/org/apache/catalina/ha/session/DeltaRequest.java
index bbf48bac12..d57bc8a24e 100644
--- a/java/org/apache/catalina/ha/session/DeltaRequest.java
+++ b/java/org/apache/catalina/ha/session/DeltaRequest.java
@@ -126,8 +126,7 @@ public class DeltaRequest implements Externalizable {
}
public void setNew(boolean n) {
- int action = ACTION_SET;
- addAction(TYPE_ISNEW, action, NAME_ISNEW, Boolean.valueOf(n));
+ addAction(TYPE_ISNEW, ACTION_SET, NAME_ISNEW, Boolean.valueOf(n));
}
public void setAuthType(String authType) {
@@ -144,8 +143,8 @@ public class DeltaRequest implements Externalizable {
}
protected void addAction(int type, int action, String name, Object value) {
- AttributeInfo info = null;
- if (this.actionPool.size() > 0) {
+ AttributeInfo info;
+ if (!this.actionPool.isEmpty()) {
try {
info = actionPool.removeFirst();
} catch (Exception x) {
@@ -247,7 +246,7 @@ public class DeltaRequest implements Externalizable {
}
public void reset() {
- while (actions.size() > 0) {
+ while (!actions.isEmpty()) {
try {
AttributeInfo info = actions.removeFirst();
info.recycle();
@@ -256,7 +255,6 @@ public class DeltaRequest implements Externalizable {
log.error(sm.getString("deltaRequest.removeUnable"), x);
}
}
- actions.clear();
}
public String getSessionId() {
@@ -291,8 +289,8 @@ public class DeltaRequest implements Externalizable {
recordAllActions = in.readBoolean();
int cnt = in.readInt();
for (int i = 0; i < cnt; i++) {
- AttributeInfo info = null;
- if (this.actionPool.size() > 0) {
+ AttributeInfo info;
+ if (!this.actionPool.isEmpty()) {
try {
info = actionPool.removeFirst();
} catch (Exception x) {
@@ -433,11 +431,9 @@ public class DeltaRequest implements Externalizable {
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("AttributeInfo[type=");
- buf.append(getType()).append(", action=").append(getAction());
- buf.append(", name=").append(getName()).append(", value=").append(getValue());
- buf.append(", addr=").append(super.toString()).append(']');
- return buf.toString();
+ return "AttributeInfo[type=" + getType() + ", action=" + getAction() +
+ ", name=" + getName() + ", value=" + getValue() +
+ ", addr=" + super.toString() + ']';
}
}
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java b/java/org/apache/catalina/ha/session/DeltaSession.java
index 2cba31e3e4..fe3e42bff6 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -107,7 +107,7 @@ public class DeltaSession extends StandardSession implements Externalizable, Clu
}
/*
- * DeltaRequest instances are created via this protected method to enable sub-classes to over-ride the method to use
+ * DeltaRequest instances are created via this protected method to enable subclasses to over-ride the method to use
* custom DeltaRequest implementations.
*/
protected DeltaRequest createRequest(String sessionId, boolean recordAllActions) {
@@ -129,7 +129,7 @@ public class DeltaSession extends StandardSession implements Externalizable, Clu
@Override
public byte[] getDiff() throws IOException {
SynchronizedStack<DeltaRequest> deltaRequestPool = null;
- DeltaRequest newDeltaRequest = null;
+ DeltaRequest newDeltaRequest;
if (manager instanceof ClusterManagerBase) {
deltaRequestPool = ((ClusterManagerBase) manager).getDeltaRequestPool();
@@ -243,10 +243,7 @@ public class DeltaSession extends StandardSession implements Externalizable, Clu
@Override
public boolean isAccessReplicate() {
long replDelta = System.currentTimeMillis() - getLastTimeReplicated();
- if (maxInactiveInterval >= 0 && replDelta > (maxInactiveInterval * 1000L)) {
- return true;
- }
- return false;
+ return maxInactiveInterval >= 0 && replDelta > (maxInactiveInterval * 1000L);
}
@Override
@@ -461,11 +458,7 @@ public class DeltaSession extends StandardSession implements Externalizable, Clu
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("DeltaSession[");
- sb.append(id);
- sb.append(']');
- return sb.toString();
+ return "DeltaSession[" + id + ']';
}
@Override
@@ -831,12 +824,11 @@ public class DeltaSession extends StandardSession implements Externalizable, Clu
stream.writeObject(notes.get(org.apache.catalina.authenticator.Constants.FORM_REQUEST_NOTE));
// Accumulate the names of serializable and non-serializable attributes
- String keys[] = keys();
+ String[] keys = keys();
List<String> saveNames = new ArrayList<>();
List<Object> saveValues = new ArrayList<>();
for (String key : keys) {
- Object value = null;
- value = attributes.get(key);
+ Object value = attributes.get(key);
if (value != null && !exclude(key, value) && isAttributeDistributable(key, value)) {
saveNames.add(key);
saveValues.add(value);
diff --git a/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java b/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
index dab7f5f07a..b23ee05aa9 100644
--- a/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
+++ b/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
@@ -138,7 +138,7 @@ public class JvmRouteBinderValve extends ValveBase implements ClusterValve {
}
/**
- * Detect possible the JVMRoute change at cluster backup node..
+ * Detect possible the JVMRoute change at cluster backup node.
*
* @param request tomcat request being processed
* @param response tomcat response being processed
diff --git a/java/org/apache/catalina/ha/session/SessionMessage.java b/java/org/apache/catalina/ha/session/SessionMessage.java
index 291f5573ab..39674f5b89 100644
--- a/java/org/apache/catalina/ha/session/SessionMessage.java
+++ b/java/org/apache/catalina/ha/session/SessionMessage.java
@@ -47,7 +47,7 @@ public interface SessionMessage extends ClusterMessage {
int EVT_SESSION_EXPIRED = 2;
/**
- * Event type used when a session has been accessed (ie, last access time has been updated. This is used so that the
+ * Event type used when a session has been accessed (ie, last access time has been updated). This is used so that the
* replicated sessions will not expire on the network
*/
int EVT_SESSION_ACCESSED = 3;
diff --git a/java/org/apache/catalina/ha/session/SessionMessageImpl.java b/java/org/apache/catalina/ha/session/SessionMessageImpl.java
index c3b8d2713f..84e2dbc5b8 100644
--- a/java/org/apache/catalina/ha/session/SessionMessageImpl.java
+++ b/java/org/apache/catalina/ha/session/SessionMessageImpl.java
@@ -61,7 +61,7 @@ public class SessionMessageImpl extends ClusterMessageBase implements SessionMes
* <B>EVT_SESSION_ACCESSED</B><BR>
* The parameters: sessionID must be set.<BR>
* <B>EVT_GET_ALL_SESSIONS</B><BR>
- * get all sessions from from one of the nodes.<BR>
+ * get all sessions from one of the nodes.<BR>
* <B>EVT_SESSION_DELTA</B><BR>
* Send attribute delta (add,update,remove attribute or principal, ...).<BR>
* <B>EVT_ALL_SESSION_DATA</B><BR>
diff --git a/java/org/apache/catalina/ha/tcp/ReplicationValve.java b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
index 1872c95bf3..619801e711 100644
--- a/java/org/apache/catalina/ha/tcp/ReplicationValve.java
+++ b/java/org/apache/catalina/ha/tcp/ReplicationValve.java
@@ -100,7 +100,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
protected LongAdder nrOfCrossContextSendRequests = new LongAdder();
/**
- * must primary change indicator set
+ * Must set primary change indicator.
*/
protected boolean primaryIndicator = false;
@@ -153,7 +153,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
log.trace(sm.getString("ReplicationValve.filter.loading", filter));
}
- if (filter == null || filter.length() == 0) {
+ if (filter == null || filter.isEmpty()) {
this.filter = null;
} else {
try {
@@ -294,7 +294,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
createPrimaryIndicator(request);
}
Context context = request.getContext();
- boolean isCrossContext = context != null && context instanceof StandardContext && context.getCrossContext();
+ boolean isCrossContext = context instanceof StandardContext && context.getCrossContext();
boolean isAsync = request.getAsyncContextInternal() != null;
try {
if (isCrossContext) {
@@ -319,7 +319,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
}
}
} finally {
- // Array must be remove: Current master request send endAccess at recycle.
+ // Array must be removed: Current master request send endAccess at recycle.
// Don't register this request session again!
if (isCrossContext) {
if (log.isTraceEnabled()) {
@@ -392,7 +392,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
*/
protected void sendCrossContextSession() {
List<DeltaSession> sessions = crossContextSessions.get();
- if (sessions != null && sessions.size() > 0) {
+ if (sessions != null && !sessions.isEmpty()) {
for (DeltaSession session : sessions) {
if (log.isTraceEnabled()) {
log.trace(sm.getString("ReplicationValve.crossContext.sendDelta",
@@ -503,13 +503,11 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
*/
protected void sendInvalidSessions(ClusterManager manager) {
String[] invalidIds = manager.getInvalidatedSessions();
- if (invalidIds.length > 0) {
- for (String invalidId : invalidIds) {
- try {
- send(manager, invalidId);
- } catch (Exception x) {
- log.error(sm.getString("ReplicationValve.send.invalid.failure", invalidId), x);
- }
+ for (String invalidId : invalidIds) {
+ try {
+ send(manager, invalidId);
+ } catch (Exception x) {
+ log.error(sm.getString("ReplicationValve.send.invalid.failure", invalidId), x);
}
}
}
@@ -543,13 +541,13 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
if (log.isDebugEnabled()) {
if ((nrOfRequests.longValue() % 100) == 0) {
log.debug(sm.getString("ReplicationValve.stats",
- new Object[] { Long.valueOf(totalRequestTime.longValue() / nrOfRequests.longValue()),
- Long.valueOf(totalSendTime.longValue() / nrOfRequests.longValue()),
- Long.valueOf(nrOfRequests.longValue()), Long.valueOf(nrOfSendRequests.longValue()),
- Long.valueOf(nrOfCrossContextSendRequests.longValue()),
- Long.valueOf(nrOfFilterRequests.longValue()),
- Long.valueOf(totalRequestTime.longValue()),
- Long.valueOf(totalSendTime.longValue()) }));
+ Long.valueOf(totalRequestTime.longValue() / nrOfRequests.longValue()),
+ Long.valueOf(totalSendTime.longValue() / nrOfRequests.longValue()),
+ Long.valueOf(nrOfRequests.longValue()), Long.valueOf(nrOfSendRequests.longValue()),
+ Long.valueOf(nrOfCrossContextSendRequests.longValue()),
+ Long.valueOf(nrOfFilterRequests.longValue()),
+ Long.valueOf(totalRequestTime.longValue()),
+ Long.valueOf(totalSendTime.longValue())));
}
}
}
@@ -565,7 +563,7 @@ public class ReplicationValve extends ValveBase implements ClusterValve {
*/
protected void createPrimaryIndicator(Request request) throws IOException {
String id = request.getRequestedSessionId();
- if ((id != null) && (id.length() > 0)) {
+ if ((id != null) && (!id.isEmpty())) {
Manager manager = request.getContext().getManager();
Session session = manager.findSession(id);
if (session instanceof ClusterSession) {
diff --git a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
index aeeb95e0d7..39a19e9b88 100644
--- a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
+++ b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
@@ -479,10 +479,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
protected void checkDefaults() {
- if (clusterListeners.size() == 0 && managerTemplate instanceof DeltaManager) {
+ if (clusterListeners.isEmpty() && managerTemplate instanceof DeltaManager) {
addClusterListener(new ClusterSessionListener());
}
- if (valves.size() == 0) {
+ if (valves.isEmpty()) {
addValve(new JvmRouteBinderValve());
addValve(new ReplicationValve());
}
diff --git a/java/org/apache/catalina/loader/JdbcLeakPrevention.java b/java/org/apache/catalina/loader/JdbcLeakPrevention.java
index cdd5b8b974..a292505123 100644
--- a/java/org/apache/catalina/loader/JdbcLeakPrevention.java
+++ b/java/org/apache/catalina/loader/JdbcLeakPrevention.java
@@ -40,8 +40,8 @@ public class JdbcLeakPrevention {
/*
* DriverManager.getDrivers() has a nasty side-effect of registering drivers that are visible to this class
* loader but haven't yet been loaded. Therefore, the first call to this method a) gets the list of originally
- * loaded drivers and b) triggers the unwanted side-effect. The second call gets the complete list of drivers
- * ensuring that both original drivers and any loaded as a result of the side-effects are all de-registered.
+ * loaded drivers and b) triggers the unwanted side effect. The second call gets the complete list of drivers
+ * ensuring that both original drivers and any loaded as a result of the side effects are all de-registered.
*/
Set<Driver> originalDrivers = new HashSet<>();
Enumeration<Driver> drivers = DriverManager.getDrivers();
@@ -56,7 +56,7 @@ public class JdbcLeakPrevention {
continue;
}
// Only report drivers that were originally registered. Skip any
- // that were registered as a side-effect of this code.
+ // that were registered as a side effect of this code.
if (originalDrivers.contains(driver)) {
driverNames.add(driver.getClass().getCanonicalName());
}
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index 93518d19f0..bb5e17e9c1 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -163,7 +163,7 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader {
/**
- * @return a non null String if the loader will attempt to use the Jakarta converter. The String is the name of the
+ * @return a non-null String if the loader will attempt to use the Jakarta converter. The String is the name of the
* profile used for conversion.
*/
public String getJakartaConverter() {
@@ -336,12 +336,12 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader {
ObjectName cloname =
new ObjectName(context.getDomain() + ":type=" + classLoader.getClass().getSimpleName() + ",host=" +
context.getParent().getName() + ",context=" + contextName);
- Registry.getRegistry(null, null).registerComponent(classLoader, cloname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(classLoader, cloname, null);
} catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
- throw new LifecycleException(sm.getString("webappLoader.startError"), t);
+ Throwable throwable = ExceptionUtils.unwrapInvocationTargetException(t);
+ ExceptionUtils.handleThrowable(throwable);
+ throw new LifecycleException(sm.getString("webappLoader.startError"), throwable);
}
setState(LifecycleState.STARTING);
@@ -385,7 +385,7 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader {
ObjectName cloname =
new ObjectName(context.getDomain() + ":type=" + classLoader.getClass().getSimpleName() +
",host=" + context.getParent().getName() + ",context=" + contextName);
- Registry.getRegistry(null, null).unregisterComponent(cloname);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(cloname);
} catch (Exception e) {
log.warn(sm.getString("webappLoader.stopError"), e);
}
@@ -570,7 +570,7 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader {
/**
- * Implemented in a sub-class so EESpecProfile and EESpecProfiles are not loaded unless a profile is configured.
+ * Implemented in a subclass so EESpecProfile and EESpecProfiles are not loaded unless a profile is configured.
* Otherwise, tomcat-embed-core.jar has a runtime dependency on the migration tool whether it is used or not.
*/
private static class MigrationUtil {
diff --git a/java/org/apache/catalina/manager/HTMLManagerServlet.java b/java/org/apache/catalina/manager/HTMLManagerServlet.java
index dbc8d8f9c3..fe0f7ece24 100644
--- a/java/org/apache/catalina/manager/HTMLManagerServlet.java
+++ b/java/org/apache/catalina/manager/HTMLManagerServlet.java
@@ -113,8 +113,10 @@ public class HTMLManagerServlet extends ManagerServlet {
// List always displayed - nothing to do here
} else if (command.equals("/sessions")) {
try {
- doSessions(cn, request, response, smClient);
- return;
+ if (cn != null) {
+ doSessions(cn, request, response, smClient);
+ return;
+ }
} catch (Exception e) {
log(sm.getString("htmlManagerServlet.error.sessions", cn), e);
message = smClient.getString("managerServlet.exception", e.toString());
@@ -268,7 +270,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param cn Name of the application to be deployed
* @param war URL of the web application archive to be deployed
* @param smClient internationalized strings
- *
* @return message String
*/
protected String deployInternal(String config, ContextName cn, String war, StringManager smClient) {
@@ -289,7 +290,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param response The response
* @param message a message to display
* @param smClient internationalized strings
- *
* @throws IOException an IO error occurred
*/
protected void list(HttpServletRequest request, HttpServletResponse response, String message,
@@ -566,12 +566,10 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Reload the web application at the specified context path.
*
- * @see ManagerServlet#reload(PrintWriter, ContextName, StringManager)
- *
* @param cn Name of the application to be restarted
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#reload(PrintWriter, ContextName, StringManager)
*/
protected String reload(ContextName cn, StringManager smClient) {
@@ -586,12 +584,10 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Undeploy the web application at the specified context path.
*
- * @see ManagerServlet#undeploy(PrintWriter, ContextName, StringManager)
- *
* @param cn Name of the application to be undeployed
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#undeploy(PrintWriter, ContextName, StringManager)
*/
protected String undeploy(ContextName cn, StringManager smClient) {
@@ -606,13 +602,11 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Display session information and invoke list.
*
- * @see ManagerServlet#sessions(PrintWriter, ContextName, int, StringManager)
- *
* @param cn Name of the application to list session information
* @param idle Expire all sessions with idle time ≥ idle for this context
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#sessions(PrintWriter, ContextName, int, StringManager)
*/
protected String sessions(ContextName cn, int idle, StringManager smClient) {
@@ -627,12 +621,10 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Start the web application at the specified context path.
*
- * @see ManagerServlet#start(PrintWriter, ContextName, StringManager)
- *
* @param cn Name of the application to be started
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#start(PrintWriter, ContextName, StringManager)
*/
protected String start(ContextName cn, StringManager smClient) {
@@ -647,12 +639,10 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Stop the web application at the specified context path.
*
- * @see ManagerServlet#stop(PrintWriter, ContextName, StringManager)
- *
* @param cn Name of the application to be stopped
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#stop(PrintWriter, ContextName, StringManager)
*/
protected String stop(ContextName cn, StringManager smClient) {
@@ -667,11 +657,9 @@ public class HTMLManagerServlet extends ManagerServlet {
/**
* Find potential memory leaks caused by web application reload.
*
- * @see ManagerServlet#findleaks(boolean, PrintWriter, StringManager)
- *
* @param smClient StringManager for the client's locale
- *
* @return message String
+ * @see ManagerServlet#findleaks(boolean, PrintWriter, StringManager)
*/
protected String findleaks(StringManager smClient) {
@@ -752,7 +740,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param cn Name of the application from which to expire sessions
* @param req The Servlet request
* @param smClient StringManager for the client's locale
- *
* @return message string
*/
protected String expireSessions(ContextName cn, HttpServletRequest req, StringManager smClient) {
@@ -775,7 +762,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param req The Servlet request
* @param resp The Servlet response
* @param smClient StringManager for the client's locale
- *
* @throws ServletException Propagated Servlet error
* @throws IOException An IO error occurred
*/
@@ -861,7 +847,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param req The Servlet request
* @param resp The Servlet response
* @param smClient StringManager for the client's locale
- *
* @throws ServletException Propagated Servlet error
* @throws IOException An IO error occurred
*/
@@ -911,7 +896,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param cn Name of the application for which the sessions will be listed
* @param sessionId the session id
* @param smClient StringManager for the client's locale
- *
* @throws ServletException Propagated Servlet error
* @throws IOException An IO error occurred
*/
@@ -934,7 +918,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param cn Name of the application for which sessions are to be invalidated
* @param sessionIds the session ids of the sessions
* @param smClient StringManager for the client's locale
- *
* @return number of invalidated sessions
*/
protected int invalidateSessions(ContextName cn, String[] sessionIds, StringManager smClient) {
@@ -973,7 +956,6 @@ public class HTMLManagerServlet extends ManagerServlet {
* @param sessionId the session id
* @param attributeName the attribute name
* @param smClient StringManager for the client's locale
- *
* @return true if there was an attribute removed, false otherwise
*/
protected boolean removeSessionAttribute(ContextName cn, String sessionId, String attributeName,
diff --git a/java/org/apache/catalina/manager/JMXProxyServlet.java b/java/org/apache/catalina/manager/JMXProxyServlet.java
index 89033821b9..4857ef3743 100644
--- a/java/org/apache/catalina/manager/JMXProxyServlet.java
+++ b/java/org/apache/catalina/manager/JMXProxyServlet.java
@@ -69,8 +69,8 @@ public class JMXProxyServlet extends HttpServlet {
@Override
public void init() throws ServletException {
// Retrieve the MBean server
- registry = Registry.getRegistry(null, null);
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ registry = Registry.getRegistryNonNull(null, null);
+ mBeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
}
diff --git a/java/org/apache/catalina/manager/ManagerServlet.java b/java/org/apache/catalina/manager/ManagerServlet.java
index 625b53c82c..ea8c79109a 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -246,7 +246,7 @@ public class ManagerServlet extends HttpServlet implements ContainerServlet {
}
// Retrieve the MBean server
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ mBeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
}
@@ -507,8 +507,8 @@ public class ManagerServlet extends HttpServlet implements ContainerServlet {
} else {
SSLHostConfig[] sslHostConfigs = http11Protoocol.findSslHostConfigs();
for (SSLHostConfig sslHostConfig : sslHostConfigs) {
- // tlsHostName is as provided by the user so use a case insensitive
- // comparison as host names are case insensitive.
+ // tlsHostName is as provided by the user so use a case-insensitive
+ // comparison as host names are case-insensitive.
if (sslHostConfig.getHostName().equalsIgnoreCase(tlsHostName)) {
found = true;
http11Protoocol.reloadSslHostConfig(tlsHostName);
diff --git a/java/org/apache/catalina/manager/StatusManagerServlet.java b/java/org/apache/catalina/manager/StatusManagerServlet.java
index cc53ca7fbe..6927283133 100644
--- a/java/org/apache/catalina/manager/StatusManagerServlet.java
+++ b/java/org/apache/catalina/manager/StatusManagerServlet.java
@@ -88,7 +88,7 @@ public class StatusManagerServlet extends HttpServlet implements NotificationLis
public void init() throws ServletException {
// Retrieve the MBean server
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ mBeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
try {
diff --git a/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java b/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
index 31934d863b..33ee01a4db 100644
--- a/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
+++ b/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.SortedSet;
@@ -53,7 +54,7 @@ import org.apache.tomcat.util.security.Escape;
*
* @see org.apache.catalina.manager.ManagerServlet
*/
-public final class HTMLHostManagerServlet extends HostManagerServlet {
+public class HTMLHostManagerServlet extends HostManagerServlet {
private static final long serialVersionUID = 1L;
@@ -254,7 +255,7 @@ public final class HTMLHostManagerServlet extends HostManagerServlet {
// Message Section
args = new Object[3];
args[0] = smClient.getString("htmlHostManagerServlet.messageLabel");
- if (message == null || message.length() == 0) {
+ if (message == null || message.isEmpty()) {
args[1] = "OK";
} else {
args[1] = Escape.htmlElementContent(message);
@@ -288,13 +289,12 @@ public final class HTMLHostManagerServlet extends HostManagerServlet {
// Hosts Row Section
// Create sorted set of host names.
Container[] children = engine.findChildren();
- String hostNames[] = new String[children.length];
+ String[] hostNames = new String[children.length];
for (int i = 0; i < children.length; i++) {
hostNames[i] = children[i].getName();
}
- SortedSet<String> sortedHostNames = new TreeSet<>();
- sortedHostNames.addAll(Arrays.asList(hostNames));
+ SortedSet<String> sortedHostNames = new TreeSet<>(Arrays.asList(hostNames));
String hostsStart = smClient.getString("htmlHostManagerServlet.hostsStart");
String hostsStop = smClient.getString("htmlHostManagerServlet.hostsStop");
@@ -329,15 +329,15 @@ public final class HTMLHostManagerServlet extends HostManagerServlet {
args = new Object[5];
if (host.getState().isAvailable()) {
args[0] = response.encodeURL(getServletContext().getContextPath() + "/html/stop?name=" +
- URLEncoder.encode(hostName, "UTF-8"));
+ URLEncoder.encode(hostName, StandardCharsets.UTF_8));
args[1] = hostsStop;
} else {
args[0] = response.encodeURL(getServletContext().getContextPath() + "/html/start?name=" +
- URLEncoder.encode(hostName, "UTF-8"));
+ URLEncoder.encode(hostName, StandardCharsets.UTF_8));
args[1] = hostsStart;
}
args[2] = response.encodeURL(getServletContext().getContextPath() + "/html/remove?name=" +
- URLEncoder.encode(hostName, "UTF-8"));
+ URLEncoder.encode(hostName, StandardCharsets.UTF_8));
args[3] = hostsRemove;
args[4] = hostThis;
if (host == this.installedHost) {
diff --git a/java/org/apache/catalina/manager/host/HostManagerServlet.java b/java/org/apache/catalina/manager/host/HostManagerServlet.java
index 7bc47fb11c..4b584a2b47 100644
--- a/java/org/apache/catalina/manager/host/HostManagerServlet.java
+++ b/java/org/apache/catalina/manager/host/HostManagerServlet.java
@@ -270,7 +270,7 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Set our properties from the initialization parameters
- String value = null;
+ String value;
try {
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
@@ -307,7 +307,7 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Validate the requested host name
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
writer.println(smClient.getString("hostManagerServlet.invalidHostName", name));
return;
}
@@ -319,10 +319,10 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Validate and create appBase
- File appBaseFile = null;
- File file = null;
+ File appBaseFile;
+ File file;
String applicationBase = appBase;
- if (applicationBase == null || applicationBase.length() == 0) {
+ if (applicationBase == null || applicationBase.isEmpty()) {
applicationBase = name;
}
file = new File(applicationBase);
@@ -413,7 +413,7 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Validate the requested host name
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
writer.println(smClient.getString("hostManagerServlet.invalidHostName", name));
return;
}
@@ -491,7 +491,7 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Validate the requested host name
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
writer.println(smClient.getString("hostManagerServlet.invalidHostName", name));
return;
}
@@ -542,7 +542,7 @@ public class HostManagerServlet extends HttpServlet implements ContainerServlet
}
// Validate the requested host name
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
writer.println(smClient.getString("hostManagerServlet.invalidHostName", name));
return;
}
diff --git a/java/org/apache/catalina/manager/util/SessionUtils.java b/java/org/apache/catalina/manager/util/SessionUtils.java
index 787d6037b4..be011bd09d 100644
--- a/java/org/apache/catalina/manager/util/SessionUtils.java
+++ b/java/org/apache/catalina/manager/util/SessionUtils.java
@@ -216,10 +216,6 @@ public class SessionUtils {
user = principalArray.get(0);
}
- if (null != user) {
- return user;
- }
-
return user;
} catch (IllegalStateException ise) {
// ignore: invalidated session
@@ -230,8 +226,7 @@ public class SessionUtils {
public static long getUsedTimeForSession(Session in_session) {
try {
- long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
- return diffMilliSeconds;
+ return in_session.getThisAccessedTime() - in_session.getCreationTime();
} catch (IllegalStateException ise) {
// ignore: invalidated session
return -1;
@@ -240,9 +235,8 @@ public class SessionUtils {
public static long getTTLForSession(Session in_session) {
try {
- long diffMilliSeconds = 1000 * in_session.getMaxInactiveInterval() -
+ return 1000L * in_session.getMaxInactiveInterval() -
(System.currentTimeMillis() - in_session.getThisAccessedTime());
- return diffMilliSeconds;
} catch (IllegalStateException ise) {
// ignore: invalidated session
return -1;
@@ -251,8 +245,7 @@ public class SessionUtils {
public static long getInactiveTimeForSession(Session in_session) {
try {
- long diffMilliSeconds = System.currentTimeMillis() - in_session.getThisAccessedTime();
- return diffMilliSeconds;
+ return System.currentTimeMillis() - in_session.getThisAccessedTime();
} catch (IllegalStateException ise) {
// ignore: invalidated session
return -1;
diff --git a/java/org/apache/catalina/mapper/Mapper.java b/java/org/apache/catalina/mapper/Mapper.java
index 3d1ceb3679..f2f09c95c1 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -466,8 +466,7 @@ public final class Mapper {
}
} else if (path.equals("/")) {
// Default wrapper
- MappedWrapper newWrapper = new MappedWrapper("", wrapper, jspWildCard, resourceOnly);
- context.defaultWrapper = newWrapper;
+ context.defaultWrapper = new MappedWrapper("", wrapper, jspWildCard, resourceOnly);
} else {
// Exact wrapper
final String name;
diff --git a/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java b/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
index 49f30cc799..26321d7ebc 100644
--- a/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
+++ b/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
@@ -42,7 +42,7 @@ public class ContextEnvironmentMBean extends BaseCatalinaMBean<ContextEnvironmen
ContextEnvironment ce = doGetManagedResource();
- // cannot use side-effects. It's removed and added back each time
+ // cannot use side effects. It's removed and added back each time
// there is a modification in a resource.
NamingResources nr = ce.getNamingResources();
nr.removeEnvironment(ce.getName());
diff --git a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
index c6b68a5455..73718c27d1 100644
--- a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
+++ b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
@@ -100,7 +100,7 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL
crl.setProperty(name, "" + value);
}
- // cannot use side-effects. It's removed and added back each time
+ // cannot use side effects. It's removed and added back each time
// there is a modification in a resource.
NamingResources nr = crl.getNamingResources();
nr.removeResourceLink(crl.getName());
diff --git a/java/org/apache/catalina/mbeans/ContextResourceMBean.java b/java/org/apache/catalina/mbeans/ContextResourceMBean.java
index 4b1d1f1146..b178344906 100644
--- a/java/org/apache/catalina/mbeans/ContextResourceMBean.java
+++ b/java/org/apache/catalina/mbeans/ContextResourceMBean.java
@@ -103,7 +103,7 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> {
cr.setProperty(name, "" + value);
}
- // cannot use side-effects. It's removed and added back each time
+ // cannot use side effects. It's removed and added back each time
// there is a modification in a resource.
NamingResources nr = cr.getNamingResources();
nr.removeResource(cr.getName());
diff --git a/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java
index bfbe1cf48a..d5127efa25 100644
--- a/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java
+++ b/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java
@@ -134,11 +134,11 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Create a new User and return the corresponding name.
*
- * @param username User name of the new user
+ * @param username Username of the new user
* @param password Password for the new user
* @param fullName Full name for the new user
*
- * @return the new user name
+ * @return the new username
*/
public String createUser(String username, String password, String fullName) {
UserDatabase database = (UserDatabase) this.resource;
@@ -180,7 +180,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Remove an existing user.
*
- * @param username User name to remove
+ * @param username Username to remove
*/
public void removeUser(String username) {
UserDatabase database = (UserDatabase) this.resource;
@@ -195,7 +195,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Change user credentials.
*
- * @param username The user name
+ * @param username The username
* @param password The new credentials
*/
public void changeUserPassword(String username, String password) {
@@ -210,7 +210,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Add specified role to the user.
*
- * @param username The user name
+ * @param username The username
* @param rolename The role name
*/
public void addUserRole(String username, String rolename) {
@@ -226,7 +226,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Remove specified role from the user.
*
- * @param username The user name
+ * @param username The username
* @param rolename The role name
*/
public void removeUserRole(String username, String rolename) {
@@ -242,7 +242,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Get roles for a user.
*
- * @param username The user name
+ * @param username The username
*
* @return Array of role names
*/
@@ -266,7 +266,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Add group to user.
*
- * @param username The user name
+ * @param username The username
* @param groupname The group name
*/
public void addUserGroup(String username, String groupname) {
@@ -282,7 +282,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Remove group from user.
*
- * @param username The user name
+ * @param username The username
* @param groupname The group name
*/
public void removeUserGroup(String username, String groupname) {
@@ -298,7 +298,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean {
/**
* Get groups for a user.
*
- * @param username The user name
+ * @param username The username
*
* @return Array of group names
*/
diff --git a/java/org/apache/catalina/mbeans/MBeanFactory.java b/java/org/apache/catalina/mbeans/MBeanFactory.java
index cf3b76a24a..838d8a415d 100644
--- a/java/org/apache/catalina/mbeans/MBeanFactory.java
+++ b/java/org/apache/catalina/mbeans/MBeanFactory.java
@@ -203,7 +203,7 @@ public class MBeanFactory {
* @param dataSourceName the datasource name
* @param roleNameCol the column name for the role names
* @param userCredCol the column name for the user credentials
- * @param userNameCol the column name for the user names
+ * @param userNameCol the column name for the usernames
* @param userRoleTable the table name for the roles table
* @param userTable the table name for the users
*
diff --git a/java/org/apache/catalina/mbeans/MBeanUtils.java b/java/org/apache/catalina/mbeans/MBeanUtils.java
index fe0281d688..2ae614356b 100644
--- a/java/org/apache/catalina/mbeans/MBeanUtils.java
+++ b/java/org/apache/catalina/mbeans/MBeanUtils.java
@@ -513,7 +513,7 @@ public class MBeanUtils {
*/
public static synchronized Registry createRegistry() {
if (registry == null) {
- registry = Registry.getRegistry(null, null);
+ registry = Registry.getRegistryNonNull(null, null);
ClassLoader cl = MBeanUtils.class.getClassLoader();
registry.loadDescriptors("org.apache.catalina.mbeans", cl);
@@ -544,7 +544,7 @@ public class MBeanUtils {
*/
public static synchronized MBeanServer createServer() {
if (mserver == null) {
- mserver = Registry.getRegistry(null, null).getMBeanServer();
+ mserver = Registry.getRegistryNonNull(null, null).getMBeanServer();
}
return mserver;
}
diff --git a/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java
index d4140176f3..6aef4d11f5 100644
--- a/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java
+++ b/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java
@@ -37,7 +37,7 @@ import org.apache.tomcat.util.res.StringManager;
* <p>
* A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.users.SparseUserDatabase</code>
* component. The main difference is that the MBeans are created on demand (for example, the findUser method would
- * register the corresponding user and make it available for management. All the MBeans created for users, groups and
+ * register the corresponding user and make it available for management). All the MBeans created for users, groups and
* roles are then discarded when save is invoked.
* </p>
*
@@ -177,7 +177,7 @@ public class SparseUserDatabaseMBean extends BaseModelMBean {
/**
* Create a new User and return the corresponding MBean Name.
*
- * @param username User name of the new user
+ * @param username Username of the new user
* @param password Password for the new user
* @param fullName Full name for the new user
*
@@ -247,9 +247,9 @@ public class SparseUserDatabaseMBean extends BaseModelMBean {
/**
- * Return the MBean Name for the specified user name (if any); otherwise return <code>null</code>.
+ * Return the MBean Name for the specified username (if any); otherwise return <code>null</code>.
*
- * @param username User name to look up
+ * @param username Username to look up
*
* @return the user object name
*/
@@ -314,7 +314,7 @@ public class SparseUserDatabaseMBean extends BaseModelMBean {
/**
* Remove an existing user and destroy the corresponding MBean.
*
- * @param username User name to remove
+ * @param username Username to remove
*/
public void removeUser(String username) {
UserDatabase database = (UserDatabase) this.resource;
diff --git a/java/org/apache/catalina/realm/AuthenticatedUserRealm.java b/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
index 44cf8da750..23f319150a 100644
--- a/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
+++ b/java/org/apache/catalina/realm/AuthenticatedUserRealm.java
@@ -22,7 +22,7 @@ import java.security.Principal;
* This Realm is intended for use with Authenticator implementations
* ({@link org.apache.catalina.authenticator.SSLAuthenticator},
* {@link org.apache.catalina.authenticator.SpnegoAuthenticator}) that authenticate the user as well as obtain the user
- * credentials. An authenticated Principal is always created from the user name presented to without further validation.
+ * credentials. An authenticated Principal is always created from the username presented to without further validation.
* <p>
* <strong>Note:</strong> It is unsafe to use this Realm with Authenticator implementations that do not validate the
* provided credentials.
diff --git a/java/org/apache/catalina/realm/DataSourceRealm.java b/java/org/apache/catalina/realm/DataSourceRealm.java
index 7f34dfdd3d..42d3cee775 100644
--- a/java/org/apache/catalina/realm/DataSourceRealm.java
+++ b/java/org/apache/catalina/realm/DataSourceRealm.java
@@ -206,7 +206,7 @@ public class DataSourceRealm extends RealmBase {
}
/**
- * @return the table that holds user data..
+ * @return the table that holds user data
*/
public String getUserTable() {
return userTable;
@@ -403,7 +403,7 @@ public class DataSourceRealm extends RealmBase {
/**
- * Return the password associated with the given principal's user name.
+ * Return the password associated with the given principal's username.
*
* @param dbConnection The database connection to be used
* @param username Username for which password should be retrieved
@@ -447,9 +447,9 @@ public class DataSourceRealm extends RealmBase {
}
/**
- * Return the roles associated with the given user name.
+ * Return the roles associated with the given username.
*
- * @param username User name for which roles should be retrieved
+ * @param username Username for which roles should be retrieved
*
* @return an array list of the role names
*/
@@ -470,10 +470,10 @@ public class DataSourceRealm extends RealmBase {
/**
- * Return the roles associated with the given user name.
+ * Return the roles associated with the given username.
*
* @param dbConnection The database connection to be used
- * @param username User name for which roles should be retrieved
+ * @param username Username for which roles should be retrieved
*
* @return an array list of the role names
*/
diff --git a/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java b/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
index 03db3b5bb2..eda0aa816a 100644
--- a/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
+++ b/java/org/apache/catalina/realm/DigestCredentialHandlerBase.java
@@ -110,7 +110,7 @@ public abstract class DigestCredentialHandlerBase implements CredentialHandler {
if (saltLength == 0) {
salt = new byte[0];
} else if (saltLength > 0) {
- // Double checked locking. OK since random is volatile.
+ // Double-checked locking. OK since random is volatile.
if (random == null) {
synchronized (randomLock) {
if (random == null) {
@@ -137,14 +137,7 @@ public abstract class DigestCredentialHandlerBase implements CredentialHandler {
// Output the simple/old format for backwards compatibility
return serverCredential;
} else {
- StringBuilder result = new StringBuilder((saltLength << 1) + 10 + serverCredential.length() + 2);
- result.append(HexUtils.toHexString(salt));
- result.append('$');
- result.append(iterations);
- result.append('$');
- result.append(serverCredential);
-
- return result.toString();
+ return HexUtils.toHexString(salt) + '$' + iterations + '$' + serverCredential;
}
}
@@ -236,7 +229,7 @@ public abstract class DigestCredentialHandlerBase implements CredentialHandler {
/**
* Generates the equivalent stored credentials for the given input credentials, salt, iterations and key length. The
- * default implementation calls ignores the key length and calls {@link #mutate(String, byte[], int)}. Sub-classes
+ * default implementation calls ignores the key length and calls {@link #mutate(String, byte[], int)}. Subclasses
* that use the key length should override this method.
*
* @param inputCredentials User provided credentials
diff --git a/java/org/apache/catalina/realm/JAASRealm.java b/java/org/apache/catalina/realm/JAASRealm.java
index 4c1fe5399a..0fa9a1f20a 100644
--- a/java/org/apache/catalina/realm/JAASRealm.java
+++ b/java/org/apache/catalina/realm/JAASRealm.java
@@ -108,7 +108,7 @@ import org.apache.tomcat.util.file.ConfigurationSource;
* <blockquote><code>CATALINA_OPTS="-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config"</code></blockquote>
* </li>
* <li>As part of the login process, JAASRealm registers its own <code>CallbackHandler</code>, called (unsurprisingly)
- * <code>JAASCallbackHandler</code>. This handler supplies the HTTP requests's username and credentials to the
+ * <code>JAASCallbackHandler</code>. This handler supplies the HTTP requests' username and credentials to the
* user-supplied <code>LoginModule</code></li>
* <li>As with other <code>Realm</code> implementations, digested passwords are supported if the
* <code><Realm></code> element in <code>server.xml</code> contains a <code>digest</code> attribute;
@@ -161,7 +161,7 @@ public class JAASRealm extends RealmBase {
protected volatile boolean jaasConfigurationLoaded = false;
/**
- * Keeps track if JAAS invocation of login modules was successful or not. By default it is true unless we detect
+ * Keeps track if JAAS invocation of login modules was successful or not. By default, it is true unless we detect
* JAAS login module can't perform the login. This will be used for realm's {@link #isAvailable()} status so that
* {@link LockOutRealm} will not lock the user out if JAAS login modules are unavailable to perform the actual
* login.
@@ -329,7 +329,7 @@ public class JAASRealm extends RealmBase {
/**
* Perform the actual JAAS authentication.
*
- * @param username The user name
+ * @param username The username
* @param callbackHandler The callback handler
*
* @return the associated principal, or <code>null</code> if there is none.
@@ -426,7 +426,7 @@ public class JAASRealm extends RealmBase {
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
log.error(sm.getString("jaasRealm.unexpectedError"), e);
- // JAAS throws exception different than LoginException so mark the
+ // JAAS throws exception different from LoginException so mark the
// realm as unavailable
invocationSuccess = false;
return null;
@@ -451,7 +451,7 @@ public class JAASRealm extends RealmBase {
return principal;
} catch (Throwable t) {
log.error(sm.getString("jaasRealm.unexpectedError"), t);
- // JAAS throws exception different than LoginException so mark the realm as unavailable
+ // JAAS throws exception different from LoginException so mark the realm as unavailable
invocationSuccess = false;
return null;
}
@@ -459,7 +459,7 @@ public class JAASRealm extends RealmBase {
/**
- * @return the password associated with the given principal's user name. This always returns null as the JAASRealm
+ * @return the password associated with the given principal's username. This always returns null as the JAASRealm
* has no way of obtaining this information.
*/
@Override
@@ -485,7 +485,7 @@ public class JAASRealm extends RealmBase {
* the LoginModules are mapped to roles, but only if their respective classes match one of the "role class" classes.
* If a user Principal cannot be constructed, return <code>null</code>.
*
- * @param username The associated user name
+ * @param username The associated username
* @param subject The <code>Subject</code> representing the logged-in user
* @param loginContext Associated with the Principal so {@link LoginContext#logout()} can be called later
*
diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java
index 5e77d610f6..373c638b1e 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -1220,7 +1220,7 @@ public class JNDIRealm extends RealmBase {
*
* @exception NamingException if a directory server error occurs
*/
- public Principal authenticate(JNDIConnection connection, String username, String credentials)
+ protected Principal authenticate(JNDIConnection connection, String username, String credentials)
throws NamingException {
if (username == null || username.isEmpty() || credentials == null || credentials.isEmpty()) {
@@ -2386,10 +2386,10 @@ public class JNDIRealm extends RealmBase {
/**
- * Get the principal associated with the specified user name.
+ * Get the principal associated with the specified username.
*
* @param connection The directory context
- * @param username The user name
+ * @param username The username
* @param gssCredential The credentials
*
* @return the Principal associated with the given certificate.
@@ -2763,7 +2763,7 @@ public class JNDIRealm extends RealmBase {
/**
* Given a string containing LDAP patterns for user locations (separated by parentheses in a pseudo-LDAP search
- * string format - "(location1)(location2)", returns an array of those paths. Real LDAP search strings are supported
+ * string format - "(location1)(location2)"), returns an array of those paths. Real LDAP search strings are supported
* as well (though only the "|" "OR" type).
*
* @param userPatternString - a string LDAP search paths surrounded by parentheses
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java b/java/org/apache/catalina/realm/LockOutRealm.java
index 665053f6a1..22bc177570 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -202,7 +202,7 @@ public class LockOutRealm extends CombinedRealm {
/*
* Checks to see if the current user is locked. If this is associated with a login attempt, then the last access
- * time will be recorded and any attempt to authenticated a locked user will log a warning.
+ * time will be recorded and any attempt to authenticate a locked user will log a warning.
*/
public boolean isLocked(String username) {
LockRecord lockRecord;
diff --git a/java/org/apache/catalina/realm/MemoryRealm.java b/java/org/apache/catalina/realm/MemoryRealm.java
index cf9f15592a..8b1fd7ec3e 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -63,13 +63,13 @@ public class MemoryRealm extends RealmBase {
/**
- * The set of valid Principals for this Realm, keyed by user name.
+ * The set of valid Principals for this Realm, keyed by username.
*/
private final Map<String,GenericPrincipal> principals = new HashMap<>();
/**
- * The set of credentials for this Realm, keyed by user name.
+ * The set of credentials for this Realm, keyed by username.
*/
private final Map<String,String> credentials = new HashMap<>();
diff --git a/java/org/apache/catalina/realm/NullRealm.java b/java/org/apache/catalina/realm/NullRealm.java
index 83e4693d9c..cc133a4b8a 100644
--- a/java/org/apache/catalina/realm/NullRealm.java
+++ b/java/org/apache/catalina/realm/NullRealm.java
@@ -19,7 +19,7 @@ package org.apache.catalina.realm;
import java.security.Principal;
/**
- * Minimal Realm implementation that always returns null when an attempt is made to validate a user name and password.
+ * Minimal Realm implementation that always returns null when an attempt is made to validate a username and password.
* It is intended to be used as a default Realm implementation when no other Realm is specified.
*/
public class NullRealm extends RealmBase {
diff --git a/java/org/apache/catalina/realm/RealmBase.java b/java/org/apache/catalina/realm/RealmBase.java
index d8d081dc35..8a21e699dc 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -138,12 +138,12 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
protected boolean validate = true;
/**
- * The name of the class to use for retrieving user names from X509 certificates.
+ * The name of the class to use for retrieving usernames from X509 certificates.
*/
protected String x509UsernameRetrieverClassName;
/**
- * The object that will extract user names from X509 client certificates.
+ * The object that will extract usernames from X509 client certificates.
*/
protected X509UsernameRetriever x509UsernameRetriever;
@@ -155,7 +155,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
/**
* When processing users authenticated via the GSS-API, should any "@..." be stripped from the end of the
- * user name?
+ * username?
*/
protected boolean stripRealmForGss = true;
@@ -268,19 +268,19 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
}
/**
- * Gets the name of the class that will be used to extract user names from X509 client certificates.
+ * Gets the name of the class that will be used to extract usernames from X509 client certificates.
*
- * @return The name of the class that will be used to extract user names from X509 client certificates.
+ * @return The name of the class that will be used to extract usernames from X509 client certificates.
*/
public String getX509UsernameRetrieverClassName() {
return x509UsernameRetrieverClassName;
}
/**
- * Sets the name of the class that will be used to extract user names from X509 client certificates. The class must
+ * Sets the name of the class that will be used to extract usernames from X509 client certificates. The class must
* implement X509UsernameRetriever.
*
- * @param className The name of the class that will be used to extract user names from X509 client certificates.
+ * @param className The name of the class that will be used to extract usernames from X509 client certificates.
*
* @see X509UsernameRetriever
*/
@@ -1123,9 +1123,9 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
/**
- * Return the digest associated with given principal's user name.
+ * Return the digest associated with given principal's username.
*
- * @param username The user name
+ * @param username The username
* @param realmName The realm name
*
* @return the digest for the specified user
@@ -1189,9 +1189,9 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
/**
* Get the password for the specified user.
*
- * @param username The user name
+ * @param username The username
*
- * @return the password associated with the given principal's user name.
+ * @return the password associated with the given principal's username.
*/
protected abstract String getPassword(String username);
@@ -1217,9 +1217,9 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
/**
* Get the principal associated with the specified user.
*
- * @param username The user name
+ * @param username The username
*
- * @return the Principal associated with the given user name.
+ * @return the Principal associated with the given username.
*/
protected abstract Principal getPrincipal(String username);
@@ -1231,7 +1231,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
* @param gssCredential the GSS credential of the principal
* @param gssContext the established GSS context
*
- * @return the principal associated with the given user name.
+ * @return the principal associated with the given username.
*/
protected Principal getPrincipal(GSSName gssName, GSSCredential gssCredential, GSSContext gssContext) {
return getPrincipal(gssName, gssCredential);
@@ -1244,7 +1244,7 @@ public abstract class RealmBase extends LifecycleMBeanBase implements Realm {
* @param gssName The GSS name
* @param gssCredential the GSS credential of the principal
*
- * @return the principal associated with the given user name.
+ * @return the principal associated with the given username.
*/
protected Principal getPrincipal(GSSName gssName, GSSCredential gssCredential) {
String name = gssName.toString();
diff --git a/java/org/apache/catalina/realm/X509UsernameRetriever.java b/java/org/apache/catalina/realm/X509UsernameRetriever.java
index f8042c8da1..c113909d5c 100644
--- a/java/org/apache/catalina/realm/X509UsernameRetriever.java
+++ b/java/org/apache/catalina/realm/X509UsernameRetriever.java
@@ -19,15 +19,15 @@ package org.apache.catalina.realm;
import java.security.cert.X509Certificate;
/**
- * Provides an interface for retrieving a user name from an X509Certificate.
+ * Provides an interface for retrieving a username from an X509Certificate.
*/
public interface X509UsernameRetriever {
/**
- * Gets a user name from an X509Certificate.
+ * Gets a username from an X509Certificate.
*
- * @param cert The certificate containing the user name.
+ * @param cert The certificate containing the username.
*
- * @return An appropriate user name obtained from one or more fields in the certificate.
+ * @return An appropriate username obtained from one or more fields in the certificate.
*/
String getUsername(X509Certificate cert);
}
diff --git a/java/org/apache/catalina/security/SecurityListener.java b/java/org/apache/catalina/security/SecurityListener.java
index 7df83fe91b..0d0697a70a 100644
--- a/java/org/apache/catalina/security/SecurityListener.java
+++ b/java/org/apache/catalina/security/SecurityListener.java
@@ -86,7 +86,7 @@ public class SecurityListener implements LifecycleListener {
/**
* Set the list of operating system users not permitted to run Tomcat. By default, only root is prevented from
* running Tomcat. Calling this method with null or the empty string will clear the list of users and effectively
- * disables this check. User names will always be checked in a case insensitive manner using the system default
+ * disables this check. Usernames will always be checked in a case-insensitive manner using the system default
* Locale.
*
* @param userNameList A comma separated list of operating system users not permitted to run Tomcat
@@ -108,7 +108,7 @@ public class SecurityListener implements LifecycleListener {
/**
* Returns the current list of operating system users not permitted to run Tomcat.
*
- * @return A comma separated list of operating system user names.
+ * @return A comma separated list of operating system usernames.
*/
public String getCheckedOsUsers() {
return StringUtils.join(checkedOsUsers);
diff --git a/java/org/apache/catalina/security/TLSCertificateReloadListener.java b/java/org/apache/catalina/security/TLSCertificateReloadListener.java
index 3db6e286c3..6e321ebd05 100644
--- a/java/org/apache/catalina/security/TLSCertificateReloadListener.java
+++ b/java/org/apache/catalina/security/TLSCertificateReloadListener.java
@@ -53,7 +53,7 @@ public class TLSCertificateReloadListener implements LifecycleListener {
private int daysBefore = 14;
// State
- private Calendar nextCheck = Calendar.getInstance();
+ private final Calendar nextCheck = Calendar.getInstance();
/**
@@ -140,7 +140,7 @@ public class TLSCertificateReloadListener implements LifecycleListener {
*/
calendar.add(Calendar.DAY_OF_MONTH, getDaysBefore());
- // Check all of the certificates
+ // Check all the certificates
Service[] services = server.findServices();
for (Service service : services) {
Connector[] connectors = service.findConnectors();
diff --git a/java/org/apache/catalina/servlets/CGIServlet.java b/java/org/apache/catalina/servlets/CGIServlet.java
index 473eeeb28c..fabce4c0e2 100644
--- a/java/org/apache/catalina/servlets/CGIServlet.java
+++ b/java/org/apache/catalina/servlets/CGIServlet.java
@@ -240,7 +240,7 @@ public final class CGIServlet extends HttpServlet {
private String parameterEncoding = System.getProperty("file.encoding", "UTF-8");
/* The HTTP methods this Servlet will pass to the CGI script */
- private Set<String> cgiMethods = new HashSet<>();
+ private final Set<String> cgiMethods = new HashSet<>();
private boolean cgiMethodsAll = false;
@@ -270,7 +270,7 @@ public final class CGIServlet extends HttpServlet {
private boolean enableCmdLineArguments = false;
/**
- * Limits the encoded form of individual command line arguments. By default values are limited to those allowed by
+ * Limits the encoded form of individual command line arguments. By default, values are limited to those allowed by
* the RFC. See https://tools.ietf.org/html/rfc3875#section-4.4 Uses \Q...\E to avoid individual quoting.
*/
private Pattern cmdLineArgumentsEncodedPattern = Pattern.compile("[\\w\\Q%;/?:@&,$-.!~*'()\\E]+");
@@ -933,7 +933,7 @@ public final class CGIServlet extends HttpServlet {
* (see method findCGI, where the real work is done)
*
*/
- if (pathInfo == null || (pathInfo.substring(sCGIFullName.length()).length() <= 0)) {
+ if (pathInfo == null || (pathInfo.substring(sCGIFullName.length()).isEmpty())) {
sPathInfoCGI = "";
} else {
sPathInfoCGI = pathInfo.substring(sCGIFullName.length());
@@ -955,7 +955,7 @@ public final class CGIServlet extends HttpServlet {
* path_translated = servletContext.getRealPath("/trans1/trans2")
*
* That is, PATH_TRANSLATED = webAppRootDir + sPathInfoCGI
- * (unless sPathInfoCGI is null or blank, then the CGI
+ * (unless sPathInfoCGI is null or blank), then the CGI
* specification dictates that the PATH_TRANSLATED metavariable
* SHOULD NOT be defined.
*
@@ -1400,9 +1400,9 @@ public final class CGIServlet extends HttpServlet {
* <LI><u>Allowed characters in pathInfo</u>: This implementation does not allow ASCII NUL nor any character
* which cannot be URL-encoded according to internet standards;
* <LI><u>Allowed characters in path segments</u>: This implementation does not allow non-terminal NULL segments
- * in the the path -- IOExceptions may be thrown;
+ * in the path -- IOExceptions may be thrown;
* <LI><u>"<code>.</code>" and "<code>..</code>" path segments</u>: This implementation does not allow
- * "<code>.</code>" and "<code>..</code>" in the the path, and such characters will result in an IOException
+ * "<code>.</code>" and "<code>..</code>" in the path, and such characters will result in an IOException
* being thrown (this should never happen since Tomcat normalises the requestURI before determining the
* contextPath, servletPath and pathInfo);
* <LI><u>Implementation limitations</u>: This implementation does not impose any limitations except as
diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java
index 8f24572a28..de49fdf8e7 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1158,7 +1158,7 @@ public class DefaultServlet extends HttpServlet {
} else {
- if ((ranges == null) || (ranges.getEntries().isEmpty())) {
+ if (ranges.getEntries().isEmpty()) {
return;
}
@@ -1240,7 +1240,7 @@ public class DefaultServlet extends HttpServlet {
skip(is, 2, stripBom);
return StandardCharsets.UTF_16BE;
}
- // Delay the UTF_16LE check if there are more that 2 bytes since it
+ // Delay the UTF_16LE check if there are more than 2 bytes since it
// overlaps with UTF-32LE.
if (count == 2 && b0 == 0xFF && b1 == 0xFE) {
skip(is, 2, stripBom);
@@ -1829,7 +1829,7 @@ public class DefaultServlet extends HttpServlet {
sb.append("<thead>\r\n");
sb.append("<tr>\r\n");
sb.append("<th align=\"left\"><font size=\"+1\"><strong>");
- if (sortListings) {
+ if (order != null) {
sb.append("<a href=\"?C=N;O=");
sb.append(getOrderChar(order, 'N'));
sb.append("\">");
@@ -1840,7 +1840,7 @@ public class DefaultServlet extends HttpServlet {
}
sb.append("</strong></font></th>\r\n");
sb.append("<th align=\"center\"><font size=\"+1\"><strong>");
- if (sortListings) {
+ if (order != null) {
sb.append("<a href=\"?C=S;O=");
sb.append(getOrderChar(order, 'S'));
sb.append("\">");
@@ -1851,7 +1851,7 @@ public class DefaultServlet extends HttpServlet {
}
sb.append("</strong></font></th>\r\n");
sb.append("<th align=\"right\"><font size=\"+1\"><strong>");
- if (sortListings) {
+ if (order != null) {
sb.append("<a href=\"?C=M;O=");
sb.append(getOrderChar(order, 'M'));
sb.append("\">");
@@ -1997,7 +1997,10 @@ public class DefaultServlet extends HttpServlet {
} else {
reader = new InputStreamReader(is);
}
- copyRange(reader, new PrintWriter(buffer));
+ IOException e = copyRange(reader, new PrintWriter(buffer));
+ if (debug > 10) {
+ log("readme '" + readmeFile + "' output error: " + e.getMessage());
+ }
} catch (IOException e) {
log(sm.getString("defaultServlet.readerCloseFailed"), e);
} finally {
@@ -2067,7 +2070,7 @@ public class DefaultServlet extends HttpServlet {
}
/*
- * Open and read in file in one fell swoop to reduce chance chance of leaving handle open.
+ * Open and read in file in one fell swoop to reduce the chance of leaving handle open.
*/
if (globalXsltFile != null) {
File f = validateGlobalXsltFile();
@@ -2848,7 +2851,7 @@ public class DefaultServlet extends HttpServlet {
/**
* A class encapsulating the sorting of resources.
*/
- private static class SortManager {
+ protected static class SortManager {
/**
* The default sort.
*/
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java
index de82211ee4..fc6d7220f8 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -137,7 +137,7 @@ import org.xml.sax.SAXException;
* </servlet-mapping>
* </pre>
*
- * By default access to /WEB-INF and META-INF are not available via WebDAV. To enable access to these URLs, add:
+ * By default, access to /WEB-INF and META-INF are not available via WebDAV. To enable access to these URLs, add:
*
* <pre>
* <init-param>
@@ -152,7 +152,7 @@ import org.xml.sax.SAXException;
* http://host:port/context/webdavedit/content
* <p>
* The Servlet provides support for arbitrary dead properties on all resources (dead properties are properties whose
- * values are not protected by the server, such as the content length of a resource). By default the Servlet will use
+ * values are not protected by the server, such as the content length of a resource). By default, the Servlet will use
* non persistent memory storage for them. Persistence can be achieved by implementing the <code>PropertyStore</code>
* interface and configuring the Servlet to use that store. The <code>propertyStore</code> init-param allows configuring
* the class name of the store to use, while the parameters in the form of <code>store.xxx</code> will be set on the
@@ -476,7 +476,7 @@ public class WebdavServlet extends DefaultServlet implements PeriodicEventListen
}
/**
- * @return the statusCode the statusCode to set as a result of the operation
+ * @return the statusCode to set as a result of the operation
*/
public int getStatusCode() {
return this.statusCode;
diff --git a/java/org/apache/catalina/session/Constants.java b/java/org/apache/catalina/session/Constants.java
index 3948fe8dc5..fcaa7f746e 100644
--- a/java/org/apache/catalina/session/Constants.java
+++ b/java/org/apache/catalina/session/Constants.java
@@ -16,8 +16,6 @@
*/
package org.apache.catalina.session;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import org.apache.catalina.Globals;
@@ -35,12 +33,7 @@ public class Constants {
* Set of session attribute names used internally by Tomcat that should always be removed from the session before it
* is persisted, replicated or equivalent.
*/
- public static final Set<String> excludedAttributeNames;
+ public static final Set<String> excludedAttributeNames =
+ Set.of(Globals.SUBJECT_ATTR, CrawlerSessionManagerValve.class.getName());
- static {
- Set<String> names = new HashSet<>();
- names.add(Globals.SUBJECT_ATTR);
- names.add(CrawlerSessionManagerValve.class.getName());
- excludedAttributeNames = Collections.unmodifiableSet(names);
- }
}
diff --git a/java/org/apache/catalina/session/StandardManager.java b/java/org/apache/catalina/session/StandardManager.java
index 53edc00fd4..18bf534aaf 100644
--- a/java/org/apache/catalina/session/StandardManager.java
+++ b/java/org/apache/catalina/session/StandardManager.java
@@ -47,7 +47,7 @@ import org.apache.tomcat.util.ExceptionUtils;
/**
* Standard implementation of the <b>Manager</b> interface that provides simple session persistence across restarts of
* this component (such as when the entire server is shut down and restarted, or when a particular web application is
- * reloaded.
+ * reloaded).
* <p>
* <b>IMPLEMENTATION NOTE</b>: Correct behavior of session storing and reloading depends upon external calls to the
* <code>start()</code> and <code>stop()</code> methods of this class at the correct times.
diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java
index a34a929599..629f08437a 100644
--- a/java/org/apache/catalina/session/StandardSession.java
+++ b/java/org/apache/catalina/session/StandardSession.java
@@ -65,11 +65,6 @@ import org.apache.tomcat.util.res.StringManager;
* Standard implementation of the <b>Session</b> interface. This object is serializable, so that it can be stored in
* persistent storage or transferred to a different JVM for distributable session support.
* <p>
- * <b>IMPLEMENTATION NOTE</b>: An instance of this class represents both the internal (Session) and application level
- * (HttpSession) view of the session. However, because the class itself is not declared public, Java logic outside of
- * the <code>org.apache.catalina.session</code> package cannot cast an HttpSession view of this instance back to a
- * Session view.
- * <p>
* <b>IMPLEMENTATION NOTE</b>: If you add fields to this class, you must make sure that you carry them over in the
* read/writeObject methods so that this class is properly serialized.
*
@@ -1099,7 +1094,7 @@ public class StandardSession implements HttpSession, Session, Serializable {
/**
* {@inheritDoc}
* <p>
- * This implementation simply checks the value for serializability. Sub-classes might use other distribution
+ * This implementation simply checks the value for serializability. Subclasses might use other distribution
* technology not based on serialization and can override this check.
*/
@Override
diff --git a/java/org/apache/catalina/ssi/ExpressionParseTree.java b/java/org/apache/catalina/ssi/ExpressionParseTree.java
index c1346a2a95..8996263580 100644
--- a/java/org/apache/catalina/ssi/ExpressionParseTree.java
+++ b/java/org/apache/catalina/ssi/ExpressionParseTree.java
@@ -58,7 +58,7 @@ public class ExpressionParseTree {
* Creates a new parse tree for the specified expression.
*
* @param expr The expression string
- * @param ssiMediator Used to evaluated the expressions
+ * @param ssiMediator Used to evaluate the expressions
*
* @throws ParseException a parsing error occurred
*/
diff --git a/java/org/apache/catalina/ssi/SSIConditional.java b/java/org/apache/catalina/ssi/SSIConditional.java
index b1c5ea4f73..45885c746f 100644
--- a/java/org/apache/catalina/ssi/SSIConditional.java
+++ b/java/org/apache/catalina/ssi/SSIConditional.java
@@ -100,8 +100,6 @@ public class SSIConditional implements SSICommand {
state.branchTaken = true;
} else {
throw new SSIStopProcessingException();
- // throw new SsiCommandException( "Not a conditional command:" +
- // cmdName );
}
return lastModified;
}
@@ -115,13 +113,11 @@ public class SSIConditional implements SSICommand {
String expr = getExpression(names, values);
if (expr == null) {
throw new SSIStopProcessingException();
- // throw new SsiCommandException( "No expression specified." );
}
try {
ExpressionParseTree tree = new ExpressionParseTree(expr, ssiMediator);
return tree.evaluateTree();
} catch (ParseException e) {
- // throw new SsiCommandException( "Error parsing expression." );
throw new SSIStopProcessingException();
}
}
diff --git a/java/org/apache/catalina/ssi/SSIConditionalState.java b/java/org/apache/catalina/ssi/SSIConditionalState.java
index e678dd9407..6486d75e9a 100644
--- a/java/org/apache/catalina/ssi/SSIConditionalState.java
+++ b/java/org/apache/catalina/ssi/SSIConditionalState.java
@@ -24,7 +24,7 @@ package org.apache.catalina.ssi;
* @author Dan Sandberg
* @author Paul Speed
*/
-class SSIConditionalState {
+public class SSIConditionalState {
/**
* Set to true if the current conditional has already been completed, i.e.: a branch was taken.
*/
diff --git a/java/org/apache/catalina/ssi/SSIFlastmod.java b/java/org/apache/catalina/ssi/SSIFlastmod.java
index 505f1d5f1f..72c0d32e04 100644
--- a/java/org/apache/catalina/ssi/SSIFlastmod.java
+++ b/java/org/apache/catalina/ssi/SSIFlastmod.java
@@ -64,7 +64,7 @@ public final class SSIFlastmod implements SSICommand {
}
- protected String formatDate(Date date, String configTimeFmt) {
+ private String formatDate(Date date, String configTimeFmt) {
Strftime strftime = new Strftime(configTimeFmt, Locale.US);
return strftime.format(date);
}
diff --git a/java/org/apache/catalina/ssi/SSIFsize.java b/java/org/apache/catalina/ssi/SSIFsize.java
index ee0ff574d8..e3c1688038 100644
--- a/java/org/apache/catalina/ssi/SSIFsize.java
+++ b/java/org/apache/catalina/ssi/SSIFsize.java
@@ -79,7 +79,7 @@ public final class SSIFsize implements SSICommand {
// We try to mimic httpd here, as we do everywhere.
// All the 'magic' numbers are from the util_script.c httpd source file.
// Should use KiB and MiB in output but use k and M for consistency with httpd.
- protected String formatSize(long size, String format) {
+ private String formatSize(long size, String format) {
String retString;
if (format.equalsIgnoreCase("bytes")) {
DecimalFormat decimalFormat = new DecimalFormat("#,##0");
diff --git a/java/org/apache/catalina/ssi/SSIServlet.java b/java/org/apache/catalina/ssi/SSIServlet.java
index faaeae6d7e..f4cbbec032 100644
--- a/java/org/apache/catalina/ssi/SSIServlet.java
+++ b/java/org/apache/catalina/ssi/SSIServlet.java
@@ -198,7 +198,7 @@ public class SSIServlet extends HttpServlet {
if (lastModified > 0) {
res.setDateHeader("last-modified", lastModified);
}
- if (buffered) {
+ if (stringWriter != null) {
printWriter.flush();
@SuppressWarnings("null")
String text = stringWriter.toString();
diff --git a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
index deae097843..3d20e61f24 100644
--- a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
+++ b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
@@ -308,14 +308,8 @@ public class SSIServletExternalResolver implements SSIExternalResolver {
} else if (nameParts[1].equals("PROTOCOL")) {
retVal = req.getProtocol();
} else if (nameParts[1].equals("SOFTWARE")) {
- StringBuilder rv = new StringBuilder(context.getServerInfo());
- rv.append(' ');
- rv.append(System.getProperty("java.vm.name"));
- rv.append('/');
- rv.append(System.getProperty("java.vm.version"));
- rv.append(' ');
- rv.append(System.getProperty("os.name"));
- retVal = rv.toString();
+ retVal = context.getServerInfo() + ' ' + System.getProperty("java.vm.name") +
+ '/' + System.getProperty("java.vm.version") + ' ' + System.getProperty("os.name");
}
} else if (name.equalsIgnoreCase("UNIQUE_ID")) {
retVal = req.getRequestedSessionId();
diff --git a/java/org/apache/catalina/startup/Bootstrap.java b/java/org/apache/catalina/startup/Bootstrap.java
index 4155285766..c91274cbfd 100644
--- a/java/org/apache/catalina/startup/Bootstrap.java
+++ b/java/org/apache/catalina/startup/Bootstrap.java
@@ -201,7 +201,7 @@ public final class Bootstrap {
*
* @return the modified string
*/
- protected String replace(String str) {
+ private String replace(String str) {
// Implementation is copied from ClassLoaderLogManager.replace(),
// but added special processing for catalina.home and catalina.base.
String result = str;
@@ -494,11 +494,12 @@ public final class Bootstrap {
}
} catch (Throwable t) {
// Unwrap the Exception for clearer error reporting
- if (t instanceof InvocationTargetException && t.getCause() != null) {
- t = t.getCause();
+ Throwable throwable = t;
+ if (throwable instanceof InvocationTargetException && throwable.getCause() != null) {
+ throwable = throwable.getCause();
}
- handleThrowable(t);
- log.error("Error running command", t);
+ handleThrowable(throwable);
+ log.error("Error running command", throwable);
System.exit(1);
}
}
@@ -571,7 +572,7 @@ public final class Bootstrap {
}
// Protected for unit testing
- protected static String[] getPaths(String value) {
+ static String[] getPaths(String value) {
List<String> result = new ArrayList<>();
Matcher matcher = PATH_PATTERN.matcher(value);
diff --git a/java/org/apache/catalina/startup/Catalina.java b/java/org/apache/catalina/startup/Catalina.java
index d8e83cc7db..5b74dab22d 100644
--- a/java/org/apache/catalina/startup/Catalina.java
+++ b/java/org/apache/catalina/startup/Catalina.java
@@ -961,7 +961,7 @@ public class Catalina {
// --------------------------------------- CatalinaShutdownHook Inner Class
- // XXX Should be moved to embedded !
+
/**
* Shutdown hook which will perform a clean shutdown of Catalina if needed.
*/
diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java
index b76e171d16..d05f88bc44 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -2086,7 +2086,7 @@ public class ContextConfig implements LifecycleListener {
private class AnnotationScanTask implements Runnable {
private final WebXml fragment;
private final boolean handlesTypesOnly;
- private Map<String,JavaClassCacheEntry> javaClassCache;
+ private final Map<String,JavaClassCacheEntry> javaClassCache;
private AnnotationScanTask(WebXml fragment, boolean handlesTypesOnly,
Map<String,JavaClassCacheEntry> javaClassCache) {
@@ -2589,7 +2589,7 @@ public class ContextConfig implements LifecycleListener {
boolean urlPatternsSet = false;
boolean servletNamesSet = false;
boolean dispatchTypesSet = false;
- String[] urlPatterns = null;
+ String[] urlPatterns;
for (ElementValuePair evp : evps) {
String name = evp.getNameString();
@@ -2727,7 +2727,7 @@ public class ContextConfig implements LifecycleListener {
return result;
}
- private static class DefaultWebXmlCacheEntry {
+ protected static class DefaultWebXmlCacheEntry {
private final WebXml webXml;
private final long globalTimeStamp;
private final long hostTimeStamp;
@@ -2763,7 +2763,7 @@ public class ContextConfig implements LifecycleListener {
}
}
- static class JavaClassCacheEntry {
+ protected static class JavaClassCacheEntry {
public final String superclassName;
public final String[] interfaceNames;
diff --git a/java/org/apache/catalina/startup/ExpandWar.java b/java/org/apache/catalina/startup/ExpandWar.java
index a83bb49061..969f7b02c1 100644
--- a/java/org/apache/catalina/startup/ExpandWar.java
+++ b/java/org/apache/catalina/startup/ExpandWar.java
@@ -273,7 +273,7 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and sub-directories recursively. Any failure will
+ * Delete the specified directory, including all of its contents and subdirectories recursively. Any failure will
* be logged.
*
* @param dir File object representing the directory to be deleted
@@ -287,7 +287,7 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and sub-directories recursively.
+ * Delete the specified directory, including all of its contents and subdirectories recursively.
*
* @param dir File object representing the directory to be deleted
* @param logFailure <code>true</code> if failure to delete the resource should be logged
@@ -313,7 +313,7 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and sub-directories recursively. Any failure will
+ * Delete the specified directory, including all of its contents and subdirectories recursively. Any failure will
* be logged.
*
* @param dir File object representing the directory to be deleted
@@ -326,7 +326,7 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and sub-directories recursively.
+ * Delete the specified directory, including all of its contents and subdirectories recursively.
*
* @param dir File object representing the directory to be deleted
* @param logFailure <code>true</code> if failure to delete the resource should be logged
diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java
index d0a937d7b1..b0f932bb25 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -638,7 +638,8 @@ public class HostConfig implements LifecycleListener {
// default to appBase dir + name
expandedDocBase = new File(host.getAppBaseFile(), cn.getBaseName());
- if (context.getDocBase() != null && !context.getDocBase().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
+ if (context != null && context.getDocBase() != null &&
+ !context.getDocBase().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
// first assume docBase is absolute
expandedDocBase = new File(context.getDocBase());
if (!expandedDocBase.isAbsolute()) {
@@ -847,7 +848,7 @@ public class HostConfig implements LifecycleListener {
// should only be used if the directory is not out of date and
// unpackWARs is true. Note the code below may apply further limits
boolean useXml = xml.exists() && unpackWARs && (!warTracker.exists() || warTracker.lastModified() == war.lastModified());
- // If the xml file exists then expandedDir must exists so no need to
+ // If the xml file exists then expandedDir must exist so no need to
// test that here
Context context = null;
@@ -1389,8 +1390,8 @@ public class HostConfig implements LifecycleListener {
}
}
} else {
- // There is a chance the the resource was only missing
- // temporarily eg renamed during a text editor save
+ // There is a chance the resource was only missing
+ // temporarily e.g. renamed during a text editor save
if (resource.exists() || !resource.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
try {
Thread.sleep(500);
@@ -1604,7 +1605,7 @@ public class HostConfig implements LifecycleListener {
try {
ObjectName hostON = host.getObjectName();
oname = new ObjectName(hostON.getDomain() + ":type=Deployer,host=" + host.getName());
- Registry.getRegistry(null, null).registerComponent(this, oname, this.getClass().getName());
+ Registry.getRegistryNonNull(null, null).registerComponent(this, oname, this.getClass().getName());
} catch (Exception e) {
log.warn(sm.getString("hostConfig.jmx.register", oname), e);
}
@@ -1632,7 +1633,7 @@ public class HostConfig implements LifecycleListener {
if (oname != null) {
try {
- Registry.getRegistry(null, null).unregisterComponent(oname);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(oname);
} catch (Exception e) {
log.warn(sm.getString("hostConfig.jmx.unregister", oname), e);
}
@@ -1954,14 +1955,14 @@ public class HostConfig implements LifecycleListener {
/*
- * The purpose of this class is to provide a way for HostConfig to get a Context to delete an expanded WAR after the
- * Context stops. This is to resolve this issue described in Bug 57772. The alternative solutions require either
- * duplicating a lot of the Context.reload() code in HostConfig or adding a new reload(boolean) method to Context
- * that allows the caller to optionally delete any expanded WAR.
- *
- * The LifecycleListener approach offers greater flexibility and enables the behaviour to be changed / extended /
- * removed in future without changing the Context API.
- */
+ * The purpose of this class is to provide a way for HostConfig to get a Context to delete an expanded WAR after the
+ * Context stops. This is to resolve this issue described in Bug 57772. The alternative solutions require either
+ * duplicating a lot of the Context.reload() code in HostConfig or adding a new reload(boolean) method to Context
+ * that allows the caller to optionally delete any expanded WAR.
+ *
+ * The LifecycleListener approach offers greater flexibility and enables the behaviour to be changed / extended /
+ * removed in future without changing the Context API.
+ */
private static class ExpandedDirectoryRemovalListener implements LifecycleListener {
private final File toDelete;
diff --git a/java/org/apache/catalina/startup/PasswdUserDatabase.java b/java/org/apache/catalina/startup/PasswdUserDatabase.java
index 2b2e47c448..638865f2a0 100644
--- a/java/org/apache/catalina/startup/PasswdUserDatabase.java
+++ b/java/org/apache/catalina/startup/PasswdUserDatabase.java
@@ -45,7 +45,7 @@ public final class PasswdUserDatabase implements UserDatabase {
/**
- * The set of home directories for all defined users, keyed by user name.
+ * The set of home directories for all defined users, keyed by username.
*/
private final Map<String,String> homes = new HashMap<>();
diff --git a/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java b/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
index 719cfefa42..4dd435cc78 100644
--- a/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
+++ b/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
@@ -24,7 +24,7 @@ import java.util.concurrent.ForkJoinWorkerThread;
* Provides a {@link ForkJoinWorkerThreadFactory} that provides {@link ForkJoinWorkerThread}s that won't trigger memory
* leaks due to retained references to web application class loaders.
* <p>
- * Note: This class must be available on the boot strap class path for it to be visible to {@link ForkJoinPool}.
+ * Note: This class must be available on the bootstrap class path for it to be visible to {@link ForkJoinPool}.
*/
public class SafeForkJoinWorkerThreadFactory implements ForkJoinWorkerThreadFactory {
diff --git a/java/org/apache/catalina/startup/SetNextNamingRule.java b/java/org/apache/catalina/startup/SetNextNamingRule.java
index 776433287b..1d07c18ebe 100644
--- a/java/org/apache/catalina/startup/SetNextNamingRule.java
+++ b/java/org/apache/catalina/startup/SetNextNamingRule.java
@@ -105,13 +105,7 @@ public class SetNextNamingRule extends Rule {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("SetNextRule[");
- sb.append("methodName=");
- sb.append(methodName);
- sb.append(", paramType=");
- sb.append(paramType);
- sb.append(']');
- return sb.toString();
+ return "SetNextRule[" + "methodName=" + methodName + ", paramType=" + paramType + ']';
}
diff --git a/java/org/apache/catalina/startup/Tomcat.java b/java/org/apache/catalina/startup/Tomcat.java
index eaac0a02c2..5e2a43e2ae 100644
--- a/java/org/apache/catalina/startup/Tomcat.java
+++ b/java/org/apache/catalina/startup/Tomcat.java
@@ -193,7 +193,7 @@ public class Tomcat {
}
/**
- * The the hostname of the default host, default is 'localhost'.
+ * The hostname of the default host, default is 'localhost'.
*
* @param s The default host name
*/
@@ -463,7 +463,7 @@ public class Tomcat {
/**
* Add a user for the in-memory realm. All created apps use this by default, can be replaced using setRealm().
*
- * @param user The user name
+ * @param user The username
* @param pass The password
*/
public void addUser(String user, String pass) {
@@ -475,7 +475,7 @@ public class Tomcat {
*
* @see #addUser(String, String)
*
- * @param user The user name
+ * @param user The username
* @param role The role name
*/
public void addRole(String user, String role) {
@@ -671,7 +671,7 @@ public class Tomcat {
Class<?> clazz = Class.forName(getHost().getConfigClass());
listener = (LifecycleListener) clazz.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
- // Wrap in IAE since we can't easily change the method signature to
+ // Wrap in IAE since we can't easily change the method signature
// to throw the specific checked exceptions
throw new IllegalArgumentException(e);
}
@@ -877,7 +877,7 @@ public class Tomcat {
/**
- * By default, when calling addWebapp() to create a Context, the settings from from the default web.xml are added to
+ * By default, when calling addWebapp() to create a Context, the settings from the default web.xml are added to
* the context. Calling this method with a <code>false</code> value prior to calling addWebapp() allows to opt out
* of the default settings. In that event you will need to add the configurations yourself, either programmatically
* or by using web.xml deployment descriptors.
diff --git a/java/org/apache/catalina/startup/Tool.java b/java/org/apache/catalina/startup/Tool.java
index 753327ebc0..5be1580ce8 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -218,9 +218,9 @@ public final class Tool {
paramValues[0] = params;
method.invoke(null, paramValues);
} catch (Throwable t) {
- t = Bootstrap.unwrapInvocationTargetException(t);
- Bootstrap.handleThrowable(t);
- log.error("Exception calling main() method", t);
+ Throwable throwable = Bootstrap.unwrapInvocationTargetException(t);
+ Bootstrap.handleThrowable(throwable);
+ log.error("Exception calling main() method", throwable);
System.exit(1);
}
diff --git a/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java b/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java
index 9a5c235029..a925841bde 100644
--- a/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java
+++ b/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/storeconfig/ConnectorSF.java b/java/org/apache/catalina/storeconfig/ConnectorSF.java
index 794c349e11..eaaa7d1da5 100644
--- a/java/org/apache/catalina/storeconfig/ConnectorSF.java
+++ b/java/org/apache/catalina/storeconfig/ConnectorSF.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java b/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
index 5e38b0f13f..a738b8296a 100644
--- a/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
+++ b/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java b/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java
index b0362757fa..22f4fe6256 100644
--- a/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java
+++ b/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
index eb8ed921ed..da2d00f751 100644
--- a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
+++ b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
diff --git a/java/org/apache/catalina/storeconfig/StoreContextAppender.java b/java/org/apache/catalina/storeconfig/StoreContextAppender.java
index 316f8aa9d3..6084235efe 100644
--- a/java/org/apache/catalina/storeconfig/StoreContextAppender.java
+++ b/java/org/apache/catalina/storeconfig/StoreContextAppender.java
@@ -163,7 +163,6 @@ public class StoreContextAppender extends StoreAppender {
@Override
public Object defaultInstance(Object bean) throws ReflectiveOperationException {
if (bean instanceof StandardContext) {
- StandardContext defaultContext = new StandardContext();
// @formatter:off
/*
* if (!((StandardContext) bean).getOverride()) {
@@ -176,7 +175,7 @@ public class StoreContextAppender extends StoreAppender {
* }
*/
// @formatter:on
- return defaultContext;
+ return new StandardContext();
} else {
return super.defaultInstance(bean);
}
diff --git a/java/org/apache/catalina/tribes/ByteMessage.java b/java/org/apache/catalina/tribes/ByteMessage.java
index 5afa7da900..4793ef105f 100644
--- a/java/org/apache/catalina/tribes/ByteMessage.java
+++ b/java/org/apache/catalina/tribes/ByteMessage.java
@@ -24,7 +24,7 @@ import java.io.ObjectOutput;
/**
* A byte message is not serialized and deserialized by the channel instead it is sent as a byte array.
* <p>
- * By default Tribes uses java serialization when it receives an object to be sent over the wire. Java serialization is
+ * By default, Tribes uses java serialization when it receives an object to be sent over the wire. Java serialization is
* not the most efficient of serializing data, and Tribes might not even have access to the correct class loaders to
* deserialize the object properly.
* <p>
diff --git a/java/org/apache/catalina/tribes/Channel.java b/java/org/apache/catalina/tribes/Channel.java
index f92958a150..3afc3b527c 100644
--- a/java/org/apache/catalina/tribes/Channel.java
+++ b/java/org/apache/catalina/tribes/Channel.java
@@ -38,7 +38,7 @@ import org.apache.juli.logging.LogFactory;
* </ul>
* The channel has 5 major components:
* <ul>
- * <li>Data receiver, with a built in thread pool to receive messages from other peers</li>
+ * <li>Data receiver, with a built-in thread pool to receive messages from other peers</li>
* <li>Data sender, an implementation for sending data using NIO or java.io</li>
* <li>Membership listener,listens for membership broadcasts</li>
* <li>Membership broadcaster, broadcasts membership pings.</li>
@@ -144,7 +144,7 @@ public interface Channel {
* <p>
* However, there are five default flags that every channel implementation must implement.
* <p>
- * SEND_OPTIONS_BYTE_MESSAGE - The message is a pure byte message and no marshaling or unmarshaling will be
+ * SEND_OPTIONS_BYTE_MESSAGE - The message is a pure byte message and no marshaling or unmarshalling will be
* performed.
*
* @see #send(Member[], Serializable , int)
@@ -279,12 +279,12 @@ public interface Channel {
void start(int svc) throws ChannelException;
/**
- * Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter
- * can be the logical or value of any constants
+ * Shuts down the channel. This can be called multiple times for individual services to shut down.
+ * The svc parameter can be the logical or value of any constants
*
* @param svc one of:
* <ul>
- * <li>DEFAULT - will shutdown all services</li>
+ * <li>DEFAULT - will shut down all services</li>
* <li>MBR_RX_SEQ - stops the membership receiver</li>
* <li>MBR_TX_SEQ - stops the membership broadcaster</li>
* <li>SND_TX_SEQ - stops the replication transmitter</li>
@@ -335,7 +335,7 @@ public interface Channel {
* Sends a heart beat through the interceptor stacks. Use this method to alert interceptors and other components to
* clean up garbage, timed out messages etc.
* <p>
- * If you application has a background thread, then you can save one thread, by configuring your channel to not use
+ * If your application has a background thread, then you can save one thread, by configuring your channel to not use
* an internal heartbeat thread and invoking this method.
*
* @see #setHeartbeat(boolean)
@@ -412,7 +412,7 @@ public interface Channel {
Member[] getMembers();
/**
- * Return the member that represents this node. This is also the data that gets broadcasted through the membership
+ * Return the member that represents this node. This is also the data that gets broadcast through the membership
* broadcaster component
*
* @param incAlive - optimization, true if you want it to calculate alive time since the membership service started.
diff --git a/java/org/apache/catalina/tribes/ChannelException.java b/java/org/apache/catalina/tribes/ChannelException.java
index 0f2f69738b..b7740f447d 100644
--- a/java/org/apache/catalina/tribes/ChannelException.java
+++ b/java/org/apache/catalina/tribes/ChannelException.java
@@ -91,7 +91,7 @@ public class ChannelException extends Exception {
@Override
public String getMessage() {
StringBuilder buf = new StringBuilder(super.getMessage());
- if (faultyMembers == null || faultyMembers.size() == 0) {
+ if (faultyMembers == null || faultyMembers.isEmpty()) {
buf.append("; No faulty members identified.");
} else {
buf.append("; Faulty members:");
diff --git a/java/org/apache/catalina/tribes/ChannelInterceptor.java b/java/org/apache/catalina/tribes/ChannelInterceptor.java
index 30d513c732..42b79f5ebe 100644
--- a/java/org/apache/catalina/tribes/ChannelInterceptor.java
+++ b/java/org/apache/catalina/tribes/ChannelInterceptor.java
@@ -182,12 +182,12 @@ public interface ChannelInterceptor extends MembershipListener, Heartbeat {
void start(int svc) throws ChannelException;
/**
- * Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter
- * can be the logical or value of any constants
+ * Shuts down the channel. This can be called multiple times for individual services to shut down.
+ * The svc parameter can be the logical or value of any constants
*
* @param svc one of:
* <ul>
- * <li>Channel.DEFAULT - will shutdown all services</li>
+ * <li>Channel.DEFAULT - will shut down all services</li>
* <li>Channel.MBR_RX_SEQ - stops the membership receiver</li>
* <li>Channel.MBR_TX_SEQ - stops the membership broadcaster</li>
* <li>Channel.SND_TX_SEQ - stops the replication transmitter</li>
diff --git a/java/org/apache/catalina/tribes/Member.java b/java/org/apache/catalina/tribes/Member.java
index 3a62e7a7a7..ce444377f5 100644
--- a/java/org/apache/catalina/tribes/Member.java
+++ b/java/org/apache/catalina/tribes/Member.java
@@ -56,17 +56,17 @@ public interface Member extends Serializable {
/**
* Returns the listen port for the ChannelReceiver implementation
*
- * @return the listen port for this member, -1 if its not listening on an insecure port
+ * @return the listen port for this member, -1 if it's not listening on an insecure port
*
* @see ChannelReceiver
*/
int getPort();
/**
- * Returns the secure listen port for the ChannelReceiver implementation. Returns -1 if its not listening to a
+ * Returns the secure listen port for the ChannelReceiver implementation. Returns -1 if it's not listening to a
* secure port.
*
- * @return the listen port for this member, -1 if its not listening on a secure port
+ * @return the listen port for this member, -1 if it's not listening on a secure port
*
* @see ChannelReceiver
*/
@@ -75,13 +75,13 @@ public interface Member extends Serializable {
/**
* Returns the UDP port that this member is listening to for UDP messages.
*
- * @return the listen UDP port for this member, -1 if its not listening on a UDP port
+ * @return the listen UDP port for this member, -1 if it's not listening on a UDP port
*/
int getUdpPort();
/**
- * Contains information on how long this member has been online. The result is the number of milli seconds this
+ * Contains information on how long this member has been online. The result is the number of milliseconds this
* member has been broadcasting its membership to the group.
*
* @return nr of milliseconds since this member started.
diff --git a/java/org/apache/catalina/tribes/MembershipService.java b/java/org/apache/catalina/tribes/MembershipService.java
index 5d9e6040de..df27a56cd4 100644
--- a/java/org/apache/catalina/tribes/MembershipService.java
+++ b/java/org/apache/catalina/tribes/MembershipService.java
@@ -51,7 +51,7 @@ public interface MembershipService {
* Starts the membership service. If a membership listeners is added the listener will start to receive membership
* events.
*
- * @param level - level MBR_RX starts listening for members, level MBR_TX starts broad casting the server
+ * @param level - level MBR_RX starts listening for members, level MBR_TX starts broadcasting the server
*
* @throws Exception if the service fails to start.
* @throws java.lang.IllegalArgumentException if the level is incorrect.
@@ -63,14 +63,14 @@ public interface MembershipService {
* Stops the membership service. If a membership listeners is added the listener will start to receive membership
* events.
*
- * @param level - level MBR_RX stops listening for members, level MBR_TX stops broad casting the server
+ * @param level - level MBR_RX stops listening for members, level MBR_TX stops broadcasting the server
*
* @throws java.lang.IllegalArgumentException if the level is incorrect.
*/
void stop(int level);
/**
- * @return true if the the group contains members
+ * @return true if the group contains members
*/
boolean hasMembers();
@@ -84,7 +84,7 @@ public interface MembershipService {
Member getMember(Member mbr);
/**
- * @return a list of all the members in the cluster.
+ * @return an array of all the members in the cluster.
*/
Member[] getMembers();
diff --git a/java/org/apache/catalina/tribes/UniqueId.java b/java/org/apache/catalina/tribes/UniqueId.java
index 0a2524da86..24c7815ff5 100644
--- a/java/org/apache/catalina/tribes/UniqueId.java
+++ b/java/org/apache/catalina/tribes/UniqueId.java
@@ -55,15 +55,15 @@ public final class UniqueId implements Serializable {
if (result) {
UniqueId uid = (UniqueId) other;
if (this.id == null && uid.id == null) {
- result = true;
- } else if (this.id == null && uid.id != null) {
+ // Nothing to do
+ } else if (this.id == null) {
result = false;
- } else if (this.id != null && uid.id == null) {
+ } else if (uid.id == null) {
result = false;
} else {
result = Arrays.equals(this.id, uid.id);
}
- } // end if
+ }
return result;
}
diff --git a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
index df889928e7..e9c6c350eb 100644
--- a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
+++ b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
@@ -113,15 +113,7 @@ public class AbsoluteOrder {
}
protected int compareInts(int b1, int b2) {
- int result = 0;
- if (b1 == b2) {
-
- } else if (b1 < b2) {
- result = -1;
- } else {
- result = 1;
- }
- return result;
+ return Integer.compare(b1, b2);
}
}
diff --git a/java/org/apache/catalina/tribes/group/GroupChannel.java b/java/org/apache/catalina/tribes/group/GroupChannel.java
index 31f1c074c1..adca38e946 100644
--- a/java/org/apache/catalina/tribes/group/GroupChannel.java
+++ b/java/org/apache/catalina/tribes/group/GroupChannel.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
@@ -61,7 +62,7 @@ import org.apache.juli.logging.LogFactory;
/**
* The default implementation of a Channel.<br>
* The GroupChannel manages the replication channel. It coordinates message being sent and received with membership
- * announcements. The channel has an chain of interceptors that can modify the message or perform other logic.<br>
+ * announcements. The channel has a chain of interceptors that can modify the message or perform other logic.<br>
* It manages a complete group, both membership and replication.
*/
public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel, JmxChannel, GroupChannelMBean {
@@ -216,7 +217,7 @@ public class GroupChannel extends ChannelInterceptorBase implements ManagedChann
ChannelData data = new ChannelData(true);// generates a unique Id
data.setAddress(getLocalMember(false));
data.setTimestamp(System.currentTimeMillis());
- byte[] b = null;
+ byte[] b;
if (msg instanceof ByteMessage) {
b = ((ByteMessage) msg).getMessage();
options = options | SEND_OPTIONS_BYTE_MESSAGE;
@@ -255,7 +256,7 @@ public class GroupChannel extends ChannelInterceptorBase implements ManagedChann
/**
* Callback from the interceptor stack. <br>
* When a message is received from a remote node, this method will be invoked by the previous interceptor.<br>
- * This method can also be used to send a message to other components within the same application, but its an
+ * This method can also be used to send a message to other components within the same application, but it's an
* extreme case, and you're probably better off doing that logic between the applications itself.
*
* @param msg ChannelMessage
@@ -271,7 +272,7 @@ public class GroupChannel extends ChannelInterceptorBase implements ManagedChann
new java.sql.Timestamp(System.currentTimeMillis()) + " from " + msg.getAddress().getName());
}
- Serializable fwd = null;
+ Serializable fwd;
if ((msg.getOptions() & SEND_OPTIONS_BYTE_MESSAGE) == SEND_OPTIONS_BYTE_MESSAGE) {
fwd = new ByteMessage(msg.getMessage().getBytes());
} else {
@@ -450,7 +451,7 @@ public class GroupChannel extends ChannelInterceptorBase implements ManagedChann
}
protected void startHeartbeat() {
- if (heartbeat && (heartbeatFuture == null || (heartbeatFuture != null && heartbeatFuture.isDone()))) {
+ if (heartbeat && (heartbeatFuture == null || heartbeatFuture.isDone())) {
if (heartbeatFuture != null && heartbeatFuture.isDone()) {
// There was an error executing the scheduled task, get it and log it
try {
@@ -492,11 +493,7 @@ public class GroupChannel extends ChannelInterceptorBase implements ManagedChann
* @return ChannelInterceptor
*/
public ChannelInterceptor getFirstInterceptor() {
- if (interceptors != null) {
- return interceptors;
- } else {
- return coordinator;
- }
+ return Objects.requireNonNullElse(interceptors, coordinator);
}
@Override
diff --git a/java/org/apache/catalina/tribes/group/RpcChannel.java b/java/org/apache/catalina/tribes/group/RpcChannel.java
index 6f0b0c087b..48ba62710b 100644
--- a/java/org/apache/catalina/tribes/group/RpcChannel.java
+++ b/java/org/apache/catalina/tribes/group/RpcChannel.java
@@ -87,7 +87,7 @@ public class RpcChannel implements ChannelListener {
return new Response[0];
}
- // avoid dead lock
+ // avoid deadlock
int sendOptions = channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;
RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false));
diff --git a/java/org/apache/catalina/tribes/group/RpcMessage.java b/java/org/apache/catalina/tribes/group/RpcMessage.java
index 052befc9e5..70ef9a84b2 100644
--- a/java/org/apache/catalina/tribes/group/RpcMessage.java
+++ b/java/org/apache/catalina/tribes/group/RpcMessage.java
@@ -65,15 +65,8 @@ public class RpcMessage implements Externalizable {
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("RpcMessage[");
- buf.append(super.toString());
- buf.append("] rpcId=");
- buf.append(Arrays.toString(rpcId));
- buf.append("; uuid=");
- buf.append(Arrays.toString(uuid));
- buf.append("; msg=");
- buf.append(message);
- return buf.toString();
+ return "RpcMessage[" + super.toString() + "] rpcId=" + Arrays.toString(rpcId) + "; uuid=" +
+ Arrays.toString(uuid) + "; msg=" + message;
}
public static class NoRpcChannelReply extends RpcMessage {
diff --git a/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java
index 4d4fbf0918..55e55efac3 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java
@@ -60,7 +60,7 @@ public class DomainFilterInterceptor extends ChannelInterceptorBase implements D
if (membership == null) {
setupMembership();
}
- boolean notify = false;
+ boolean notify;
synchronized (membership) {
notify = Arrays.equals(domain, member.getDomain());
if (notify) {
@@ -81,7 +81,7 @@ public class DomainFilterInterceptor extends ChannelInterceptorBase implements D
if (membership == null) {
setupMembership();
}
- boolean notify = false;
+ boolean notify;
synchronized (membership) {
notify = Arrays.equals(domain, member.getDomain());
if (notify) {
diff --git a/java/org/apache/catalina/tribes/group/interceptors/EncryptInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/EncryptInterceptor.java
index 8c3a5cf3bf..eb46e5259f 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/EncryptInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/EncryptInterceptor.java
@@ -263,7 +263,7 @@ public class EncryptInterceptor extends ChannelInterceptorBase implements Encryp
// Copied from org.apache.tomcat.util.buf.HexUtils
// @formatter:off
private static final int[] DEC = {
- 00, 01, 02, 03, 04, 05, 06, 07, 8, 9, -1, -1, -1, -1, -1, -1,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15,
@@ -390,7 +390,7 @@ public class EncryptInterceptor extends ChannelInterceptorBase implements Encryp
}
public void shutdown() {
- // Individual Cipher and SecureRandom objects need no explicit teardown
+ // Individual Cipher and SecureRandom objects need no explicit tear down
cipherPool.clear();
randomPool.clear();
}
diff --git a/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
index 642bc0a955..b7758bc53c 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
@@ -248,7 +248,7 @@ public class MessageDispatchInterceptor extends ChannelInterceptorBase implement
log.error(sm.getString("messageDispatchInterceptor.completeMessage.failed"), ex);
}
} catch (Exception x) {
- ChannelException cx = null;
+ ChannelException cx;
if (x instanceof ChannelException) {
cx = (ChannelException) x;
} else {
diff --git a/java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java b/java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
index be6f6f3c9a..1ba47d16d8 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
@@ -100,8 +100,8 @@ import org.apache.juli.logging.LogFactory;
* the view.
* </p>
* <p>
- * Lets assume that C1 arrives, C1 has lower priority than C, but higher priority than D.<br>
- * Lets also assume that C1 sees the following view {B,D,E}<br>
+ * Let's assume that C1 arrives, C1 has lower priority than C, but higher priority than D.<br>
+ * Let's also assume that C1 sees the following view {B,D,E}<br>
* C1 waits for a token to arrive. When the token arrives, the same scenario as above will happen.<br>
* In the scenario where C1 sees {D,E} and A,B,C cannot see C1, no token will ever arrive.<br>
* In this case, C1 sends a Z{C1-ldr, C1-src, mbrs-C1,D,E} to D<br>
@@ -266,9 +266,8 @@ public class NonBlockingCoordinator extends ChannelInterceptorBase {
Arrays.fill(m, others);
Member[] mbrs = m.getMembers();
m.reset();
- CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,
+ return new CoordinationMessage(leader, local, mbrs,
new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST);
- return msg;
}
protected void sendElectionMsg(Member local, Member next, CoordinationMessage msg) throws ChannelException {
@@ -468,7 +467,7 @@ public class NonBlockingCoordinator extends ChannelInterceptorBase {
}
/**
- * Block in/out messages while a election is going on
+ * Block in/out messages while an election is going on
*/
protected void halt() {
@@ -544,7 +543,7 @@ public class NonBlockingCoordinator extends ChannelInterceptorBase {
@Override
public void messageReceived(ChannelMessage msg) {
if (Arrays.contains(msg.getMessage().getBytesDirect(), 0, COORD_ALIVE, 0, COORD_ALIVE.length)) {
- // ignore message, its an alive message
+ // ignore message, it's an alive message
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE, this, "Alive Message"));
} else if (Arrays.contains(msg.getMessage().getBytesDirect(), 0, COORD_HEADER, 0, COORD_HEADER.length)) {
@@ -786,12 +785,10 @@ public class NonBlockingCoordinator extends ChannelInterceptorBase {
byte[] ldr = leader.getData(false, false);
buf.append(ldr.length);
buf.append(ldr, 0, ldr.length);
- ldr = null;
// source
byte[] src = source.getData(false, false);
buf.append(src.length);
buf.append(src, 0, src.length);
- src = null;
// view
buf.append(view.length);
for (Member member : view) {
diff --git a/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
index b1e0668372..02f5a89040 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
@@ -70,7 +70,7 @@ public class OrderInterceptor extends ChannelInterceptorBase {
ChannelException cx = null;
for (Member member : destination) {
try {
- int nr = 0;
+ int nr;
outLock.writeLock().lock();
try {
nr = incCounter(member);
@@ -157,7 +157,7 @@ public class OrderInterceptor extends ChannelInterceptorBase {
MessageOrder prev = null;
tmp = order;
// flag to empty out the queue when it larger than maxQueue
- boolean empty = order != null ? order.getCount() >= maxQueue : false;
+ boolean empty = order != null && order.getCount() >= maxQueue;
while (tmp != null) {
// process expired messages or empty out the queue
if (tmp.isExpired(expire) || empty) {
@@ -249,7 +249,7 @@ public class OrderInterceptor extends ChannelInterceptorBase {
private final long received = System.currentTimeMillis();
private MessageOrder next;
private final int msgNr;
- private ChannelMessage msg = null;
+ private ChannelMessage msg;
public MessageOrder(int msgNr, ChannelMessage msg) {
this.msgNr = msgNr;
@@ -317,7 +317,6 @@ public class OrderInterceptor extends ChannelInterceptorBase {
// add before
prev.next = add; // prev cannot be null here, warning suppressed
add.next = iter;
-
} else {
throw new ArithmeticException(sm.getString("orderInterceptor.messageAdded.sameCounter"));
}
diff --git a/java/org/apache/catalina/tribes/group/interceptors/SimpleCoordinator.java b/java/org/apache/catalina/tribes/group/interceptors/SimpleCoordinator.java
index a3082c8dcb..8e87200ccf 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/SimpleCoordinator.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/SimpleCoordinator.java
@@ -110,7 +110,7 @@ public class SimpleCoordinator extends ChannelInterceptorBase {
}
public boolean isCoordinator() {
- return view == null ? false : getLocalMember(false).equals(getCoordinator());
+ return view != null && getLocalMember(false).equals(getCoordinator());
}
}
diff --git a/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java
index 604efca1b8..942ef08eb2 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java
@@ -61,9 +61,7 @@ public class StaticMembershipInterceptor extends ChannelInterceptorBase implemen
public void removeStaticMember(Member member) {
synchronized (members) {
- if (members.contains(member)) {
- members.remove(member);
- }
+ members.remove(member);
}
}
@@ -100,20 +98,18 @@ public class StaticMembershipInterceptor extends ChannelInterceptorBase implemen
@Override
public boolean hasMembers() {
- return super.hasMembers() || (members.size() > 0);
+ return super.hasMembers() || (!members.isEmpty());
}
@Override
public Member[] getMembers() {
- if (members.size() == 0) {
+ if (members.isEmpty()) {
return super.getMembers();
} else {
synchronized (members) {
Member[] others = super.getMembers();
Member[] result = new Member[members.size() + others.length];
- for (int i = 0; i < others.length; i++) {
- result[i] = others[i];
- }
+ System.arraycopy(others, 0, result, 0, others.length);
for (int i = 0; i < members.size(); i++) {
result[i + others.length] = members.get(i);
}
@@ -218,7 +214,7 @@ public class StaticMembershipInterceptor extends ChannelInterceptorBase implemen
}
protected ChannelInterceptor getfirstInterceptor() {
- ChannelInterceptor result = null;
+ ChannelInterceptor result;
ChannelInterceptor now = this;
do {
result = now;
diff --git a/java/org/apache/catalina/tribes/group/interceptors/TwoPhaseCommitInterceptor.java b/java/org/apache/catalina/tribes/group/interceptors/TwoPhaseCommitInterceptor.java
index a55e0cd7ef..689fa24e9b 100644
--- a/java/org/apache/catalina/tribes/group/interceptors/TwoPhaseCommitInterceptor.java
+++ b/java/org/apache/catalina/tribes/group/interceptors/TwoPhaseCommitInterceptor.java
@@ -52,7 +52,7 @@ public class TwoPhaseCommitInterceptor extends ChannelInterceptorBase {
// and just send one message
if (okToProcess(msg.getOptions())) {
super.sendMessage(destination, msg, null);
- ChannelMessage confirmation = null;
+ ChannelMessage confirmation;
if (deepclone) {
confirmation = (ChannelMessage) msg.deepclone();
} else {
@@ -150,7 +150,6 @@ public class TwoPhaseCommitInterceptor extends ChannelInterceptorBase {
public boolean expired(long now, long expiration) {
return (now - timestamp) > expiration;
}
-
}
}
\ No newline at end of file
diff --git a/java/org/apache/catalina/tribes/io/ChannelData.java b/java/org/apache/catalina/tribes/io/ChannelData.java
index 9f94520dd6..5c27170cda 100644
--- a/java/org/apache/catalina/tribes/io/ChannelData.java
+++ b/java/org/apache/catalina/tribes/io/ChannelData.java
@@ -153,7 +153,7 @@ public class ChannelData implements ChannelMessage {
}
public int getDataPackageLength() {
- int length = 4 + // options
+ return 4 + // options
8 + // timestamp off=4
4 + // unique id length off=12
uniqueId.length + // id data off=12+uniqueId.length
@@ -161,8 +161,6 @@ public class ChannelData implements ChannelMessage {
address.getDataLength() + // member data off=12+uniqueId.length+4+add.length
4 + // message length off=12+uniqueId.length+4+add.length+4
message.getLength();
- return length;
-
}
/**
@@ -339,12 +337,10 @@ public class ChannelData implements ChannelMessage {
@Override
public String toString() {
- StringBuilder buf = new StringBuilder();
- buf.append("ClusterData[src=");
- buf.append(getAddress()).append("; id=");
- buf.append(bToS(getUniqueId())).append("; sent=");
- buf.append(new Timestamp(this.getTimestamp()).toString()).append(']');
- return buf.toString();
+ return "ClusterData[src=" +
+ getAddress() + "; id=" +
+ bToS(getUniqueId()) + "; sent=" +
+ new Timestamp(this.getTimestamp()).toString() + ']';
}
public static String bToS(byte[] data) {
diff --git a/java/org/apache/catalina/tribes/io/ObjectReader.java b/java/org/apache/catalina/tribes/io/ObjectReader.java
index 33d612f3ad..7f8c340e44 100644
--- a/java/org/apache/catalina/tribes/io/ObjectReader.java
+++ b/java/org/apache/catalina/tribes/io/ObjectReader.java
@@ -124,7 +124,7 @@ public class ObjectReader {
* @see XByteBuffer#doesPackageExist()
* @see XByteBuffer#extractPackage(boolean)
*
- * @return number of received packages/messages
+ * @return array of received packages/messages
*/
public ChannelMessage[] execute() {
int pkgCnt = buffer.countPackages();
diff --git a/java/org/apache/catalina/tribes/io/ReplicationStream.java b/java/org/apache/catalina/tribes/io/ReplicationStream.java
index be163196b2..b0fd419e21 100644
--- a/java/org/apache/catalina/tribes/io/ReplicationStream.java
+++ b/java/org/apache/catalina/tribes/io/ReplicationStream.java
@@ -39,7 +39,7 @@ public final class ReplicationStream extends ObjectInputStream {
/**
* The class loader we will use to resolve classes.
*/
- private ClassLoader[] classLoaders = null;
+ private ClassLoader[] classLoaders;
/**
* Construct a new instance of CustomObjectInputStream
@@ -140,16 +140,14 @@ public final class ReplicationStream extends ObjectInputStream {
public Class<?> findReplicationClass(String name) throws ClassNotFoundException {
- Class<?> clazz = Class.forName(name, false, getClass().getClassLoader());
- return clazz;
+ return Class.forName(name, false, getClass().getClassLoader());
}
public Class<?> findExternalClass(String name) throws ClassNotFoundException {
ClassNotFoundException cnfe = null;
for (ClassLoader classLoader : classLoaders) {
try {
- Class<?> clazz = Class.forName(name, false, classLoader);
- return clazz;
+ return Class.forName(name, false, classLoader);
} catch (ClassNotFoundException x) {
cnfe = x;
}
diff --git a/java/org/apache/catalina/tribes/io/XByteBuffer.java b/java/org/apache/catalina/tribes/io/XByteBuffer.java
index b3bf657310..46cdac01d9 100644
--- a/java/org/apache/catalina/tribes/io/XByteBuffer.java
+++ b/java/org/apache/catalina/tribes/io/XByteBuffer.java
@@ -64,7 +64,7 @@ public class XByteBuffer implements Serializable {
/**
* Variable to hold the data
*/
- protected byte[] buf = null;
+ protected byte[] buf;
/**
* Current length of data in the buffer
@@ -75,7 +75,7 @@ public class XByteBuffer implements Serializable {
* Flag for discarding invalid packages If this flag is set to true, and append(byte[],...) is called, the data
* added will be inspected, and if it doesn't start with <code>START_DATA</code> it will be thrown away.
*/
- protected boolean discard = true;
+ protected boolean discard;
/**
* Constructs a new XByteBuffer.<br>
@@ -241,7 +241,7 @@ public class XByteBuffer implements Serializable {
public void expand(int newcount) {
// don't change the allocation strategy
- byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)];
+ byte[] newbuf = new byte[Math.max(buf.length << 1, newcount)];
System.arraycopy(buf, 0, newbuf, 0, bufSize);
buf = newbuf;
}
@@ -337,8 +337,7 @@ public class XByteBuffer implements Serializable {
public ChannelData extractPackage(boolean clearFromBuffer) {
XByteBuffer xbuf = extractDataPackage(clearFromBuffer);
- ChannelData cdata = ChannelData.getDataFromPackage(xbuf);
- return cdata;
+ return ChannelData.getDataFromPackage(xbuf);
}
/**
@@ -379,12 +378,10 @@ public class XByteBuffer implements Serializable {
public static int getDataPackageLength(int datalength) {
- int length = START_DATA.length + // header length
+ return START_DATA.length + // header length
4 + // data length indicator
datalength + // actual data length
END_DATA.length; // footer length
- return length;
-
}
public static byte[] createDataPackage(byte[] data) {
@@ -404,7 +401,7 @@ public class XByteBuffer implements Serializable {
*/
public static int toInt(byte[] b, int off) {
return ((b[off + 3]) & 0xFF) + (((b[off + 2]) & 0xFF) << 8) + (((b[off + 1]) & 0xFF) << 16) +
- (((b[off + 0]) & 0xFF) << 24);
+ (((b[off]) & 0xFF) << 24);
}
/**
@@ -419,7 +416,7 @@ public class XByteBuffer implements Serializable {
return (((long) b[off + 7]) & 0xFF) + ((((long) b[off + 6]) & 0xFF) << 8) +
((((long) b[off + 5]) & 0xFF) << 16) + ((((long) b[off + 4]) & 0xFF) << 24) +
((((long) b[off + 3]) & 0xFF) << 32) + ((((long) b[off + 2]) & 0xFF) << 40) +
- ((((long) b[off + 1]) & 0xFF) << 48) + ((((long) b[off + 0]) & 0xFF) << 56);
+ ((((long) b[off + 1]) & 0xFF) << 48) + ((((long) b[off]) & 0xFF) << 56);
}
@@ -466,7 +463,7 @@ public class XByteBuffer implements Serializable {
n >>>= 8;
b[offset + 1] = (byte) (n);
n >>>= 8;
- b[offset + 0] = (byte) (n);
+ b[offset] = (byte) (n);
return b;
}
@@ -494,7 +491,7 @@ public class XByteBuffer implements Serializable {
n >>>= 8;
b[offset + 1] = (byte) (n);
n >>>= 8;
- b[offset + 0] = (byte) (n);
+ b[offset] = (byte) (n);
return b;
}
@@ -512,7 +509,7 @@ public class XByteBuffer implements Serializable {
if (find.length > src.length) {
return result;
}
- if (find.length == 0 || src.length == 0) {
+ if (find.length == 0) {
return result;
}
if (srcOff >= src.length) {
@@ -577,7 +574,7 @@ public class XByteBuffer implements Serializable {
}
if (data != null && length > 0) {
InputStream instream = new ByteArrayInputStream(data, offset, length);
- ObjectInputStream stream = null;
+ ObjectInputStream stream;
stream = (cls.length > 0) ? new ReplicationStream(instream, cls) : new ObjectInputStream(instream);
message = stream.readObject();
instream.close();
@@ -606,8 +603,7 @@ public class XByteBuffer implements Serializable {
ObjectOutputStream out = new ObjectOutputStream(outs);
out.writeObject(msg);
out.flush();
- byte[] data = outs.toByteArray();
- return data;
+ return outs.toByteArray();
}
public void setDiscard(boolean discard) {
diff --git a/java/org/apache/catalina/tribes/jmx/JmxRegistry.java b/java/org/apache/catalina/tribes/jmx/JmxRegistry.java
index a833597fbe..b1d5059666 100644
--- a/java/org/apache/catalina/tribes/jmx/JmxRegistry.java
+++ b/java/org/apache/catalina/tribes/jmx/JmxRegistry.java
@@ -36,9 +36,9 @@ public class JmxRegistry {
private static final Log log = LogFactory.getLog(JmxRegistry.class);
protected static final StringManager sm = StringManager.getManager(JmxRegistry.class);
- private static ConcurrentHashMap<String,JmxRegistry> registryCache = new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<String,JmxRegistry> registryCache = new ConcurrentHashMap<>();
- private MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer();
+ private final MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer();
private ObjectName baseOname = null;
private JmxRegistry() {
@@ -110,7 +110,7 @@ public class JmxRegistry {
return null;
}
String oNameStr = baseOname.toString() + keyprop;
- ObjectName oName = null;
+ ObjectName oName;
try {
oName = new ObjectName(oNameStr);
if (mbserver.isRegistered(oName)) {
diff --git a/java/org/apache/catalina/tribes/membership/McastService.java b/java/org/apache/catalina/tribes/membership/McastService.java
index 4768455281..873d2db4d5 100644
--- a/java/org/apache/catalina/tribes/membership/McastService.java
+++ b/java/org/apache/catalina/tribes/membership/McastService.java
@@ -526,7 +526,7 @@ public class McastService extends MembershipServiceBase implements MessageListen
*
* @throws Exception If an error occurs
*/
- public static void main(String args[]) throws Exception {
+ public static void main(String[] args) throws Exception {
McastService service = new McastService();
Properties p = new Properties();
p.setProperty("mcastPort", "5555");
diff --git a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
index 108abb7cc7..7d766e8ac2 100644
--- a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
+++ b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
@@ -64,7 +64,7 @@ public class McastServiceImpl extends MembershipProviderBase {
*/
protected MulticastSocket socket;
/**
- * The local member that we intend to broad cast over and over again
+ * The local member that we intend to broadcast over and over again
*/
protected final MemberImpl member;
/**
@@ -116,7 +116,7 @@ public class McastServiceImpl extends MembershipProviderBase {
/**
* Read timeout on the mcast socket
*/
- protected int mcastSoTimeout = -1;
+ protected int mcastSoTimeout;
/**
* bind address
*/
@@ -347,9 +347,7 @@ public class McastServiceImpl extends MembershipProviderBase {
* @throws IOException Received failed
*/
public void receive() throws IOException {
- boolean checkexpired = true;
try {
-
socket.receive(receivePacket);
if (receivePacket.getLength() > MAX_PACKET_SIZE) {
log.error(sm.getString("mcastServiceImpl.packet.tooLong", Integer.toString(receivePacket.getLength())));
@@ -361,16 +359,13 @@ public class McastServiceImpl extends MembershipProviderBase {
} else {
memberBroadcastsReceived(data);
}
-
}
} catch (SocketTimeoutException x) {
// do nothing, this is normal, we don't want to block forever
// since the receive thread is the same thread
// that does membership expiration
}
- if (checkexpired) {
- checkExpired();
- }
+ checkExpired();
}
private void memberDataReceived(byte[] data) {
@@ -523,7 +518,7 @@ public class McastServiceImpl extends MembershipProviderBase {
}
public long getServiceStartTime() {
- return (member != null) ? member.getServiceStartTime() : -1l;
+ return (member != null) ? member.getServiceStartTime() : -1L;
}
public int getRecoveryCounter() {
diff --git a/java/org/apache/catalina/tribes/membership/MemberImpl.java b/java/org/apache/catalina/tribes/membership/MemberImpl.java
index 712231904e..ea397d1fac 100644
--- a/java/org/apache/catalina/tribes/membership/MemberImpl.java
+++ b/java/org/apache/catalina/tribes/membership/MemberImpl.java
@@ -33,8 +33,8 @@ import org.apache.catalina.tribes.util.StringManager;
*/
public class MemberImpl implements Member, java.io.Externalizable {
- public static final transient byte[] TRIBES_MBR_BEGIN = new byte[] { 84, 82, 73, 66, 69, 83, 45, 66, 1, 0 };
- public static final transient byte[] TRIBES_MBR_END = new byte[] { 84, 82, 73, 66, 69, 83, 45, 69, 1, 0 };
+ public static final byte[] TRIBES_MBR_BEGIN = new byte[] { 84, 82, 73, 66, 69, 83, 45, 66, 1, 0 };
+ public static final byte[] TRIBES_MBR_END = new byte[] { 84, 82, 73, 66, 69, 83, 45, 69, 1, 0 };
protected static final StringManager sm = StringManager.getManager(Constants.Package);
/**
@@ -517,7 +517,7 @@ public class MemberImpl implements Member, java.io.Externalizable {
for (int i = 0; data != null && i < data.length; i++) {
buf.append(String.valueOf(data[i])).append(' ');
if (i == max) {
- buf.append("...(" + data.length + ")");
+ buf.append("...(").append(data.length).append(")");
break;
}
}
diff --git a/java/org/apache/catalina/tribes/membership/Membership.java b/java/org/apache/catalina/tribes/membership/Membership.java
index 0e735ebe78..c0bf71f6ee 100644
--- a/java/org/apache/catalina/tribes/membership/Membership.java
+++ b/java/org/apache/catalina/tribes/membership/Membership.java
@@ -175,7 +175,7 @@ public class Membership implements Cloneable {
synchronized (membersLock) {
if (!map.containsKey(member)) {
map.put(member, entry);
- Member results[] = new Member[members.length + 1];
+ Member[] results = new Member[members.length + 1];
System.arraycopy(members, 0, results, 0, members.length);
results[members.length] = member;
Arrays.sort(results, memberComparator);
@@ -203,7 +203,7 @@ public class Membership implements Cloneable {
if (n < 0) {
return;
}
- Member results[] = new Member[members.length - 1];
+ Member[] results = new Member[members.length - 1];
int j = 0;
for (int i = 0; i < members.length; i++) {
if (i != n) {
@@ -220,7 +220,7 @@ public class Membership implements Cloneable {
*
* @param maxtime - the max time a member can remain unannounced before it is considered dead.
*
- * @return the list of expired members
+ * @return the array of expired members
*/
public Member[] expire(long maxtime) {
synchronized (membersLock) {
@@ -263,11 +263,9 @@ public class Membership implements Cloneable {
public Member getMember(Member mbr) {
Member[] members = this.members;
- if (members.length > 0) {
- for (Member member : members) {
- if (member.equals(mbr)) {
- return member;
- }
+ for (Member member : members) {
+ if (member.equals(mbr)) {
+ return member;
}
}
return null;
@@ -292,7 +290,7 @@ public class Membership implements Cloneable {
/**
* Inner class that represents a member entry
*/
- protected static class MbrEntry {
+ public static class MbrEntry {
protected final Member mbr;
protected long lastHeardFrom;
diff --git a/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java b/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
index 32ab1fe392..4d51468d59 100644
--- a/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
+++ b/java/org/apache/catalina/tribes/membership/StaticMembershipProvider.java
@@ -374,15 +374,8 @@ public class StaticMembershipProvider extends MembershipProviderBase
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("MemberMessage[");
- buf.append("name=");
- buf.append(new String(membershipId));
- buf.append("; type=");
- buf.append(getTypeDesc());
- buf.append("; member=");
- buf.append(member);
- buf.append(']');
- return buf.toString();
+ return "MemberMessage[" + "name=" + new String(membershipId) + "; type=" +
+ getTypeDesc() + "; member=" + member + ']';
}
protected String getTypeDesc() {
@@ -407,6 +400,7 @@ public class StaticMembershipProvider extends MembershipProviderBase
sleep(pingInterval);
ping();
} catch (InterruptedException ix) {
+ // Ignore
} catch (Exception x) {
log.warn(sm.getString("staticMembershipProvider.pingThread.failed"), x);
}
diff --git a/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipProvider.java b/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipProvider.java
index 45fb27dd6f..a009b02117 100644
--- a/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipProvider.java
+++ b/java/org/apache/catalina/tribes/membership/cloud/CloudMembershipProvider.java
@@ -92,7 +92,7 @@ public abstract class CloudMembershipProvider extends MembershipProviderBase imp
*/
protected String getNamespace() {
String namespace = getEnv(CUSTOM_ENV_PREFIX + "NAMESPACE", "KUBERNETES_NAMESPACE");
- if (namespace == null || namespace.length() == 0) {
+ if (namespace == null || namespace.isEmpty()) {
log.warn(sm.getString("kubernetesMembershipProvider.noNamespace"));
namespace = "tomcat";
}
diff --git a/java/org/apache/catalina/tribes/membership/cloud/DNSMembershipProvider.java b/java/org/apache/catalina/tribes/membership/cloud/DNSMembershipProvider.java
index eb715aa4fb..ae9d663796 100644
--- a/java/org/apache/catalina/tribes/membership/cloud/DNSMembershipProvider.java
+++ b/java/org/apache/catalina/tribes/membership/cloud/DNSMembershipProvider.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -124,7 +125,7 @@ public class DNSMembershipProvider extends CloudMembershipProvider {
if (log.isDebugEnabled()) {
log.debug(sm.getString("cloudMembershipProvider.start", dnsServiceName));
}
- dnsServiceName = URLEncoder.encode(dnsServiceName, "UTF-8");
+ dnsServiceName = URLEncoder.encode(dnsServiceName, StandardCharsets.UTF_8);
// Fetch initial members
heartbeat();
@@ -161,7 +162,7 @@ public class DNSMembershipProvider extends CloudMembershipProvider {
continue;
}
long aliveTime = -1;
- MemberImpl member = null;
+ MemberImpl member;
try {
member = new MemberImpl(ip, port, aliveTime);
} catch (IOException e) {
diff --git a/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java b/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
index 59ff620b23..d4bc9e9470 100644
--- a/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
+++ b/java/org/apache/catalina/tribes/membership/cloud/KubernetesMembershipProvider.java
@@ -119,11 +119,11 @@ public class KubernetesMembershipProvider extends CloudMembershipProvider {
String labels = getEnv(CUSTOM_ENV_PREFIX + "LABELS", "KUBERNETES_LABELS");
- namespace = URLEncoder.encode(namespace, "UTF-8");
- labels = labels == null ? null : URLEncoder.encode(labels, "UTF-8");
+ namespace = URLEncoder.encode(namespace, StandardCharsets.UTF_8);
+ labels = labels == null ? null : URLEncoder.encode(labels, StandardCharsets.UTF_8);
url = String.format("%s://%s:%s/api/%s/namespaces/%s/pods", protocol, masterHost, masterPort, ver, namespace);
- if (labels != null && labels.length() > 0) {
+ if (labels != null && !labels.isEmpty()) {
url = url + "?labelSelector=" + labels;
}
@@ -153,7 +153,7 @@ public class KubernetesMembershipProvider extends CloudMembershipProvider {
List<MemberImpl> members = new ArrayList<>();
try (InputStream stream = streamProvider.openStream(url, headers, connectionTimeout, readTimeout);
- InputStreamReader reader = new InputStreamReader(stream, "UTF-8")) {
+ InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
parsePods(reader, members);
} catch (IOException e) {
log.error(sm.getString("kubernetesMembershipProvider.streamError"), e);
@@ -260,7 +260,7 @@ public class KubernetesMembershipProvider extends CloudMembershipProvider {
long aliveTime =
Duration.between(Instant.parse(creationTimestampObject.toString()), startTime).toMillis();
- MemberImpl member = null;
+ MemberImpl member;
try {
member = new MemberImpl(podIP, port, aliveTime);
} catch (IOException e) {
diff --git a/java/org/apache/catalina/tribes/membership/cloud/TokenStreamProvider.java b/java/org/apache/catalina/tribes/membership/cloud/TokenStreamProvider.java
index c1efc7a6e6..e8e52a096d 100644
--- a/java/org/apache/catalina/tribes/membership/cloud/TokenStreamProvider.java
+++ b/java/org/apache/catalina/tribes/membership/cloud/TokenStreamProvider.java
@@ -27,7 +27,7 @@ import javax.net.ssl.TrustManager;
public class TokenStreamProvider extends AbstractStreamProvider {
private String token;
- private SSLSocketFactory factory;
+ private final SSLSocketFactory factory;
TokenStreamProvider(String token, String caCertFile) throws Exception {
diff --git a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
index 350d2436ac..fd74822137 100644
--- a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
+++ b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
@@ -223,7 +223,7 @@ public abstract class AbstractReplicatedMap<K, V>
"Created Lazy Map with name:" + mapContextName + ", bytes:" + Arrays.toString(this.mapContextName));
}
- // create an rpc channel and add the map as a listener
+ // create a rpc channel and add the map as a listener
this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
// add this map as a message listener
this.channel.addChannelListener(this);
@@ -438,7 +438,7 @@ public abstract class AbstractReplicatedMap<K, V>
* @param complete - if set to true, the object is replicated to its backup if set to false, only objects that
* implement ReplicatedMapEntry and the isDirty() returns true will be replicated
*/
- public void replicate(Object key, boolean complete) {
+ public void replicate(K key, boolean complete) {
if (log.isTraceEnabled()) {
log.trace("Replicate invoked on key:" + key);
}
@@ -487,7 +487,7 @@ public abstract class AbstractReplicatedMap<K, V>
(Serializable) entry.getValue(), null, entry.getPrimary(), entry.getBackupNodes());
}
if (msg == null) {
- // construct a access message
+ // construct an access message
msg = new MapMessage(mapContextName, MapMessage.MSG_ACCESS, false, (Serializable) entry.getKey(), null,
null, entry.getPrimary(), entry.getBackupNodes());
}
@@ -863,9 +863,8 @@ public abstract class AbstractReplicatedMap<K, V>
@Override
public void memberDisappeared(Member member) {
- boolean removed = false;
synchronized (mapMembers) {
- removed = (mapMembers.remove(member) != null);
+ boolean removed = (mapMembers.remove(member) != null);
if (!removed) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("replicatedMap.member.disappeared.unknown", member));
@@ -941,7 +940,7 @@ public abstract class AbstractReplicatedMap<K, V>
public int getNextBackupIndex() {
synchronized (mapMembers) {
int size = mapMembers.size();
- if (mapMembers.size() == 0) {
+ if (mapMembers.isEmpty()) {
return -1;
}
int node = currentNode++;
@@ -1030,7 +1029,7 @@ public abstract class AbstractReplicatedMap<K, V>
// if the message is not primary, we need to retrieve the latest value
try {
Member[] backup = null;
- MapMessage msg = null;
+ MapMessage msg;
if (entry.isBackup()) {
// select a new backup node
backup = publishEntryInfo(key, entry.getValue());
@@ -1116,9 +1115,9 @@ public abstract class AbstractReplicatedMap<K, V>
System.out.println((++cnt) + ". " + innerMap.get(e.getKey()));
}
System.out.println("EndMap]\n\n");
- } catch (Exception ignore) {
+ } catch (Exception e) {
if (log.isTraceEnabled()) {
- log.trace("Error printing map", ignore);
+ log.trace("Error printing map", e);
}
}
}
@@ -1257,11 +1256,9 @@ public abstract class AbstractReplicatedMap<K, V>
// todo, implement a counter variable instead
// only count active members in this node
int counter = 0;
- Iterator<Map.Entry<K,MapEntry<K,V>>> it = innerMap.entrySet().iterator();
- while (it != null && it.hasNext()) {
- Map.Entry<?,?> e = it.next();
+ for (Entry<?, ?> e : innerMap.entrySet()) {
if (e != null) {
- MapEntry<K,V> entry = innerMap.get(e.getKey());
+ MapEntry<K, V> entry = innerMap.get(e.getKey());
if (entry != null && entry.isActive() && entry.getValue() != null) {
counter++;
}
@@ -1435,13 +1432,11 @@ public abstract class AbstractReplicatedMap<K, V>
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("MapEntry[key:");
- buf.append(getKey()).append("; ");
- buf.append("value:").append(getValue()).append("; ");
- buf.append("primary:").append(isPrimary()).append("; ");
- buf.append("backup:").append(isBackup()).append("; ");
- buf.append("proxy:").append(isProxy()).append(";]");
- return buf.toString();
+ return "MapEntry[key:" + getKey() + "; " +
+ "value:" + getValue() + "; " +
+ "primary:" + isPrimary() + "; " +
+ "backup:" + isBackup() + "; " +
+ "proxy:" + isProxy() + ";]";
}
}
@@ -1479,16 +1474,8 @@ public abstract class AbstractReplicatedMap<K, V>
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("MapMessage[context=");
- buf.append(new String(mapId));
- buf.append("; type=");
- buf.append(getTypeDesc());
- buf.append("; key=");
- buf.append(key);
- buf.append("; value=");
- buf.append(value);
- buf.append(']');
- return buf.toString();
+ return "MapMessage[context=" + new String(mapId) + "; type=" + getTypeDesc() +
+ "; key=" + key + "; value=" + value + ']';
}
public String getTypeDesc() {
diff --git a/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
index 751b2d15de..4029c84853 100644
--- a/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
+++ b/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
@@ -180,7 +180,7 @@ public class LazyReplicatedMap<K, V> extends AbstractReplicatedMap<K,V> {
if (next == null) {
continue;
}
- MapMessage msg = null;
+ MapMessage msg;
try {
Member[] tmpBackup = wrap(next);
// publish the backup data to one node
@@ -203,7 +203,7 @@ public class LazyReplicatedMap<K, V> extends AbstractReplicatedMap<K,V> {
try {
// publish the data out to all nodes
Member[] proxies = excludeFromSet(backup, getMapMembers());
- if (success && proxies.length > 0) {
+ if (proxies.length > 0) {
msg = new MapMessage(getMapContextName(), MapMessage.MSG_PROXY, false, (Serializable) key, null,
null, channel.getLocalMember(false), backup);
if (log.isTraceEnabled()) {
diff --git a/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
index a935098579..3b02f75fc5 100644
--- a/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
+++ b/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
@@ -186,10 +186,9 @@ public class ReplicatedMap<K, V> extends AbstractReplicatedMap<K,V> {
@Override
public void memberDisappeared(Member member) {
- boolean removed = false;
Log log = getLog();
synchronized (mapMembers) {
- removed = (mapMembers.remove(member) != null);
+ boolean removed = (mapMembers.remove(member) != null);
if (!removed) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("replicatedMap.member.disappeared.unknown", member));
diff --git a/java/org/apache/catalina/tribes/transport/PooledSender.java b/java/org/apache/catalina/tribes/transport/PooledSender.java
index b0af0fa4c9..a9d7339ff8 100644
--- a/java/org/apache/catalina/tribes/transport/PooledSender.java
+++ b/java/org/apache/catalina/tribes/transport/PooledSender.java
@@ -92,7 +92,7 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
@Override
public boolean keepalive() {
// do nothing, the pool checks on every return
- return (queue == null) ? false : queue.checkIdleKeepAlive();
+ return queue != null && queue.checkIdleKeepAlive();
}
@Override
@@ -110,13 +110,13 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
// ----------------------------------------------------- Inner Class
private static class SenderQueue {
- private int limit = 25;
+ private int limit;
- PooledSender parent = null;
+ PooledSender parent;
- private List<DataSender> notinuse = null;
+ private final List<DataSender> notinuse;
- private List<DataSender> inuse = null;
+ private final List<DataSender> inuse;
private boolean isOpen = true;
@@ -165,15 +165,15 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
throw new IllegalStateException(sm.getString("pooledSender.closed.queue"));
}
DataSender sender = null;
- if (notinuse.size() == 0 && inuse.size() < limit) {
+ if (notinuse.isEmpty() && inuse.size() < limit) {
sender = parent.getNewDataSender();
- } else if (notinuse.size() > 0) {
+ } else if (!notinuse.isEmpty()) {
sender = notinuse.remove(0);
}
if (sender != null) {
inuse.add(sender);
return sender;
- } // end if
+ }
long delta = System.currentTimeMillis() - start;
if (delta > timeout && timeout > 0) {
return null;
@@ -181,8 +181,9 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
try {
wait(Math.max(timeout - delta, 1));
} catch (InterruptedException x) {
+ // Ignore
}
- } // end if
+ }
}
}
@@ -215,11 +216,11 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
for (Object value : unused) {
DataSender sender = (DataSender) value;
sender.disconnect();
- } // for
+ }
for (Object o : used) {
DataSender sender = (DataSender) o;
sender.disconnect();
- } // for
+ }
notinuse.clear();
inuse.clear();
notifyAll();
diff --git a/java/org/apache/catalina/tribes/transport/ReceiverBase.java b/java/org/apache/catalina/tribes/transport/ReceiverBase.java
index 385dd28390..f3b4b51b17 100644
--- a/java/org/apache/catalina/tribes/transport/ReceiverBase.java
+++ b/java/org/apache/catalina/tribes/transport/ReceiverBase.java
@@ -97,8 +97,6 @@ public abstract class ReceiverBase implements ChannelReceiver, ListenCallback, R
@Override
public void start() throws IOException {
if (executor == null) {
- // executor = new ThreadPoolExecutor(minThreads,maxThreads,60,TimeUnit.SECONDS,new
- // LinkedBlockingQueue<Runnable>());
String channelName = "";
if (channel.getName() != null) {
channelName = "[" + channel.getName() + "]";
@@ -183,7 +181,7 @@ public abstract class ReceiverBase implements ChannelReceiver, ListenCallback, R
/**
* Attempts to bind using the provided port and if that fails attempts to bind to each of the ports from portstart
* to (portstart + retries -1) until either there are no more ports or the bind is successful. The address to bind
- * to is obtained via a call to {link {@link #getBind()}.
+ * to is obtained via a call to {@link #getBind()}.
*
* @param socket The socket to bind
* @param portstart Starting port for bind attempts
diff --git a/java/org/apache/catalina/tribes/transport/RxTaskPool.java b/java/org/apache/catalina/tribes/transport/RxTaskPool.java
index 4d36367476..667e0fdd98 100644
--- a/java/org/apache/catalina/tribes/transport/RxTaskPool.java
+++ b/java/org/apache/catalina/tribes/transport/RxTaskPool.java
@@ -48,10 +48,6 @@ public class RxTaskPool {
protected void configureTask(AbstractRxTask task) {
synchronized (task) {
task.setTaskPool(this);
- // task.setName(task.getClass().getName() + "[" + inc() + "]");
- // task.setDaemon(true);
- // task.setPriority(Thread.MAX_PRIORITY);
- // task.start();
}
}
@@ -64,12 +60,11 @@ public class RxTaskPool {
AbstractRxTask worker = null;
synchronized (mutex) {
while (worker == null && running) {
- if (idle.size() > 0) {
+ if (!idle.isEmpty()) {
try {
worker = idle.remove(0);
} catch (java.util.NoSuchElementException x) {
// this means that there are no available workers
- worker = null;
}
} else if (used.size() < this.maxTasks && creator != null) {
worker = creator.createRxTask();
@@ -81,7 +76,7 @@ public class RxTaskPool {
Thread.currentThread().interrupt();
}
}
- } // while
+ }
if (worker != null) {
used.add(worker);
}
@@ -104,7 +99,6 @@ public class RxTaskPool {
if (running) {
synchronized (mutex) {
used.remove(worker);
- // if ( idle.size() < minThreads && !idle.contains(worker)) idle.add(worker);
if (idle.size() < maxTasks && !idle.contains(worker)) {
idle.add(worker); // let max be the upper limit
} else {
diff --git a/java/org/apache/catalina/tribes/transport/SenderState.java b/java/org/apache/catalina/tribes/transport/SenderState.java
index a333ae127d..fa6235bc1f 100644
--- a/java/org/apache/catalina/tribes/transport/SenderState.java
+++ b/java/org/apache/catalina/tribes/transport/SenderState.java
@@ -52,7 +52,7 @@ public class SenderState {
// ----------------------------------------------------- Instance Variables
- private volatile int state = READY;
+ private volatile int state;
// ----------------------------------------------------- Constructor
diff --git a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
index 4f3c1c1668..93aa4cfaef 100644
--- a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
+++ b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
@@ -52,7 +52,7 @@ public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMB
private volatile boolean running = false;
- private AtomicReference<Selector> selector = new AtomicReference<>();
+ private final AtomicReference<Selector> selector = new AtomicReference<>();
private ServerSocketChannel serverChannel = null;
private DatagramChannel datagramChannel = null;
@@ -160,7 +160,7 @@ public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMB
if (events.isEmpty()) {
return;
}
- Runnable r = null;
+ Runnable r;
while ((r = events.pollFirst()) != null) {
try {
if (log.isTraceEnabled()) {
@@ -303,7 +303,7 @@ public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMB
// get an iterator over the set of selected keys
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
// look at each key in the selected set
- while (it != null && it.hasNext()) {
+ while (it.hasNext()) {
SelectionKey key = it.next();
// Is a new connection coming in?
if (key.isAcceptable()) {
@@ -397,9 +397,9 @@ public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMB
key.attach(null);
key.cancel();
}
- } catch (IOException ignore) {
+ } catch (IOException e) {
if (log.isWarnEnabled()) {
- log.warn(sm.getString("nioReceiver.cleanup.fail"), ignore);
+ log.warn(sm.getString("nioReceiver.cleanup.fail"), e);
}
} catch (ClosedSelectorException ignore) {
// Ignore
diff --git a/java/org/apache/catalina/tribes/transport/nio/NioReplicationTask.java b/java/org/apache/catalina/tribes/transport/nio/NioReplicationTask.java
index f4c91e1abf..ab34308717 100644
--- a/java/org/apache/catalina/tribes/transport/nio/NioReplicationTask.java
+++ b/java/org/apache/catalina/tribes/transport/nio/NioReplicationTask.java
@@ -199,7 +199,7 @@ public class NioReplicationTask extends AbstractRxTask {
ChannelMessage[] msgs = pkgcnt == 0 ? ChannelData.EMPTY_DATA_ARRAY : reader.execute();
- registerForRead(key, reader);// register to read new data, before we send it off to avoid dead locks
+ registerForRead(key, reader);// register to read new data, before we send it off to avoid deadlocks
for (ChannelMessage msg : msgs) {
/*
diff --git a/java/org/apache/catalina/tribes/transport/nio/NioSender.java b/java/org/apache/catalina/tribes/transport/nio/NioSender.java
index 8e7aedb79f..0db8c0fa54 100644
--- a/java/org/apache/catalina/tribes/transport/nio/NioSender.java
+++ b/java/org/apache/catalina/tribes/transport/nio/NioSender.java
@@ -96,12 +96,11 @@ public class NioSender extends AbstractSender {
if (current != null) {
key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
}
- return false;
} else {
// wait for the connection to finish
key.interestOps(key.interestOps() | SelectionKey.OP_CONNECT);
- return false;
- } // end if
+ }
+ return false;
} else if (key.isWritable()) {
boolean writecomplete = write();
if (writecomplete) {
@@ -120,7 +119,7 @@ public class NioSender extends AbstractSender {
} else {
// we are not complete, lets write some more
key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
- } // end if
+ }
} else if (key.isReadable()) {
boolean readcomplete = read();
if (readcomplete) {
@@ -281,9 +280,6 @@ public class NioSender extends AbstractSender {
// Ignore
}
// error free close, all the way
- // try {socket.shutdownOutput();}catch ( Exception x){}
- // try {socket.shutdownInput();}catch ( Exception x){}
- // try {socket.close();}catch ( Exception x){}
try {
socketChannel.close();
} catch (Exception x) {
@@ -301,9 +297,6 @@ public class NioSender extends AbstractSender {
// Ignore
}
// error free close, all the way
- // try {socket.shutdownOutput();}catch ( Exception x){}
- // try {socket.shutdownInput();}catch ( Exception x){}
- // try {socket.close();}catch ( Exception x){}
try {
dataChannel.close();
} catch (Exception x) {
diff --git a/java/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java b/java/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java
index 2c0f7ca850..d3c60af514 100644
--- a/java/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java
+++ b/java/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java
@@ -228,7 +228,7 @@ public class ParallelNioSender extends AbstractSender implements MultiPointSende
}
private static class SendResult {
- private List<NioSender> completeSenders = new ArrayList<>();
+ private final List<NioSender> completeSenders = new ArrayList<>();
private ChannelException exception = null;
private void complete(NioSender sender) {
diff --git a/java/org/apache/catalina/tribes/util/Arrays.java b/java/org/apache/catalina/tribes/util/Arrays.java
index 9998f6e5d4..714dc25aca 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -214,7 +214,7 @@ public class Arrays {
return idx;
}
- public static int hashCode(byte a[]) {
+ public static int hashCode(byte[] a) {
if (a == null) {
return 0;
}
diff --git a/java/org/apache/catalina/tribes/util/StringManager.java b/java/org/apache/catalina/tribes/util/StringManager.java
index d2b6623068..9b95b64b6f 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -47,7 +47,7 @@ import java.util.ResourceBundle;
*/
public class StringManager {
- private static int LOCALE_CACHE_SIZE = 10;
+ private static final int LOCALE_CACHE_SIZE = 10;
/**
* The ResourceBundle for this StringManager.
@@ -129,7 +129,6 @@ public class StringManager {
// better: consistent with container pattern to
// simply return null. Calling code can then do
// a null check.
- str = null;
}
return str;
@@ -181,7 +180,7 @@ public class StringManager {
*
* @return The StringManager for the given class.
*/
- public static final StringManager getManager(Class<?> clazz) {
+ public static StringManager getManager(Class<?> clazz) {
return getManager(clazz.getPackage().getName());
}
@@ -194,7 +193,7 @@ public class StringManager {
*
* @return The StringManager for the given package.
*/
- public static final StringManager getManager(String packageName) {
+ public static StringManager getManager(String packageName) {
return getManager(packageName, Locale.getDefault());
}
@@ -208,7 +207,7 @@ public class StringManager {
*
* @return The StringManager for a particular package and Locale
*/
- public static final synchronized StringManager getManager(String packageName, Locale locale) {
+ public static synchronized StringManager getManager(String packageName, Locale locale) {
Map<Locale,StringManager> map = managers.get(packageName);
if (map == null) {
@@ -222,10 +221,7 @@ public class StringManager {
@Override
protected boolean removeEldestEntry(Map.Entry<Locale,StringManager> eldest) {
- if (size() > (LOCALE_CACHE_SIZE - 1)) {
- return true;
- }
- return false;
+ return size() > (LOCALE_CACHE_SIZE - 1);
}
};
managers.put(packageName, map);
diff --git a/java/org/apache/catalina/tribes/util/UUIDGenerator.java b/java/org/apache/catalina/tribes/util/UUIDGenerator.java
index 0358fbcdc0..34df11b89c 100644
--- a/java/org/apache/catalina/tribes/util/UUIDGenerator.java
+++ b/java/org/apache/catalina/tribes/util/UUIDGenerator.java
@@ -64,7 +64,7 @@ public class UUIDGenerator {
into[6 + offset] &= 0x0F;
into[6 + offset] |= (UUID_VERSION << 4);
into[8 + offset] &= 0x3F; // 0011 1111
- into[8 + offset] |= 0x80; // 1000 0000
+ into[8 + offset] |= (byte) 0x80; // 1000 0000
return into;
}
@@ -77,11 +77,10 @@ public class UUIDGenerator {
* @param r Random
*/
public static void nextBytes(byte[] into, int offset, int length, Random r) {
- int numRequested = length;
int numGot = 0, rnd = 0;
while (true) {
for (int i = 0; i < BYTES_PER_INT; i++) {
- if (numGot == numRequested) {
+ if (numGot == length) {
return;
}
rnd = (i == 0 ? r.nextInt() : rnd >> BITS_PER_BYTE);
diff --git a/java/org/apache/catalina/users/DataSourceUserDatabase.java b/java/org/apache/catalina/users/DataSourceUserDatabase.java
index 503bd89cb9..9f8ba12440 100644
--- a/java/org/apache/catalina/users/DataSourceUserDatabase.java
+++ b/java/org/apache/catalina/users/DataSourceUserDatabase.java
@@ -322,7 +322,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
}
/**
- * @return the table that holds user data..
+ * @return the table that holds user data
*/
public String getUserTable() {
return userTable;
diff --git a/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java b/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java
index 388f0ea764..0db21bdd5b 100644
--- a/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java
+++ b/java/org/apache/catalina/users/DataSourceUserDatabaseFactory.java
@@ -52,7 +52,7 @@ public class DataSourceUserDatabaseFactory implements ObjectFactory {
/**
* <p>
* Create and return a new <code>DataSourceUserDatabase</code> instance that has been configured according to the
- * properties of the specified <code>Reference</code>. If you instance can be created, return <code>null</code>
+ * properties of the specified <code>Reference</code>. If the instance cannot be created, return <code>null</code>
* instead.
* </p>
*
diff --git a/java/org/apache/catalina/users/MemoryUserDatabase.java b/java/org/apache/catalina/users/MemoryUserDatabase.java
index 71566e6f29..8006607130 100644
--- a/java/org/apache/catalina/users/MemoryUserDatabase.java
+++ b/java/org/apache/catalina/users/MemoryUserDatabase.java
@@ -139,7 +139,7 @@ public class MemoryUserDatabase implements UserDatabase {
protected final Map<String,Role> roles = new ConcurrentHashMap<>();
/**
- * The set of {@link User}s defined in this database, keyed by user name.
+ * The set of {@link User}s defined in this database, keyed by username.
*/
protected final Map<String,User> users = new ConcurrentHashMap<>();
@@ -654,18 +654,8 @@ public class MemoryUserDatabase implements UserDatabase {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("MemoryUserDatabase[id=");
- sb.append(this.id);
- sb.append(",pathname=");
- sb.append(pathname);
- sb.append(",groupCount=");
- sb.append(this.groups.size());
- sb.append(",roleCount=");
- sb.append(this.roles.size());
- sb.append(",userCount=");
- sb.append(this.users.size());
- sb.append(']');
- return sb.toString();
+ return "MemoryUserDatabase[id=" + this.id + ",pathname=" + pathname + ",groupCount=" +
+ this.groups.size() + ",roleCount=" + this.roles.size() + ",userCount=" + this.users.size() + ']';
}
}
diff --git a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java
index b291573cae..540eb669de 100644
--- a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java
+++ b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java
@@ -54,7 +54,7 @@ public class MemoryUserDatabaseFactory implements ObjectFactory {
/**
* <p>
* Create and return a new <code>MemoryUserDatabase</code> instance that has been configured according to the
- * properties of the specified <code>Reference</code>. If you instance can be created, return <code>null</code>
+ * properties of the specified <code>Reference</code>. If the instance cannot be created, return <code>null</code>
* instead.
* </p>
*
diff --git a/java/org/apache/catalina/util/CharsetMapper.java b/java/org/apache/catalina/util/CharsetMapper.java
index fd10cc8aef..37365280df 100644
--- a/java/org/apache/catalina/util/CharsetMapper.java
+++ b/java/org/apache/catalina/util/CharsetMapper.java
@@ -57,7 +57,7 @@ public class CharsetMapper {
/**
- * Construct a new CharsetMapper using the specified properties resource.
+ * Construct a new CharsetMapper using the specified properties' resource.
*
* @param name Name of a properties resource to be loaded
*
diff --git a/java/org/apache/catalina/util/Introspection.java b/java/org/apache/catalina/util/Introspection.java
index 791362ae55..835bfc5744 100644
--- a/java/org/apache/catalina/util/Introspection.java
+++ b/java/org/apache/catalina/util/Introspection.java
@@ -72,7 +72,7 @@ public class Introspection {
*/
public static boolean isValidLifecycleCallback(Method method) {
return method.getParameterTypes().length == 0 && !Modifier.isStatic(method.getModifiers()) &&
- method.getExceptionTypes().length <= 0 && method.getReturnType().getName().equals("void");
+ method.getExceptionTypes().length == 0 && method.getReturnType().getName().equals("void");
}
/**
diff --git a/java/org/apache/catalina/util/LifecycleBase.java b/java/org/apache/catalina/util/LifecycleBase.java
index f614e5ea5d..1d59e54812 100644
--- a/java/org/apache/catalina/util/LifecycleBase.java
+++ b/java/org/apache/catalina/util/LifecycleBase.java
@@ -56,7 +56,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Will a {@link LifecycleException} thrown by a sub-class during {@link #initInternal()}, {@link #startInternal()},
+ * Will a {@link LifecycleException} thrown by a subclass during {@link #initInternal()}, {@link #startInternal()},
* {@link #stopInternal()} or {@link #destroyInternal()} be re-thrown for the caller to handle or will it be logged
* instead?
*
@@ -68,7 +68,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Configure if a {@link LifecycleException} thrown by a sub-class during {@link #initInternal()},
+ * Configure if a {@link LifecycleException} thrown by a subclass during {@link #initInternal()},
* {@link #startInternal()}, {@link #stopInternal()} or {@link #destroyInternal()} will be re-thrown for the caller
* to handle or if it will be logged instead.
*
@@ -98,7 +98,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Allow sub classes to fire {@link Lifecycle} events.
+ * Allow subclasses to fire {@link Lifecycle} events.
*
* @param type Event type
* @param data Data associated with event.
@@ -128,7 +128,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Sub-classes implement this method to perform any instance initialisation required.
+ * Subclasses implement this method to perform any instance initialisation required.
*
* @throws LifecycleException If the initialisation fails
*/
@@ -167,7 +167,7 @@ public abstract class LifecycleBase implements Lifecycle {
// FAILED state so call stop() to complete the clean-up.
stop();
} else if (!state.equals(LifecycleState.STARTING)) {
- // Shouldn't be necessary but acts as a check that sub-classes are
+ // Shouldn't be necessary but acts as a check that subclasses are
// doing what they are supposed to.
invalidTransition(AFTER_START_EVENT);
} else {
@@ -182,9 +182,9 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Sub-classes must ensure that the state is changed to {@link LifecycleState#STARTING} during the execution of this
+ * Subclasses must ensure that the state is changed to {@link LifecycleState#STARTING} during the execution of this
* method. Changing state will trigger the {@link Lifecycle#START_EVENT} event. If a component fails to start it may
- * either throw a {@link LifecycleException} which will cause it's parent to fail to start or it can place itself in
+ * either throw a {@link LifecycleException} which will cause it's parent to fail to start, or it can place itself in
* the error state in which case {@link #stop()} will be called on the failed component but the parent component
* will continue to start normally.
*
@@ -234,7 +234,7 @@ public abstract class LifecycleBase implements Lifecycle {
stopInternal();
- // Shouldn't be necessary but acts as a check that sub-classes are
+ // Shouldn't be necessary but acts as a check that subclasses are
// doing what they are supposed to.
if (!state.equals(LifecycleState.STOPPING) && !state.equals(LifecycleState.FAILED)) {
invalidTransition(AFTER_STOP_EVENT);
@@ -254,7 +254,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Sub-classes must ensure that the state is changed to {@link LifecycleState#STOPPING} during the execution of this
+ * Subclasses must ensure that the state is changed to {@link LifecycleState#STOPPING} during the execution of this
* method. Changing state will trigger the {@link Lifecycle#STOP_EVENT} event.
*
* @throws LifecycleException Stop error occurred
@@ -304,7 +304,7 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Sub-classes implement this method to perform any instance destruction required.
+ * Subclasses implement this method to perform any instance destruction required.
*
* @throws LifecycleException If the destruction fails
*/
@@ -324,9 +324,9 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Provides a mechanism for sub-classes to update the component state. Calling this method will automatically fire
+ * Provides a mechanism for subclasses to update the component state. Calling this method will automatically fire
* any associated {@link Lifecycle} event. It will also check that any attempted state transition is valid for a
- * sub-class.
+ * subclass.
*
* @param state The new state for this component
*
@@ -338,9 +338,9 @@ public abstract class LifecycleBase implements Lifecycle {
/**
- * Provides a mechanism for sub-classes to update the component state. Calling this method will automatically fire
+ * Provides a mechanism for subclasses to update the component state. Calling this method will automatically fire
* any associated {@link Lifecycle} event. It will also check that any attempted state transition is valid for a
- * sub-class.
+ * subclass.
*
* @param state The new state for this component
* @param data The data to pass to the associated {@link Lifecycle} event
diff --git a/java/org/apache/catalina/util/LifecycleMBeanBase.java b/java/org/apache/catalina/util/LifecycleMBeanBase.java
index e4db48c832..b58802dc26 100644
--- a/java/org/apache/catalina/util/LifecycleMBeanBase.java
+++ b/java/org/apache/catalina/util/LifecycleMBeanBase.java
@@ -75,7 +75,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
/**
- * Method implemented by sub-classes to identify the domain in which MBeans should be registered.
+ * Method implemented by subclasses to identify the domain in which MBeans should be registered.
*
* @return The name of the domain to use to register MBeans.
*/
@@ -89,7 +89,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
/**
- * Allow sub-classes to specify the key properties component of the {@link ObjectName} that will be used to register
+ * Allow subclasses to specify the key properties component of the {@link ObjectName} that will be used to register
* this component.
*
* @return The string representation of the key properties component of the desired {@link ObjectName}
@@ -98,7 +98,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
/**
- * Utility method to enable sub-classes to easily register additional components that don't implement
+ * Utility method to enable subclasses to easily register additional components that don't implement
* {@link JmxEnabled} with an MBean server. <br>
* Note: This method should only be used once {@link #initInternal()} has been called and before
* {@link #destroyInternal()} has been called.
@@ -119,7 +119,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
try {
on = new ObjectName(name.toString());
- Registry.getRegistry(null, null).registerComponent(obj, on, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(obj, on, null);
} catch (Exception e) {
log.warn(sm.getString("lifecycleMBeanBase.registerFail", obj, name), e);
}
@@ -129,7 +129,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
/**
- * Utility method to enable sub-classes to easily unregister additional components that don't implement
+ * Utility method to enable subclasses to easily unregister additional components that don't implement
* {@link JmxEnabled} with an MBean server. <br>
* Note: This method should only be used once {@link #initInternal()} has been called and before
* {@link #destroyInternal()} has been called.
@@ -138,15 +138,13 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
*/
protected final void unregister(String objectNameKeyProperties) {
// Construct an object name with the right domain
- StringBuilder name = new StringBuilder(getDomain());
- name.append(':');
- name.append(objectNameKeyProperties);
- Registry.getRegistry(null, null).unregisterComponent(name.toString());
+ String name = getDomain() + ':' + objectNameKeyProperties;
+ Registry.getRegistryNonNull(null, null).unregisterComponent(name);
}
/**
- * Utility method to enable sub-classes to easily unregister additional components that don't implement
+ * Utility method to enable subclasses to easily unregister additional components that don't implement
* {@link JmxEnabled} with an MBean server. <br>
* Note: This method should only be used once {@link #initInternal()} has been called and before
* {@link #destroyInternal()} has been called.
@@ -154,7 +152,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEna
* @param on The name of the component to unregister
*/
protected final void unregister(ObjectName on) {
- Registry.getRegistry(null, null).unregisterComponent(on);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(on);
}
diff --git a/java/org/apache/catalina/util/NetMask.java b/java/org/apache/catalina/util/NetMask.java
index 2ae3c67ec7..51c53769c8 100644
--- a/java/org/apache/catalina/util/NetMask.java
+++ b/java/org/apache/catalina/util/NetMask.java
@@ -236,7 +236,7 @@ public final class NetMask {
*
* But prior to that, a simple test can be done: we deal with IP addresses here, which means IPv4 and IPv6. IPv4
* addresses are encoded on 4 bytes, IPv6 addresses are encoded on 16 bytes. If the candidate address length is
- * different than this NetMask's address, we don't have a match.
+ * different from this NetMask's address, we don't have a match.
*/
if (candidate.length != netaddr.length) {
return false;
@@ -245,7 +245,7 @@ public final class NetMask {
/*
* Now do the byte-compare. The constructor has recorded the number of bytes to compare in nrBytes, use that. If
- * any of the byte we have to compare is different than what we expect, we don't have a match.
+ * any of the byte we have to compare is different from what we expect, we don't have a match.
*
* If, on the opposite, after this loop, all bytes have been deemed equal, then the loop variable i will point
* to the byte right after that -- which we will need...
diff --git a/java/org/apache/catalina/util/RateLimiterBase.java b/java/org/apache/catalina/util/RateLimiterBase.java
index d04c88836e..188eed88cf 100644
--- a/java/org/apache/catalina/util/RateLimiterBase.java
+++ b/java/org/apache/catalina/util/RateLimiterBase.java
@@ -48,7 +48,7 @@ public abstract class RateLimiterBase implements RateLimiter {
private ScheduledThreadPoolExecutor internalExecutorService = null;
/**
- * If policy name has not been specified, the first call of {@link #getPolicyName()} returns a auto-generated policy
+ * If policy name has not been specified, the first call of {@link #getPolicyName()} returns an auto-generated policy
* name using the default policy name as prefix and followed by auto-increase index.
*
* @return default policy name, as a prefix of auto-generated policy name.
diff --git a/java/org/apache/catalina/util/TimeBucketCounterBase.java b/java/org/apache/catalina/util/TimeBucketCounterBase.java
index a48bbae306..f5e1c318c2 100644
--- a/java/org/apache/catalina/util/TimeBucketCounterBase.java
+++ b/java/org/apache/catalina/util/TimeBucketCounterBase.java
@@ -48,7 +48,7 @@ public abstract class TimeBucketCounterBase {
private ScheduledFuture<?> monitorFuture;
private final ScheduledExecutorService executorService;
private final long sleeptime;
- private int bucketDuration;
+ private final int bucketDuration;
/**
diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 4992964b27..37a3f34e4c 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -428,12 +428,12 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
private static final ThreadLocal<Date> localDate = ThreadLocal.withInitial(Date::new);
/**
- * Are we doing conditional logging. default null. It is the value of <code>conditionUnless</code> property.
+ * Are we doing conditional logging ? default null. It is the value of <code>conditionUnless</code> property.
*/
protected String condition = null;
/**
- * Are we doing conditional logging. default null. It is the value of <code>conditionIf</code> property.
+ * Are we doing conditional logging ? default null. It is the value of <code>conditionIf</code> property.
*/
protected String conditionIf = null;
@@ -708,7 +708,7 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
/**
* This method returns a Date object that is accurate to within one second. If a thread calls this method to get a
- * Date and it's been less than 1 second since a new Date was created, this method simply gives out the same Date
+ * Date, and it's been less than 1 second since a new Date was created, this method simply gives out the same Date
* again so that the system doesn't spend time creating Date objects unnecessarily.
*
* @param systime The time
@@ -753,7 +753,7 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
}
/**
- * Marks an AccessLogElement as needing to be have the value cached at the start of the request rather than just
+ * Marks an AccessLogElement as needing to have the value cached at the start of the request rather than just
* recorded at the end as the source data for the element may not be available at the end of the request. This
* typically occurs for remote network information, such as ports, IP addresses etc. when the connection is closed
* unexpectedly. These elements take advantage of these values being cached elsewhere on first request and do not
@@ -1300,7 +1300,7 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
* write time taken to process the request - %D, %T
*/
protected static class ElapsedTimeElement implements AccessLogElement {
- enum Style {
+ public enum Style {
SECONDS {
@Override
public void append(CharArrayWriter buf, long time) {
@@ -1683,7 +1683,7 @@ public abstract class AbstractAccessLogValve extends ValveBase implements Access
/**
* Write identifier element %{xxx}L
*/
- protected class IdentifierElement implements AccessLogElement {
+ protected static class IdentifierElement implements AccessLogElement {
/**
* Type of identifier to log
diff --git a/java/org/apache/catalina/valves/ErrorReportValve.java b/java/org/apache/catalina/valves/ErrorReportValve.java
index 4b6fbc52b7..8c8719f287 100644
--- a/java/org/apache/catalina/valves/ErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ErrorReportValve.java
@@ -94,7 +94,7 @@ public class ErrorReportValve extends ValveBase {
if (response.isCommitted()) {
if (response.setErrorReported()) {
- // Error wasn't previously reported but we can't write an error
+ // Error wasn't previously reported, but we can't write an error
// page because the response has already been committed.
// See if IO is allowed
diff --git a/java/org/apache/catalina/valves/JsonAccessLogValve.java b/java/org/apache/catalina/valves/JsonAccessLogValve.java
index 63acd4f8f6..e62a5de135 100644
--- a/java/org/apache/catalina/valves/JsonAccessLogValve.java
+++ b/java/org/apache/catalina/valves/JsonAccessLogValve.java
@@ -69,7 +69,8 @@ import org.apache.tomcat.util.json.JSONFilter;
* <li>%{xxx}s: sessionAttributes</li>
* <li>%{xxx}L: identifier</li>
* </ul>
- * The attribute list is based on https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/parser_apache2.rb#L72
+ * The attribute list is based on
+ * <a href="https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/parser_apache2.rb#L72">parser_apache2.rb</a>
*/
public class JsonAccessLogValve extends AccessLogValve {
diff --git a/java/org/apache/catalina/valves/RemoteIpValve.java b/java/org/apache/catalina/valves/RemoteIpValve.java
index 04ddde1bcd..466022aeaf 100644
--- a/java/org/apache/catalina/valves/RemoteIpValve.java
+++ b/java/org/apache/catalina/valves/RemoteIpValve.java
@@ -53,7 +53,7 @@ import org.apache.tomcat.util.http.parser.Host;
* If the incoming <code>request.getRemoteAddr()</code> matches the valve's list of internal or trusted proxies:
* </p>
* <ul>
- * <li>Loop on the comma delimited list of IPs and hostnames passed by the preceding load balancer or proxy in the given
+ * <li>Loop on the comma-delimited list of IPs and hostnames passed by the preceding load balancer or proxy in the given
* request's Http header named <code>$remoteIpHeader</code> (default value <code>x-forwarded-for</code>). Values are
* processed in right-to-left order.</li>
* <li>For each ip/host of the list:
@@ -129,7 +129,7 @@ import org.apache.tomcat.util.http.parser.Host;
* </tr>
* <tr>
* <td>protocolHeaderHttpsValue</td>
- * <td>Value of the <code>protocolHeader</code> to indicate that it is an Https request</td>
+ * <td>Value of the <code>protocolHeader</code> to indicate that it is a Https request</td>
* <td>N/A</td>
* <td>String like <code>https</code> or <code>ON</code></td>
* <td><code>https</code></td>
@@ -861,7 +861,7 @@ public class RemoteIpValve extends ValveBase {
/**
* <p>
- * Case insensitive value of the protocol header to indicate that the incoming http request uses SSL.
+ * Case-insensitive value of the protocol header to indicate that the incoming http request uses SSL.
* </p>
* <p>
* Default value : <code>https</code>
@@ -884,7 +884,7 @@ public class RemoteIpValve extends ValveBase {
* Name of the http header that holds the list of trusted proxies that has been traversed by the http request.
* </p>
* <p>
- * The value of this header can be comma delimited.
+ * The value of this header can be comma-delimited.
* </p>
* <p>
* Default value : <code>X-Forwarded-By</code>
@@ -901,7 +901,7 @@ public class RemoteIpValve extends ValveBase {
* Name of the http header from which the remote ip is extracted.
* </p>
* <p>
- * The value of this header can be comma delimited.
+ * The value of this header can be comma-delimited.
* </p>
* <p>
* Default value : <code>X-Forwarded-For</code>
@@ -914,7 +914,7 @@ public class RemoteIpValve extends ValveBase {
}
/**
- * Should this valve set request attributes for IP address, Hostname, protocol and port used for the request? This
+ * Should this valve set request attributes for IP address, Hostname, protocol and port used for the request? These
* are typically used in conjunction with the {@link AccessLog} which will otherwise log the original values.
* Default is <code>true</code>. The attributes set are:
* <ul>
diff --git a/java/org/apache/catalina/valves/RequestFilterValve.java b/java/org/apache/catalina/valves/RequestFilterValve.java
index 711545792e..9353c7d656 100644
--- a/java/org/apache/catalina/valves/RequestFilterValve.java
+++ b/java/org/apache/catalina/valves/RequestFilterValve.java
@@ -41,7 +41,7 @@ import org.apache.juli.logging.Log;
* <li>The subclass extracts the request property to be filtered, and calls the common <code>process()</code> method.
* <li>If there is a deny expression configured, the property will be compared to the expression. If a match is found,
* this request will be rejected with a "Forbidden" HTTP response.</li>
- * <li>If there is a allow expression configured, the property will be compared to each such expression. If a match is
+ * <li>If there is an allow expression configured, the property will be compared to each such expression. If a match is
* found, this request will be allowed to pass through to the next Valve in the current pipeline.</li>
* <li>If a deny expression was specified but no allow expression, allow this request to pass through (because none of
* the deny expressions matched it).
@@ -111,9 +111,8 @@ public abstract class RequestFilterValve extends ValveBase {
protected int denyStatus = HttpServletResponse.SC_FORBIDDEN;
/**
- * <p>
* If <code>invalidAuthenticationWhenDeny</code> is true and the context has <code>preemptiveAuthentication</code>
- * set, set an invalid authorization header to trigger basic auth instead of denying the request..
+ * set, set an invalid authorization header to trigger basic auth instead of denying the request.
*/
private boolean invalidAuthenticationWhenDeny = false;
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteMap.java b/java/org/apache/catalina/valves/rewrite/RewriteMap.java
index 3722ba99a3..797af13769 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteMap.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteMap.java
@@ -49,7 +49,7 @@ public interface RewriteMap {
* Optional parameters that can be defined through the {@code RewriteMap} directive in the {@code rewrite.config}
* file.
* <p>
- * This method will be called, if there are more than one parameters defined.
+ * This method will be called, if there is more than one parameter defined.
*
* @param params the optional parameters
*/
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteRule.java b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
index 08034d7e24..444e6305c2 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteRule.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
@@ -215,7 +215,7 @@ public class RewriteRule {
protected boolean host = false;
/**
- * Stop the rewriting process here and don't apply any more rewriting rules. This corresponds to the Perl last
+ * Stop the rewriting process here and don't apply any additional rewriting rules. This corresponds to the Perl last
* command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being
* rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g.,
* '/e/www/'.
@@ -299,7 +299,7 @@ public class RewriteRule {
protected int skip = 0;
/**
- * Force the MIME-type of the target file to be MIME-type. For instance, this can be used to setup the content-type
+ * Force the MIME-type of the target file to be MIME-type. For instance, this can be used to set up the content-type
* based on some conditions. For example, the following snippet allows .php files to be displayed by mod_php if they
* are called with the .phps extension: RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]
*/
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index 3df891d205..c983cc7382 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -26,6 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
@@ -313,7 +314,7 @@ public class RewriteValve extends ValveBase {
RewriteRule rule = rules[i];
CharSequence test = (rule.isHost()) ? host : urlDecoded;
CharSequence newtest = rule.evaluate(test, resolver);
- if (newtest != null && !test.toString().equals(newtest.toString())) {
+ if (newtest != null && !Objects.equals(test.toString(), newtest.toString())) {
if (containerLog.isTraceEnabled()) {
containerLog.trace(
"Rewrote " + test + " as " + newtest + " with rule pattern " + rule.getPatternString());
diff --git a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
index 0cabb4d14e..3e89394531 100644
--- a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
+++ b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
@@ -124,7 +124,7 @@ public abstract class AbstractFileResourceSet extends AbstractResourceSet {
// Case sensitivity check
// The normalized requested path should be an exact match the equivalent
// canonical path. If it is not, possible reasons include:
- // - case differences on case insensitive file systems
+ // - case differences on case-insensitive file systems
// - Windows removing a trailing ' ' or '.' from the file name
//
// In all cases, a mismatch here results in the resource not being
diff --git a/java/org/apache/catalina/webresources/JarContents.java b/java/org/apache/catalina/webresources/JarContents.java
index 87c0693ea6..58e0bff993 100644
--- a/java/org/apache/catalina/webresources/JarContents.java
+++ b/java/org/apache/catalina/webresources/JarContents.java
@@ -130,7 +130,7 @@ public final class JarContents {
* Method that identifies whether a given path <b>MIGHT</b> be in this jar. Uses the Bloom filter mechanism.
*
* @param path Requested path. Sometimes starts with "/WEB-INF/classes".
- * @param webappRoot The value of the webapp location, which can be stripped from the path. Typically is
+ * @param webappRoot The value of the webapp location, which can be stripped from the path. Typically it is
* "/WEB-INF/classes".
*
* @return Whether the prefix of the path is known to be in this jar.
diff --git a/java/org/apache/catalina/webresources/JarWarResource.java b/java/org/apache/catalina/webresources/JarWarResource.java
index dcefd22213..a63bf51a2c 100644
--- a/java/org/apache/catalina/webresources/JarWarResource.java
+++ b/java/org/apache/catalina/webresources/JarWarResource.java
@@ -54,10 +54,9 @@ public class JarWarResource extends AbstractArchiveResource {
InputStream isInWar = warFile.getInputStream(jarFileInWar);
jarIs = new JarInputStream(isInWar);
- entry = jarIs.getNextJarEntry();
- while (entry != null && !entry.getName().equals(getResource().getName())) {
+ do {
entry = jarIs.getNextJarEntry();
- }
+ } while (entry != null && !entry.getName().equals(getResource().getName()));
if (entry == null) {
return null;
diff --git a/java/org/apache/catalina/webresources/StandardRoot.java b/java/org/apache/catalina/webresources/StandardRoot.java
index 1d95214393..8f9fa45691 100644
--- a/java/org/apache/catalina/webresources/StandardRoot.java
+++ b/java/org/apache/catalina/webresources/StandardRoot.java
@@ -119,7 +119,7 @@ public class StandardRoot extends LifecycleMBeanBase implements WebResourceRoot
// Set because we don't want duplicates
// LinkedHashSet to retain the order. It is the order of the
- // WebResourceSet that matters but it is simpler to retain the order
+ // WebResourceSet that matters, but it is simpler to retain the order
// over all of the JARs.
HashSet<String> result = new LinkedHashSet<>();
for (List<WebResourceSet> list : allResources) {
diff --git a/java/org/apache/catalina/webresources/TomcatJarInputStream.java b/java/org/apache/catalina/webresources/TomcatJarInputStream.java
index a05add04fa..9247d8a031 100644
--- a/java/org/apache/catalina/webresources/TomcatJarInputStream.java
+++ b/java/org/apache/catalina/webresources/TomcatJarInputStream.java
@@ -23,7 +23,7 @@ import java.util.jar.JarInputStream;
import java.util.zip.ZipEntry;
/**
- * The purpose of this sub-class is to obtain references to the JarEntry objects for META-INF/ and META-INF/MANIFEST.MF
+ * The purpose of this subclass is to obtain references to the JarEntry objects for META-INF/ and META-INF/MANIFEST.MF
* that are otherwise swallowed by the JarInputStream implementation.
*/
public class TomcatJarInputStream extends JarInputStream {
diff --git a/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java b/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
index 02a0842eea..a8d7ac4d60 100644
--- a/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
+++ b/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
@@ -45,7 +45,7 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
private static TomcatURLStreamHandlerFactory getInstanceInternal(boolean register) {
- // Double checked locking. OK because instance is volatile.
+ // Double-checked locking. OK because instance is volatile.
if (instance == null) {
synchronized (TomcatURLStreamHandlerFactory.class) {
if (instance == null) {
@@ -75,7 +75,7 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
/**
- * Prevent this this factory from registering with the JVM. May be called more than once.
+ * Prevent this factory from registering with the JVM. May be called more than once.
*
* @return <code>true</code> if the factory is already disabled or was successfully disabled as a result of this
* call. <code>false</code> if the factory was already registered prior to this call.
diff --git a/java/org/apache/coyote/AbstractProcessor.java b/java/org/apache/coyote/AbstractProcessor.java
index bddca91c3e..fc7d81e816 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -679,7 +679,7 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement
/**
* {@inheritDoc}
* <p>
- * Sub-classes of this base class represent a single request/response pair. The timeout to be processed is,
+ * Subclasses of this base class represent a single request/response pair. The timeout to be processed is,
* therefore, the Servlet asynchronous processing timeout.
*/
@Override
@@ -734,7 +734,7 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement
/**
- * When committing the response, we have to validate the set of headers, as well as setup the response filters.
+ * When committing the response, we have to validate the set of headers, as well as set up the response filters.
*
* @throws IOException IO exception during commit
*/
@@ -1074,9 +1074,9 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement
// Set the socket wrapper so the access log can read the socket related
// information (e.g. client IP)
setSocketWrapper(socketWrapper);
- // Setup the minimal request information
+ // Set up the minimal request information
request.setStartTimeNanos(System.nanoTime());
- // Setup the minimal response information
+ // Set up the minimal response information
response.setStatus(400);
response.setError();
getAdapter().log(request, response, 0);
diff --git a/java/org/apache/coyote/AbstractProcessorLight.java b/java/org/apache/coyote/AbstractProcessorLight.java
index bd952cedeb..257f727a52 100644
--- a/java/org/apache/coyote/AbstractProcessorLight.java
+++ b/java/org/apache/coyote/AbstractProcessorLight.java
@@ -75,7 +75,7 @@ public abstract class AbstractProcessorLight implements Processor {
}
/*
- * If state is already CLOSED don't call asyncPostProcess() as that will likely change the the state to some
+ * If state is already CLOSED don't call asyncPostProcess() as that will likely change the state to some
* other value causing processing to continue when it should cease. The AsyncStateMachine will be recycled
* as part of the Processor clean-up on CLOSED so it doesn't matter what state it is left in at this point.
*/
@@ -173,7 +173,7 @@ public abstract class AbstractProcessorLight implements Processor {
protected abstract SocketState service(SocketWrapperBase<?> socketWrapper) throws IOException;
/**
- * Process an in-progress request that is not longer in standard HTTP mode. Uses currently include Servlet 3.0 Async
+ * Process an in-progress request that is no longer in standard HTTP mode. Uses currently include Servlet 3.0 Async
* and HTTP upgrade connections. Further uses may be added in the future. These will typically start as HTTP
* requests.
*
diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java
index da8f1d0c25..013ffe8e21 100644
--- a/java/org/apache/coyote/AbstractProtocol.java
+++ b/java/org/apache/coyote/AbstractProtocol.java
@@ -616,14 +616,14 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis
// Component not pre-registered so register it
oname = createObjectName();
if (oname != null) {
- Registry.getRegistry(null, null).registerComponent(this, oname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(this, oname, null);
}
}
if (this.domain != null) {
ObjectName rgOname = new ObjectName(domain + ":type=GlobalRequestProcessor,name=" + getName());
this.rgOname = rgOname;
- Registry.getRegistry(null, null).registerComponent(getHandler().getGlobal(), rgOname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(getHandler().getGlobal(), rgOname, null);
}
String endpointName = getName();
@@ -734,7 +734,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis
} finally {
if (oname != null) {
if (mserver == null) {
- Registry.getRegistry(null, null).unregisterComponent(oname);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(oname);
} else {
// Possibly registered with a different MBeanServer
try {
@@ -747,7 +747,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis
ObjectName rgOname = getGlobalRequestProcessorMBeanName();
if (rgOname != null) {
- Registry.getRegistry(null, null).unregisterComponent(rgOname);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(rgOname);
}
}
}
@@ -1134,7 +1134,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis
if (getLog().isTraceEnabled()) {
getLog().trace("Register [" + processor + "] as [" + rpName + "]");
}
- Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(rp, rpName, null);
rp.setRpName(rpName);
} catch (Exception e) {
getLog().warn(sm.getString("abstractProtocol.processorRegisterError"), e);
@@ -1158,7 +1158,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, MBeanRegis
if (getLog().isTraceEnabled()) {
getLog().trace("Unregister [" + rpName + "]");
}
- Registry.getRegistry(null, null).unregisterComponent(rpName);
+ Registry.getRegistryNonNull(null, null).unregisterComponent(rpName);
rp.setRpName(null);
} catch (Exception e) {
getLog().warn(sm.getString("abstractProtocol.processorUnregisterError"), e);
diff --git a/java/org/apache/coyote/ActionCode.java b/java/org/apache/coyote/ActionCode.java
index 179e02d7da..8b1173291e 100644
--- a/java/org/apache/coyote/ActionCode.java
+++ b/java/org/apache/coyote/ActionCode.java
@@ -138,7 +138,7 @@ public enum ActionCode {
ASYNC_DISPATCH,
/**
- * Callback to indicate the the actual dispatch has started and that the async state needs change.
+ * Callback to indicate the actual dispatch has started and that the async state needs change.
*/
ASYNC_DISPATCHED,
diff --git a/java/org/apache/coyote/ErrorState.java b/java/org/apache/coyote/ErrorState.java
index 9724e65a20..b0e8c09267 100644
--- a/java/org/apache/coyote/ErrorState.java
+++ b/java/org/apache/coyote/ErrorState.java
@@ -66,7 +66,7 @@ public enum ErrorState {
*
* @param input The error state to compare to this one
*
- * @return The most severe error state from the the provided error state and this one
+ * @return The most severe error state from the provided error state and this one
*/
public ErrorState getMostSevere(ErrorState input) {
if (input.severity > this.severity) {
diff --git a/java/org/apache/coyote/Processor.java b/java/org/apache/coyote/Processor.java
index c82f0df75f..b322036bf0 100644
--- a/java/org/apache/coyote/Processor.java
+++ b/java/org/apache/coyote/Processor.java
@@ -67,7 +67,7 @@ public interface Processor {
* Note: The name of this method originated with the Servlet 3.0 asynchronous processing but evolved over time to
* represent a timeout that is triggered independently of the socket read/write timeouts.
*
- * @param now The time (as returned by {@link System#currentTimeMillis()} to use as the current time to determine
+ * @param now The time (as returned by {@link System#currentTimeMillis()}) to use as the current time to determine
* whether the timeout has expired. If negative, the timeout will always be treated as if it has
* expired.
*/
diff --git a/java/org/apache/coyote/ProtocolHandler.java b/java/org/apache/coyote/ProtocolHandler.java
index a92473c18a..465df3fc53 100644
--- a/java/org/apache/coyote/ProtocolHandler.java
+++ b/java/org/apache/coyote/ProtocolHandler.java
@@ -131,7 +131,7 @@ public interface ProtocolHandler {
/**
* Close the server socket (to prevent further connections) if the server socket was bound on {@link #start()}
- * (rather than on {@link #init()} but do not perform any further shutdown.
+ * (rather than on {@link #init()}) but do not perform any further shutdown.
*/
void closeServerSocketGraceful();
diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/coyote/Request.java
index fc1b0558ae..006213ad94 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -72,7 +72,7 @@ public final class Request {
* another 3,000,000 years before it gets back to zero).
*
* Local testing shows that 5, 10, 50, 500 or 1000 threads can obtain 60,000,000+ IDs a second from a single
- * AtomicLong. That is about about 17ns per request. It does not appear that the introduction of this counter will
+ * AtomicLong. That is about 17ns per request. It does not appear that the introduction of this counter will
* cause a bottleneck for request processing.
*/
private static final AtomicLong requestIdGenerator = new AtomicLong(0);
diff --git a/java/org/apache/coyote/RequestInfo.java b/java/org/apache/coyote/RequestInfo.java
index d1fffd3df9..41081f5806 100644
--- a/java/org/apache/coyote/RequestInfo.java
+++ b/java/org/apache/coyote/RequestInfo.java
@@ -25,7 +25,7 @@ import javax.management.ObjectName;
* Structure holding the Request and Response objects. It also holds statistical information about request processing
* and provide management information about the requests being processed. Each thread uses a Request/Response pair that
* is recycled on each request. This object provides a place to collect global low-level statistics - without having to
- * deal with synchronization ( since each thread will have it's own RequestProcessorMX ).
+ * deal with synchronization ( since each thread will have its own RequestProcessorMX ).
*
* @author Costin Manolache
*/
@@ -101,7 +101,7 @@ public class RequestInfo {
/**
* Obtain the remote address for this connection as reported by an intermediate proxy (if any).
*
- * @return The remote address for the this connection
+ * @return The remote address for this connection
*/
public String getRemoteAddrForwarded() {
String remoteAddrProxy = (String) req.getAttribute(Constants.REMOTE_ADDR_ATTRIBUTE);
diff --git a/java/org/apache/coyote/ajp/AbstractAjpProtocol.java b/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
index 3d60357e17..76112b980c 100644
--- a/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
+++ b/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
@@ -29,7 +29,7 @@ import org.apache.tomcat.util.net.SocketWrapperBase;
import org.apache.tomcat.util.res.StringManager;
/**
- * The is the base implementation for the AJP protocol handlers. Implementations typically extend this base class rather
+ * This the base implementation for the AJP protocol handlers. Implementations typically extend this base class rather
* than implement {@link org.apache.coyote.ProtocolHandler}. All of the implementations that ship with Tomcat are
* implemented this way.
*
@@ -97,7 +97,7 @@ public abstract class AbstractAjpProtocol<S> extends AbstractProtocol<S> {
/**
* Configure whether to aend an AJP flush packet when flushing. A flush packet is a zero byte AJP13 SEND_BODY_CHUNK
* packet. mod_jk and mod_proxy_ajp interpret this as a request to flush data to the client. AJP always does flush
- * at the and of the response, so if it is not important, that the packets get streamed up to the client, do not use
+ * at the end of the response, so if it is not important, that the packets get streamed up to the client, do not use
* extra flush packets. For compatibility and to stay on the safe side, flush packets are enabled by default.
*
* @param ajpFlush The new flush setting
diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
index af113f9302..3dba56da10 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -97,7 +97,7 @@ public abstract class AbstractHttp11Protocol<S> extends AbstractProtocol<S> {
// be de-registered.
ObjectName rgOname = getGlobalRequestProcessorMBeanName();
if (rgOname != null) {
- Registry registry = Registry.getRegistry(null, null);
+ Registry registry = Registry.getRegistryNonNull(null, null);
ObjectName query = new ObjectName(rgOname.getCanonicalName() + ",Upgrade=*");
Set<ObjectInstance> upgrades = registry.getMBeanServer().queryMBeans(query, null);
for (ObjectInstance upgrade : upgrades) {
@@ -678,7 +678,7 @@ public abstract class AbstractHttp11Protocol<S> extends AbstractProtocol<S> {
ObjectName oname = getONameForUpgrade(upgradeProtocol);
if (oname != null) {
try {
- Registry.getRegistry(null, null).registerComponent(result, oname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(result, oname, null);
} catch (Exception e) {
getLog().warn(sm.getString("abstractHttp11Protocol.upgradeJmxRegistrationFail"), e);
result = null;
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java
index a8dc09d96c..832ddc520b 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -100,7 +100,7 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler
/**
* Underlying input buffer.
*/
- private InputBuffer inputStreamInputBuffer;
+ private final InputBuffer inputStreamInputBuffer;
/**
@@ -122,7 +122,7 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler
/**
- * Parsing state - used for non blocking parsing so that when more data arrives, we can pick up where we left off.
+ * Parsing state - used for non-blocking parsing so that when more data arrives, we can pick up where we left off.
*/
private byte prevChr = 0;
private byte chr = 0;
diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java b/java/org/apache/coyote/http11/Http11OutputBuffer.java
index 6967c30996..6ce1d04cc9 100644
--- a/java/org/apache/coyote/http11/Http11OutputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java
@@ -281,7 +281,7 @@ public class Http11OutputBuffer implements HttpOutputBuffer {
public void sendAck() throws IOException {
// It possible that the protocol configuration is changed between the
- // request being received and the first read of the body. That could led
+ // request being received and the first read of the body. That could lead
// to multiple calls to this method so ensure the ACK is only sent once.
if (!response.isCommitted() && !ackSent) {
ackSent = true;
diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java
index f3ec055596..8856e3dea5 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -623,7 +623,7 @@ public class Http11Processor extends AbstractProcessor {
/**
- * After reading the request headers, we have to setup the request filters.
+ * After reading the request headers, we have to set up the request filters.
*/
@SuppressWarnings("deprecation")
private void prepareRequest() throws IOException {
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index 1be7215e76..75d6efa546 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -363,8 +363,8 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler
}
eol = true;
} else if (chr == Constants.SEMI_COLON && !parsingExtension) {
- // First semi-colon marks the start of the extension. Further
- // semi-colons may appear to separate multiple chunk-extensions.
+ // First semicolon marks the start of the extension. Further
+ // semicolons may appear to separate multiple chunk-extensions.
// These need to be processed as part of parsing the extensions.
parsingExtension = true;
extensionSize++;
@@ -426,8 +426,8 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler
}
eol = true;
} else if (chr == Constants.SEMI_COLON && !parsingExtension) {
- // First semi-colon marks the start of the extension. Further
- // semi-colons may appear to separate multiple chunk-extensions.
+ // First semicolon marks the start of the extension. Further
+ // semicolons may appear to separate multiple chunk-extensions.
// These need to be processed as part of parsing the extensions.
parsingExtension = true;
extensionSize++;
diff --git a/java/org/apache/coyote/http2/HpackDecoder.java b/java/org/apache/coyote/http2/HpackDecoder.java
index 6804f9efb1..d6fb592f6f 100644
--- a/java/org/apache/coyote/http2/HpackDecoder.java
+++ b/java/org/apache/coyote/http2/HpackDecoder.java
@@ -283,7 +283,7 @@ public class HpackDecoder {
*/
int getRealIndex(int index) throws HpackException {
// the index is one based, but our table is zero based, hence -1
- // also because of our ring buffer setup the indexes are reversed
+ // also because of our ring buffer set up the indexes are reversed
// index = 1 is at position firstSlotPosition + filledSlots
int realIndex = (firstSlotPosition + (filledTableSlots - index)) % headerTable.length;
if (realIndex < 0) {
@@ -307,7 +307,7 @@ public class HpackDecoder {
if (log.isTraceEnabled()) {
log.trace(sm.getString("hpackdecoder.clearDynamic"));
}
- // it is to big to fit, so we just completely clear the table.
+ // it is too big to fit, so we just completely clear the table.
while (filledTableSlots > 0) {
headerTable[firstSlotPosition] = null;
firstSlotPosition++;
@@ -380,7 +380,7 @@ public class HpackDecoder {
/**
* Are the headers pass to the recipient so far valid? The decoder needs to process all the headers to maintain
- * state even if there is a problem. In addition, it is easy for the the intended recipient to track if the
+ * state even if there is a problem. In addition, it is easy for the intended recipient to track if the
* complete set of headers is valid since to do that state needs to be maintained between the parsing of the
* initial headers and the parsing of any trailer headers. The recipient is the best place to maintain that
* state.
diff --git a/java/org/apache/coyote/http2/Http2Protocol.java b/java/org/apache/coyote/http2/Http2Protocol.java
index f9b57bb00f..dc94412537 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -378,7 +378,7 @@ public class Http2Protocol implements UpgradeProtocol {
ObjectName oname = this.http11Protocol.getONameForUpgrade(getUpgradeProtocolName());
// This can be null when running the testsuite
if (oname != null) {
- Registry.getRegistry(null, null).registerComponent(global, oname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(global, oname, null);
}
} catch (Exception e) {
log.warn(sm.getString("http2Protocol.jmxRegistration.fail"), e);
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 809ef47bf2..6721c633ce 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -65,7 +65,7 @@ import org.apache.tomcat.util.res.StringManager;
* For reading, this implementation is blocking within frames and non-blocking between frames. <br>
* Note:
* <ul>
- * <li>You will need to nest an <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> element
+ * <li>You will need to nest a <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> element
* inside a TLS enabled Connector element in server.xml to enable HTTP/2 support.</li>
* </ul>
*/
@@ -964,7 +964,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
} else if (windowSize < 1) {
/*
* The connection window has no capacity. If the stream has not been granted an allocation, and the
- * stream was not already added to the backlog due to an partial reservation (see next else if
+ * stream was not already added to the backlog due to a partial reservation (see next else if
* block) add it to the backlog so it can obtain an allocation when capacity is available.
*/
if (stream.getConnectionAllocationMade() == 0 && stream.getConnectionAllocationRequested() == 0) {
diff --git a/java/org/apache/coyote/http2/RecycledStream.java b/java/org/apache/coyote/http2/RecycledStream.java
index 54ca63399b..4d0da6c34f 100644
--- a/java/org/apache/coyote/http2/RecycledStream.java
+++ b/java/org/apache/coyote/http2/RecycledStream.java
@@ -55,7 +55,7 @@ class RecycledStream extends AbstractNonZeroStream {
/**
* {@inheritDoc}
* <p>
- * This implementation will return an zero length ByteBuffer to trigger a flow control error if more DATA frame
+ * This implementation will return a zero length ByteBuffer to trigger a flow control error if more DATA frame
* payload than the remaining flow control window is received for this recycled stream.
*/
@Override
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 9170a3ba0e..4ab8733489 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -134,7 +134,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
// HTTP/2 Push or HTTP/1.1 upgrade
/*
* Implementation note. The request passed in is always newly created so it is safe to recycle it for re-use
- * in the Stream.recyle() method. Need to create a matching, new response.
+ * in the Stream.recycle() method. Need to create a matching, new response.
*/
this.coyoteRequest = coyoteRequest;
this.coyoteResponse = new Response();
@@ -326,7 +326,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
log.trace(sm.getString("stream.header.debug", getConnectionId(), getIdAsString(), name, value));
}
- // Header names must be lower case
+ // Header names must be lowercase
if (!name.toLowerCase(Locale.US).equals(name)) {
throw new HpackException(sm.getString("stream.header.case", getConnectionId(), getIdAsString(), name));
}
@@ -1184,8 +1184,8 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
/*
* This method should only be called during blocking I/O. All the Servlet API calls that end up here are
* illegal during non-blocking I/O. Servlet 5.4. However, the wording Servlet specification states that the
- * behaviour is undefined so we do the best we can which is to perform a flush using blocking I/O or
- * non-blocking I/O based depending which is currently in use.
+ * behaviour is undefined so we do the best we can, which is to perform a flush using blocking I/O or
+ * non-blocking I/O based depending on which is currently in use.
*/
flush(getCoyoteResponse().getWriteListener() == null);
}
diff --git a/java/org/apache/coyote/http2/WindowAllocationManager.java b/java/org/apache/coyote/http2/WindowAllocationManager.java
index 811fe1821e..cbe6393564 100644
--- a/java/org/apache/coyote/http2/WindowAllocationManager.java
+++ b/java/org/apache/coyote/http2/WindowAllocationManager.java
@@ -208,7 +208,7 @@ class WindowAllocationManager {
// Reset this here so multiple notifies (possible with a
// backlog containing multiple streams and small window updates)
// are handled correctly (only the first should trigger a call
- // to stream.notify(). Additional notify() calls may trigger
+ // to stream.notify()). Additional notify() calls may trigger
// unexpected timeouts.
waitingFor = NONE;
Response response = stream.getCoyoteResponse();
diff --git a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
index 5aeb701c24..3c7bd215a8 100644
--- a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
+++ b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
@@ -44,7 +44,7 @@ public class MbeansDescriptorsDigesterSource extends ModelerSource
Digester digester = new Digester();
digester.setNamespaceAware(false);
digester.setValidating(false);
- URL url = Registry.getRegistry(null, null).getClass().getResource
+ URL url = Registry.getRegistryNonNull(null, null).getClass().getResource
("/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd");
if (url != null) {
digester.register
@@ -151,7 +151,7 @@ public class MbeansDescriptorsDigesterSource extends ModelerSource
public void execute() throws Exception {
if (registry == null) {
- registry = Registry.getRegistry(null, null);
+ registry = Registry.getRegistryNonNull(null, null);
}
InputStream stream = (InputStream) source;
diff --git a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
index d68767911e..dead9796b8 100644
--- a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
+++ b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
@@ -76,7 +76,7 @@ public class MbeansDescriptorsIntrospectionSource extends ModelerSource
public void execute() throws Exception {
if( registry==null ) {
- registry=Registry.getRegistry(null, null);
+ registry=Registry.getRegistryNonNull(null, null);
}
try {
ManagedBean managed = createManagedBean(registry, null,
diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 769f8bc637..f56f085979 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1320,12 +1320,12 @@ public abstract class AbstractEndpoint<S,U> {
if (this.domain != null) {
// Register endpoint (as ThreadPool - historical name)
oname = new ObjectName(domain + ":type=ThreadPool,name=\"" + getName() + "\"");
- Registry.getRegistry(null, null).registerComponent(this, oname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(this, oname, null);
ObjectName socketPropertiesOname = new ObjectName(domain +
":type=SocketProperties,name=\"" + getName() + "\"");
socketProperties.setObjectName(socketPropertiesOname);
- Registry.getRegistry(null, null).registerComponent(socketProperties, socketPropertiesOname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(socketProperties, socketPropertiesOname, null);
for (SSLHostConfig sslHostConfig : findSslHostConfigs()) {
registerJmx(sslHostConfig);
@@ -1345,7 +1345,7 @@ public abstract class AbstractEndpoint<S,U> {
getName() + "\",name=" + ObjectName.quote(sslHostConfig.getHostName()));
sslHostConfig.setObjectName(sslOname);
try {
- Registry.getRegistry(null, null).registerComponent(sslHostConfig, sslOname, null);
+ Registry.getRegistryNonNull(null, null).registerComponent(sslHostConfig, sslOname, null);
} catch (Exception e) {
getLog().warn(sm.getString("endpoint.jmxRegistrationFailed", sslOname), e);
}
@@ -1363,7 +1363,7 @@ public abstract class AbstractEndpoint<S,U> {
",name=" + sslHostConfigCert.getType());
sslHostConfigCert.setObjectName(sslCertOname);
try {
- Registry.getRegistry(null, null).registerComponent(
+ Registry.getRegistryNonNull(null, null).registerComponent(
sslHostConfigCert, sslCertOname, null);
} catch (Exception e) {
getLog().warn(sm.getString("endpoint.jmxRegistrationFailed", sslCertOname), e);
@@ -1377,7 +1377,7 @@ public abstract class AbstractEndpoint<S,U> {
private void unregisterJmx(SSLHostConfig sslHostConfig) {
- Registry registry = Registry.getRegistry(null, null);
+ Registry registry = Registry.getRegistryNonNull(null, null);
registry.unregisterComponent(sslHostConfig.getObjectName());
for (SSLHostConfigCertificate sslHostConfigCert : sslHostConfig.getCertificates()) {
registry.unregisterComponent(sslHostConfigCert.getObjectName());
@@ -1441,7 +1441,7 @@ public abstract class AbstractEndpoint<S,U> {
unbind();
bindState = BindState.UNBOUND;
}
- Registry registry = Registry.getRegistry(null, null);
+ Registry registry = Registry.getRegistryNonNull(null, null);
registry.unregisterComponent(oname);
registry.unregisterComponent(socketProperties.getObjectName());
for (SSLHostConfig sslHostConfig : findSslHostConfigs()) {
diff --git a/java/org/apache/tomcat/util/security/Escape.java b/java/org/apache/tomcat/util/security/Escape.java
index 753383913f..54e3835cae 100644
--- a/java/org/apache/tomcat/util/security/Escape.java
+++ b/java/org/apache/tomcat/util/security/Escape.java
@@ -86,12 +86,7 @@ public class Escape {
if (obj == null) {
return "?";
}
-
- try {
- return htmlElementContent(obj.toString());
- } catch (Exception e) {
- return null;
- }
+ return htmlElementContent(obj.toString());
}
diff --git a/test/org/apache/catalina/core/TestApplicationFilterConfig.java b/test/org/apache/catalina/core/TestApplicationFilterConfig.java
index 18d31916ea..63f05751b1 100644
--- a/test/org/apache/catalina/core/TestApplicationFilterConfig.java
+++ b/test/org/apache/catalina/core/TestApplicationFilterConfig.java
@@ -53,7 +53,7 @@ public class TestApplicationFilterConfig extends TomcatBaseTest {
tomcat.start();
final MBeanServer mbeanServer =
- Registry.getRegistry(null, null).getMBeanServer();
+ Registry.getRegistryNonNull(null, null).getMBeanServer();
// There should be one Servlet MBean registered
Set<ObjectName> servlets = mbeanServer.queryNames(
diff --git a/test/org/apache/catalina/mbeans/TestRegistration.java b/test/org/apache/catalina/mbeans/TestRegistration.java
index cd7a982124..e5dbb5f7cd 100644
--- a/test/org/apache/catalina/mbeans/TestRegistration.java
+++ b/test/org/apache/catalina/mbeans/TestRegistration.java
@@ -147,7 +147,7 @@ public class TestRegistration extends TomcatBaseTest {
*/
@Test
public void testMBeanDeregistration() throws Exception {
- final MBeanServer mbeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ final MBeanServer mbeanServer = Registry.getRegistryNonNull(null, null).getMBeanServer();
// Verify there are no Catalina or Tomcat MBeans
Set<ObjectName> onames = mbeanServer.queryNames(new ObjectName("Catalina:*"), null);
log.info(MBeanDumper.dumpBeans(mbeanServer, onames));
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org