Skip to content

Commit 2ff2251

Browse files
committed
Avoid earlyApplicationEvents iteration in case of empty Set
Closes gh-25161
1 parent ef626e9 commit 2ff2251

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -79,6 +79,7 @@
7979
import org.springframework.core.io.support.ResourcePatternResolver;
8080
import org.springframework.lang.Nullable;
8181
import org.springframework.util.Assert;
82+
import org.springframework.util.CollectionUtils;
8283
import org.springframework.util.ObjectUtils;
8384
import org.springframework.util.ReflectionUtils;
8485

@@ -836,7 +837,7 @@ protected void registerListeners() {
836837
// Publish early application events now that we finally have a multicaster...
837838
Set<ApplicationEvent> earlyEventsToProcess = this.earlyApplicationEvents;
838839
this.earlyApplicationEvents = null;
839-
if (earlyEventsToProcess != null) {
840+
if (!CollectionUtils.isEmpty(earlyEventsToProcess)) {
840841
for (ApplicationEvent earlyEvent : earlyEventsToProcess) {
841842
getApplicationEventMulticaster().multicastEvent(earlyEvent);
842843
}

0 commit comments

Comments
 (0)