@@ -209,6 +209,9 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
209
209
/** Should we dispatch an HTTP TRACE request to {@link #doService}?. */
210
210
private boolean dispatchTraceRequest = false ;
211
211
212
+ /** Whether to log potentially sensitive info (request params at DEBUG + headers at TRACE). */
213
+ private boolean enableLoggingRequestDetails = false ;
214
+
212
215
/** WebApplicationContext for this servlet. */
213
216
@ Nullable
214
217
private WebApplicationContext webApplicationContext ;
@@ -217,10 +220,10 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
217
220
private boolean webApplicationContextInjected = false ;
218
221
219
222
/** Flag used to detect whether onRefresh has already been called. */
220
- private boolean refreshEventReceived = false ;
223
+ private volatile boolean refreshEventReceived = false ;
221
224
222
- /** Whether to log potentially sensitive info (request params at DEBUG + headers at TRACE) . */
223
- private boolean enableLoggingRequestDetails = false ;
225
+ /** Monitor for synchronized onRefresh execution . */
226
+ private final Object onRefreshMonitor = new Object () ;
224
227
225
228
226
229
/**
@@ -591,7 +594,9 @@ protected WebApplicationContext initWebApplicationContext() {
591
594
// Either the context is not a ConfigurableApplicationContext with refresh
592
595
// support or the context injected at construction time had already been
593
596
// refreshed -> trigger initial onRefresh manually here.
594
- onRefresh (wac );
597
+ synchronized (this .onRefreshMonitor ) {
598
+ onRefresh (wac );
599
+ }
595
600
}
596
601
597
602
if (this .publishContext ) {
@@ -832,7 +837,9 @@ public void refresh() {
832
837
*/
833
838
public void onApplicationEvent (ContextRefreshedEvent event ) {
834
839
this .refreshEventReceived = true ;
835
- onRefresh (event .getApplicationContext ());
840
+ synchronized (this .onRefreshMonitor ) {
841
+ onRefresh (event .getApplicationContext ());
842
+ }
836
843
}
837
844
838
845
/**
0 commit comments