Skip to content

Commit 53ed9b2

Browse files
committed
added warnings regarding accidental usage of @configurable on a managed bean (SPR-7216)
1 parent 3d3f8f3 commit 53ed9b2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

spring-framework-reference/src/aop.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,16 @@ public class Account {
29592959

29602960
&lt;/bean&gt;</programlisting>
29612961

2962+
<note>
2963+
<para>Do not activate <interfacename>@Configurable</interfacename>
2964+
processing through the bean configurer aspect unless you really
2965+
mean to rely on its semantics at runtime. In particular, make sure
2966+
that you do not use <interfacename>@Configurable</interfacename>
2967+
on bean classes which are registered as regular Spring beans with
2968+
the container: You would get double initialization otherwise, once
2969+
through the container and once through the aspect.</para>
2970+
</note>
2971+
29622972
<section id="aop-configurable-testing">
29632973
<title>Unit testing <interfacename>@Configurable</interfacename>
29642974
objects</title>

spring-framework-reference/src/scheduling.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,17 @@ public void doSomething() {
553553
and must not expect any arguments. If the method needs to interact with
554554
other objects from the Application Context, then those would typically
555555
have been provided through dependency injection.</para>
556+
557+
<note>
558+
<para>Make sure that you are not initializing multiple instances
559+
of the same @Scheduled annotation class at runtime, unless you do
560+
want to schedule callbacks to each such instance. Related to this,
561+
make sure that you do not use @Configurable on bean classes which
562+
are annotated with @Scheduled and registered as regular Spring beans
563+
with the container: You would get double initialization otherwise,
564+
once through the container and once through the @Configurable aspect,
565+
with the consequence of each @Scheduled method being invoked twice.</para>
566+
</note>
556567
</section>
557568

558569
<section id="scheduling-annotation-support-async">

0 commit comments

Comments
 (0)