From a35adc6ea651d82fed1458bab745f3201922c6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 12 Mar 2019 14:15:59 +0200 Subject: [PATCH] Add missing break statements to stop looping when result is known Closes gh-22573 --- .../java/org/springframework/beans/ExtendedBeanInfoTests.java | 1 + .../scripting/support/StandardScriptFactory.java | 1 + .../io/support/PathMatchingResourcePatternResolverTests.java | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index 03f671da99..592a29e435 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -754,6 +754,7 @@ public class ExtendedBeanInfoTests { for (PropertyDescriptor pd : ebi.getPropertyDescriptors()) { if (pd.getName().equals("foo")) { found = true; + break; } } assertThat(found, is(true)); diff --git a/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java b/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java index 4c684b35b6..a8414d9ea5 100644 --- a/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java +++ b/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java @@ -151,6 +151,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar if (script instanceof Class ? !requestedIfc.isAssignableFrom((Class) script) : !requestedIfc.isInstance(script)) { adaptationRequired = true; + break; } } if (adaptationRequired) { diff --git a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java index 4e6237eae6..a10f4cb215 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java @@ -89,7 +89,7 @@ public class PathMatchingResourcePatternResolverTests { noCloverResources.add(resource); } } - resources = noCloverResources.toArray(new Resource[noCloverResources.size()]); + resources = noCloverResources.toArray(new Resource[0]); assertProtocolAndFilenames(resources, "file", StringUtils.concatenateStringArrays(CLASSES_IN_CORE_IO_SUPPORT, TEST_CLASSES_IN_CORE_IO_SUPPORT)); } @@ -113,6 +113,7 @@ public class PathMatchingResourcePatternResolverTests { for (Resource resource : resources) { if (resource.getFilename().equals("aspectj_1_5_0.dtd")) { found = true; + break; } } assertTrue("Could not find aspectj_1_5_0.dtd in the root of the aspectjweaver jar", found);