Skip to content

Commit

Permalink
MODCLUSTER-790 mod_cluster listener throws NPE when deploying a conte…
Browse files Browse the repository at this point in the history
…xt in Tomcat
  • Loading branch information
rhusar committed Jul 25, 2023
1 parent 4d2dc2a commit 1a96bf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public interface Context {
*/
boolean isStarted();

/**
* Returns whether this context is suspended. A suspended context is not available for processing requests,
* but it could be made available at later time. This translates into the context be made known to reverse proxies
* but in a stopped state. Implementing this method is optional defaulting to suspended mode not being supported
* by the container.
*
* @return whether this context is suspended
*/
default boolean isSuspended() {
return false;
}

/**
* Registers the specified request listener with this context. Used for request draining.
*
Expand Down
14 changes: 9 additions & 5 deletions core/src/main/java/org/jboss/modcluster/ModClusterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,15 @@ public void add(Context context) {
ModClusterLogger.LOGGER.addContext(context.getHost(), context);

if (this.include(context) && this.established) {
// Send ENABLE-APP if state is started
if (context.isStarted()) {
this.enable(context);
} else {
if (context.isSuspended()) {
// Send STOP-APP if the context is suspended
this.stop(context);
} else if (context.isStarted()) {
// Send ENABLE-APP if state is started

// n.b. for some containers like Tomcat, the context at this point is only in the 'STARTING' state and
// thus enable(..) will not be called here but rather during a start(..) call.
this.enable(context);
}
}
}
Expand All @@ -313,7 +317,7 @@ public void add(Context context) {
public void start(Context context) {
ModClusterLogger.LOGGER.startContext(context.getHost(), context);

if (this.include(context)) {
if (this.include(context) && !context.isSuspended()) {
if (this.established) {
this.enable(context);
}
Expand Down

0 comments on commit 1a96bf2

Please sign in to comment.