Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerjung committed Apr 28, 2023
2 parents 9d2ec8c + fa0b2b1 commit c658727
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
18 changes: 9 additions & 9 deletions java/org/apache/catalina/core/ContainerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void setCluster(Cluster cluster) {
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) {
Expand All @@ -390,7 +390,7 @@ public void setCluster(Cluster cluster) {
cluster.setContainer(this);
}

if (getState().isAvailable() && (cluster != null) && (cluster instanceof Lifecycle)) {
if (getState().isAvailable() && (cluster instanceof Lifecycle)) {
try {
((Lifecycle) cluster).start();
} catch (LifecycleException e) {
Expand Down Expand Up @@ -580,7 +580,7 @@ public void setRealm(Realm realm) {
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) {
Expand All @@ -592,7 +592,7 @@ public void setRealm(Realm realm) {
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) {
Expand Down Expand Up @@ -832,8 +832,8 @@ protected synchronized void startInternal() throws LifecycleException {
}

// 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)));
}
Expand Down Expand Up @@ -897,8 +897,8 @@ protected synchronized void stopInternal() throws LifecycleException {
}

// 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)));
}
Expand Down Expand Up @@ -992,7 +992,7 @@ public AccessLog getAccessLog() {
}

AccessLogAdapter adapter = null;
Valve valves[] = getPipeline().getValves();
Valve[] valves = getPipeline().getValves();
for (Valve valve : valves) {
if (valve instanceof AccessLog) {
if (adapter == null) {
Expand Down
26 changes: 11 additions & 15 deletions java/org/apache/catalina/core/StandardServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public StandardServer() {
/**
* 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();


Expand Down Expand Up @@ -175,12 +175,12 @@ public StandardServer() {
/**
* 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.
Expand All @@ -204,7 +204,7 @@ public StandardServer() {
/**
* The lifecycle event period in seconds.
*/
protected int periodicEventDelay = 10;
private int periodicEventDelay = 10;


// ------------------------------------------------------------- Properties
Expand Down Expand Up @@ -696,7 +696,7 @@ public Service findService(String name) {


/**
* @return the set of Services defined within this Server.
* @return The array of Services defined within this Server.
*/
@Override
public Service[] findServices() {
Expand All @@ -707,7 +707,7 @@ public Service[] findServices() {
* @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();
}
Expand Down Expand Up @@ -740,7 +740,7 @@ public void removeService(Service service) {
// 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];
Expand Down Expand Up @@ -815,10 +815,7 @@ public void removePropertyChangeListener(PropertyChangeListener listener) {
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder("StandardServer[");
sb.append(getPort());
sb.append(']');
return sb.toString();
return "StandardServer[" + getPort() + ']';
}


Expand Down Expand Up @@ -911,15 +908,14 @@ protected void startInternal() throws LifecycleException {
}

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 {
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/valves/JsonAccessLogValve.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected AccessLogElement[] createLogElements() {
} else {
lit.add(new CharElement('}'));
}
return logElements.toArray(new AccessLogElement[logElements.size()]);
return logElements.toArray(new AccessLogElement[0]);
}

@Override
Expand Down

0 comments on commit c658727

Please sign in to comment.