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 { public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig; this.filterConfig = filterConfig;
initGuice(); initializeContext();
}
private void initializeContext() throws ServletException {
super.init(filterConfig);
LOG.info("register for restart events"); LOG.info("register for restart events");
ScmEventBus.getInstance().register(this); ScmEventBus.getInstance().register(this);
}
private void initGuice() throws ServletException {
super.init(filterConfig);
listener.contextInitialized(new ServletContextEvent(filterConfig.getServletContext())); listener.contextInitialized(new ServletContextEvent(filterConfig.getServletContext()));
} }
@@ -80,6 +80,7 @@ public class BootstrapContextFilter extends GuiceFilter {
@Override @Override
public void destroy() { public void destroy() {
super.destroy(); super.destroy();
listener.contextDestroyed(new ServletContextEvent(filterConfig.getServletContext())); listener.contextDestroyed(new ServletContextEvent(filterConfig.getServletContext()));
ServletContextCleaner.cleanup(filterConfig.getServletContext()); ServletContextCleaner.cleanup(filterConfig.getServletContext());
} }
@@ -107,7 +108,7 @@ public class BootstrapContextFilter extends GuiceFilter {
@Override @Override
public void initialize() { public void initialize() {
try { try {
BootstrapContextFilter.this.initGuice(); BootstrapContextFilter.this.initializeContext();
} catch (ServletException e) { } catch (ServletException e) {
throw new IllegalStateException("failed to initialize guice", 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"); LOG.warn("reinitialize injection context");
context.initialize(); context.initialize();
LOG.debug("re register injection context for events"); LOG.debug("register injection context on new eventbus");
ScmEventBus.getInstance().register(context); ScmEventBus.getInstance().register(context);
} catch ( Exception ex) { } catch ( Exception ex) {
LOG.error("failed to restart", ex); LOG.error("failed to restart", ex);

View File

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