fix re registration of BootstrapContextFilter after restart

This commit is contained in:
Sebastian Sdorra
2019-06-20 14:58:32 +02:00
parent cbe983b9f1
commit d658a1a662
3 changed files with 8 additions and 8 deletions

View File

@@ -65,14 +65,14 @@ public class BootstrapContextFilter extends GuiceFilter {
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
initGuice();
initializeContext();
}
private void initializeContext() throws ServletException {
super.init(filterConfig);
LOG.info("register for restart events");
ScmEventBus.getInstance().register(this);
}
private void initGuice() throws ServletException {
super.init(filterConfig);
listener.contextInitialized(new ServletContextEvent(filterConfig.getServletContext()));
}
@@ -80,6 +80,7 @@ public class BootstrapContextFilter extends GuiceFilter {
@Override
public void destroy() {
super.destroy();
listener.contextDestroyed(new ServletContextEvent(filterConfig.getServletContext()));
ServletContextCleaner.cleanup(filterConfig.getServletContext());
}
@@ -107,7 +108,7 @@ public class BootstrapContextFilter extends GuiceFilter {
@Override
public void initialize() {
try {
BootstrapContextFilter.this.initGuice();
BootstrapContextFilter.this.initializeContext();
} catch (ServletException e) {
throw new IllegalStateException("failed to initialize guice", e);
}

View File

@@ -39,7 +39,7 @@ public class InjectionContextRestartStrategy implements RestartStrategy {
LOG.warn("reinitialize injection context");
context.initialize();
LOG.debug("re register injection context for events");
LOG.debug("register injection context on new eventbus");
ScmEventBus.getInstance().register(context);
} catch ( Exception ex) {
LOG.error("failed to restart", ex);

View File

@@ -1,7 +1,6 @@
package sonia.scm.boot;
import com.github.legman.Subscribe;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;