Skip to content

Commit a848628

Browse files
committed
Fix possible NPEs
1 parent df8999e commit a848628

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

java/org/apache/catalina/ha/tcp/ReplicationValve.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ public long getTotalSendTime() {
298298
// --------------------------------------------------------- Public Methods
299299

300300
/**
301-
* Register a cross-context session for replication. The session is added to
302-
* the current thread's cross-context session list if it is not already present.
301+
* Register a cross-context session for replication. The session is added to the current thread's cross-context
302+
* session list if it is not already present.
303303
*
304304
* @param session the cross-context session to register
305305
*/
@@ -398,10 +398,10 @@ protected void startInternal() throws LifecycleException {
398398
/**
399399
* Send a replication message for the given request.
400400
*
401-
* @param request the request
402-
* @param totalstart the start time
401+
* @param request the request
402+
* @param totalstart the start time
403403
* @param isCrossContext {@code true} if cross-context
404-
* @param isAsync {@code true} if async
404+
* @param isAsync {@code true} if async
405405
* @param clusterManager the cluster manager
406406
*/
407407
protected void sendReplicationMessage(Request request, long totalstart, boolean isCrossContext, boolean isAsync,
@@ -618,16 +618,19 @@ protected void createPrimaryIndicator(Request request) throws IOException {
618618
}
619619
if (session instanceof ClusterSession cses) {
620620
if (log.isDebugEnabled()) {
621-
log.debug(sm.getString("ReplicationValve.session.indicator", request.getContext().getName(), id,
622-
primaryIndicatorName, Boolean.valueOf(cses.isPrimarySession())));
621+
log.debug(sm.getString("ReplicationValve.session.indicator",
622+
ctx == null ? "null Context" : ctx.getPath(), id, primaryIndicatorName,
623+
Boolean.valueOf(cses.isPrimarySession())));
623624
}
624625
request.setAttribute(primaryIndicatorName, cses.isPrimarySession() ? Boolean.TRUE : Boolean.FALSE);
625626
} else {
626627
if (log.isDebugEnabled()) {
627628
if (session != null) {
628-
log.debug(sm.getString("ReplicationValve.session.found", request.getContext().getName(), id));
629+
log.debug(sm.getString("ReplicationValve.session.found",
630+
ctx == null ? "null Context" : ctx.getPath(), id));
629631
} else {
630-
log.debug(sm.getString("ReplicationValve.session.invalid", request.getContext().getName(), id));
632+
log.debug(sm.getString("ReplicationValve.session.invalid",
633+
ctx == null ? "null Context" : ctx.getPath(), id));
631634
}
632635
}
633636
}

0 commit comments

Comments
 (0)