mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
fix re registration of BootstrapContextFilter after restart
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user