Skip to content

Commit fbadfb9

Browse files
DI improvement
1 parent d440c3c commit fbadfb9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/java/org/codehaus/groovy/grails/web/plugins/support/WebMetaUtils.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ class WebMetaUtils {
9999
}
100100
}
101101

102+
def newCommandObject = false
102103
if (!commandObject) {
103104
commandObject = paramType.newInstance()
104-
ctx.autowireCapableBeanFactory?.autowireBeanProperties(
105-
commandObject, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false)
105+
newCommandObject = true
106106
commandObjects << commandObject
107107
}
108108

@@ -121,6 +121,11 @@ class WebMetaUtils {
121121
constrainedProperty.getPropertyName()), errors)
122122
}
123123
commandObject.errors = errors
124+
125+
if(newCommandObject) {
126+
ctx.autowireCapableBeanFactory?.autowireBeanProperties(
127+
commandObject, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false)
128+
}
124129
}
125130
catch (Exception e) {
126131
throw new ControllerExecutionException("Error occurred creating command object.", e)

0 commit comments

Comments
 (0)