Skip to content

Commit f783967

Browse files
committed
Don't set role in Kotlin bean DSL unless specified
Issue: SPR-17275
1 parent 47d6e91 commit f783967

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
172172
initMethodName: String? = null,
173173
destroyMethodName: String? = null,
174174
description: String? = null,
175-
role: Role = Role.APPLICATION) {
175+
role: Role? = null) {
176176

177177
val customizer = BeanDefinitionCustomizer { bd ->
178178
scope?.let { bd.scope = scope.name.toLowerCase() }
@@ -182,7 +182,7 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
182182
initMethodName?.let { bd.initMethodName = initMethodName }
183183
destroyMethodName?.let { bd.destroyMethodName = destroyMethodName }
184184
description?.let { bd.description = description }
185-
bd.role = role.ordinal
185+
role?. let { bd.role = role.ordinal }
186186
}
187187

188188
val beanName = name ?: BeanDefinitionReaderUtils.uniqueBeanName(T::class.java.name, context);
@@ -214,7 +214,7 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
214214
initMethodName: String? = null,
215215
destroyMethodName: String? = null,
216216
description: String? = null,
217-
role: Role = Role.APPLICATION,
217+
role: Role? = null,
218218
crossinline function: () -> T) {
219219

220220
val customizer = BeanDefinitionCustomizer { bd ->
@@ -225,7 +225,7 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
225225
initMethodName?.let { bd.initMethodName = initMethodName }
226226
destroyMethodName?.let { bd.destroyMethodName = destroyMethodName }
227227
description?.let { bd.description = description }
228-
bd.role = role.ordinal
228+
role?. let { bd.role = role.ordinal }
229229
}
230230

231231

0 commit comments

Comments
 (0)