This is an automated email from the ASF dual-hosted git repository.
lihan 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 d41f3d03d8 Polish
d41f3d03d8 is described below
commit d41f3d03d86bde44d0180d67a713dfa774c69a92
Author: lihan <[email protected]>
AuthorDate: Fri Apr 28 10:57:48 2023 +0800
Polish
---
java/org/apache/catalina/core/ContainerBase.java | 18 +++++++--------
java/org/apache/catalina/core/StandardServer.java | 26 +++++++++-------------
.../apache/catalina/valves/JsonAccessLogValve.java | 2 +-
3 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/java/org/apache/catalina/core/ContainerBase.java
b/java/org/apache/catalina/core/ContainerBase.java
index 5275310ec8..7c96f5de5e 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -400,7 +400,7 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
this.cluster = cluster;
// Stop the old component if necessary
- if (getState().isAvailable() && (oldCluster != null) &&
(oldCluster instanceof Lifecycle)) {
+ if (getState().isAvailable() && (oldCluster instanceof Lifecycle))
{
try {
((Lifecycle) oldCluster).stop();
} catch (LifecycleException e) {
@@ -413,7 +413,7 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
cluster.setContainer(this);
}
- if (getState().isAvailable() && (cluster != null) && (cluster
instanceof Lifecycle)) {
+ if (getState().isAvailable() && (cluster instanceof Lifecycle)) {
try {
((Lifecycle) cluster).start();
} catch (LifecycleException e) {
@@ -603,7 +603,7 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
this.realm = realm;
// Stop the old component if necessary
- if (getState().isAvailable() && (oldRealm != null) && (oldRealm
instanceof Lifecycle)) {
+ if (getState().isAvailable() && (oldRealm instanceof Lifecycle)) {
try {
((Lifecycle) oldRealm).stop();
} catch (LifecycleException e) {
@@ -615,7 +615,7 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
if (realm != null) {
realm.setContainer(this);
}
- if (getState().isAvailable() && (realm != null) && (realm
instanceof Lifecycle)) {
+ if (getState().isAvailable() && (realm instanceof Lifecycle)) {
try {
((Lifecycle) realm).start();
} catch (LifecycleException e) {
@@ -865,8 +865,8 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
}
// Start our child containers, if any
- Container children[] = findChildren();
- List<Future<Void>> results = new ArrayList<>();
+ Container[] children = findChildren();
+ List<Future<Void>> results = new ArrayList<>(children.length);
for (Container child : children) {
results.add(startStopExecutor.submit(new StartChild(child)));
}
@@ -930,8 +930,8 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
}
// Stop our child containers, if any
- Container children[] = findChildren();
- List<Future<Void>> results = new ArrayList<>();
+ Container[] children = findChildren();
+ List<Future<Void>> results = new ArrayList<>(children.length);
for (Container child : children) {
results.add(startStopExecutor.submit(new StopChild(child)));
}
@@ -1025,7 +1025,7 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
}
AccessLogAdapter adapter = null;
- Valve valves[] = getPipeline().getValves();
+ Valve[] valves = getPipeline().getValves();
for (Valve valve : valves) {
if (valve instanceof AccessLog) {
if (adapter == null) {
diff --git a/java/org/apache/catalina/core/StandardServer.java
b/java/org/apache/catalina/core/StandardServer.java
index 9c6f4b2173..5f4637153b 100644
--- a/java/org/apache/catalina/core/StandardServer.java
+++ b/java/org/apache/catalina/core/StandardServer.java
@@ -136,7 +136,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
/**
* The set of Services associated with this Server.
*/
- private Service services[] = new Service[0];
+ private Service[] services = new Service[0];
private final Object servicesLock = new Object();
@@ -176,12 +176,12 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
/**
* The number of threads available to process utility tasks in this
service.
*/
- protected int utilityThreads = 2;
+ private int utilityThreads = 2;
/**
* The utility threads daemon flag.
*/
- protected boolean utilityThreadsAsDaemon = false;
+ private boolean utilityThreadsAsDaemon = false;
/**
* Utility executor with scheduling capabilities.
@@ -205,7 +205,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
/**
* The lifecycle event period in seconds.
*/
- protected int periodicEventDelay = 10;
+ private int periodicEventDelay = 10;
// ------------------------------------------------------------- Properties
@@ -700,7 +700,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
/**
- * @return the set of Services defined within this Server.
+ * @return The array of Services defined within this Server.
*/
@Override
public Service[] findServices() {
@@ -711,7 +711,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
* @return the JMX service names.
*/
public ObjectName[] getServiceNames() {
- ObjectName onames[] = new ObjectName[services.length];
+ ObjectName[] onames = new ObjectName[services.length];
for (int i = 0; i < services.length; i++) {
onames[i] = ((StandardService) services[i]).getObjectName();
}
@@ -744,7 +744,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
// Ignore
}
int k = 0;
- Service results[] = new Service[services.length - 1];
+ Service[] results = new Service[services.length - 1];
for (int i = 0; i < services.length; i++) {
if (i != j) {
results[k++] = services[i];
@@ -819,10 +819,7 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
*/
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("StandardServer[");
- sb.append(getPort());
- sb.append(']');
- return sb.toString();
+ return "StandardServer[" + getPort() + ']';
}
@@ -915,15 +912,14 @@ public final class StandardServer extends
LifecycleMBeanBase implements Server {
}
if (periodicEventDelay > 0) {
- monitorFuture = getUtilityExecutor().scheduleWithFixedDelay(() ->
startPeriodicLifecycleEvent(), 0, 60,
+ monitorFuture =
getUtilityExecutor().scheduleWithFixedDelay(this::startPeriodicLifecycleEvent,
0, 60,
TimeUnit.SECONDS);
}
}
- protected void startPeriodicLifecycleEvent() {
- if (periodicLifecycleEventFuture == null ||
- (periodicLifecycleEventFuture != null &&
periodicLifecycleEventFuture.isDone())) {
+ private void startPeriodicLifecycleEvent() {
+ if (periodicLifecycleEventFuture == null ||
periodicLifecycleEventFuture.isDone()) {
if (periodicLifecycleEventFuture != null &&
periodicLifecycleEventFuture.isDone()) {
// There was an error executing the scheduled task, get it and
log it
try {
diff --git a/java/org/apache/catalina/valves/JsonAccessLogValve.java
b/java/org/apache/catalina/valves/JsonAccessLogValve.java
index f6162c8d70..d69f43156c 100644
--- a/java/org/apache/catalina/valves/JsonAccessLogValve.java
+++ b/java/org/apache/catalina/valves/JsonAccessLogValve.java
@@ -199,7 +199,7 @@ public class JsonAccessLogValve extends AccessLogValve {
} else {
lit.add(new CharElement('}'));
}
- return logElements.toArray(new AccessLogElement[logElements.size()]);
+ return logElements.toArray(new AccessLogElement[0]);
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]