Skip to content

Commit 2f9ad87

Browse files
author
Vincent Potucek
committed
Fix unused assignment: the value changed at constructorArgNum++ is never used
1 parent 764d35c commit 2f9ad87

File tree

3 files changed

+360
-7
lines changed

3 files changed

+360
-7
lines changed

spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import org.springframework.util.StringUtils;
3535
import org.springframework.util.xml.DomUtils;
3636

37+
import static org.springframework.util.StringUtils.hasLength;
38+
3739
/**
3840
* BeanDefinitionParser implementation for the '{@code <lang:groovy/>}',
3941
* '{@code <lang:std/>}' and '{@code <lang:bsh/>}' tags.
@@ -125,7 +127,7 @@ public ScriptBeanDefinitionParser(String scriptFactoryClassName) {
125127

126128
// Determine bean scope.
127129
String scope = element.getAttribute(SCOPE_ATTRIBUTE);
128-
if (StringUtils.hasLength(scope)) {
130+
if (hasLength(scope)) {
129131
bd.setScope(scope);
130132
}
131133

@@ -143,7 +145,7 @@ else if (autowireMode == AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR) {
143145

144146
// Parse depends-on list of bean names.
145147
String dependsOn = element.getAttribute(DEPENDS_ON_ATTRIBUTE);
146-
if (StringUtils.hasLength(dependsOn)) {
148+
if (hasLength(dependsOn)) {
147149
bd.setDependsOn(StringUtils.tokenizeToStringArray(
148150
dependsOn, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS));
149151
}
@@ -153,7 +155,7 @@ else if (autowireMode == AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR) {
153155

154156
// Determine init method and destroy method.
155157
String initMethod = element.getAttribute(INIT_METHOD_ATTRIBUTE);
156-
if (StringUtils.hasLength(initMethod)) {
158+
if (hasLength(initMethod)) {
157159
bd.setInitMethodName(initMethod);
158160
}
159161
else if (beanDefinitionDefaults.getInitMethodName() != null) {
@@ -183,7 +185,7 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
183185
// Add constructor arguments.
184186
ConstructorArgumentValues cav = bd.getConstructorArgumentValues();
185187
int constructorArgNum = 0;
186-
if (StringUtils.hasLength(engine)) {
188+
if (hasLength(engine)) {
187189
cav.addIndexedArgumentValue(constructorArgNum++, engine);
188190
}
189191
cav.addIndexedArgumentValue(constructorArgNum++, value);
@@ -194,12 +196,11 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
194196

195197
// This is used for Groovy. It's a bean reference to a customizer bean.
196198
if (element.hasAttribute(CUSTOMIZER_REF_ATTRIBUTE)) {
197-
String customizerBeanName = element.getAttribute(CUSTOMIZER_REF_ATTRIBUTE);
198-
if (!StringUtils.hasText(customizerBeanName)) {
199+
if (!StringUtils.hasText(element.getAttribute(CUSTOMIZER_REF_ATTRIBUTE))) {
199200
parserContext.getReaderContext().error("Attribute 'customizer-ref' has empty value", element);
200201
}
201202
else {
202-
cav.addIndexedArgumentValue(constructorArgNum++, new RuntimeBeanReference(customizerBeanName));
203+
cav.addIndexedArgumentValue(constructorArgNum , new RuntimeBeanReference(element.getAttribute(CUSTOMIZER_REF_ATTRIBUTE)));
203204
}
204205
}
205206

0 commit comments

Comments
 (0)