I found, that in some situations, bean methods of annotated string configuration is called multiple times, although they should be cached.
How can it be happen?
Being inside one of such method, how can I indentify different nature of calls? May be classloaders or something?
UDPATE
I have checked instance ids of all calls and it appeared the same.
UPDATE 2
code is something like this
@Configuration
class Config {
@Bean
MyBean1 myBean1() {
....
// I don't see explicit call for myBean2() here
}
@Bean
MyBean2 myBean2() {
....
// I have explicit call for myBean1() here
}
}
the problem is that this config works in one environment. But in other environment is happening something strange, including interleaved inifinite calls of these two methods. Probably some error occurs, which causes mutual initialization, which is not happening in first environment.
Also I observe tremendous Spring exception sayin "unable to instantiate myBean1 because was unable to instantiate myBean2 because was unable to instantiate myBean1 ...." and so on, endless! I didn't find the end at least.
Usually I had Spring detecting initialization loops, but here I see it can't by some reason.