Skip to content

Commit a35adc6

Browse files
stsypanovsbrannen
authored andcommitted
Add missing break statements to stop looping when result is known
Closes gh-22573
1 parent 96cd441 commit a35adc6

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ class ExtendedTestBean extends TestBean {
754754
for (PropertyDescriptor pd : ebi.getPropertyDescriptors()) {
755755
if (pd.getName().equals("foo")) {
756756
found = true;
757+
break;
757758
}
758759
}
759760
assertThat(found, is(true));

spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>...
151151
if (script instanceof Class ? !requestedIfc.isAssignableFrom((Class<?>) script) :
152152
!requestedIfc.isInstance(script)) {
153153
adaptationRequired = true;
154+
break;
154155
}
155156
}
156157
if (adaptationRequired) {

spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void classpathStarWithPatternOnFileSystem() throws IOException {
8989
noCloverResources.add(resource);
9090
}
9191
}
92-
resources = noCloverResources.toArray(new Resource[noCloverResources.size()]);
92+
resources = noCloverResources.toArray(new Resource[0]);
9393
assertProtocolAndFilenames(resources, "file",
9494
StringUtils.concatenateStringArrays(CLASSES_IN_CORE_IO_SUPPORT, TEST_CLASSES_IN_CORE_IO_SUPPORT));
9595
}
@@ -113,6 +113,7 @@ public void rootPatternRetrievalInJarFiles() throws IOException {
113113
for (Resource resource : resources) {
114114
if (resource.getFilename().equals("aspectj_1_5_0.dtd")) {
115115
found = true;
116+
break;
116117
}
117118
}
118119
assertTrue("Could not find aspectj_1_5_0.dtd in the root of the aspectjweaver jar", found);

0 commit comments

Comments
 (0)