Atlassian Cache crashes Confluence/Jira upon app disable

can we have recommendations for all of the variations of ways to import CacheManager in a plugin?

Sorry if this thread has been confusing. Let me summarise the implications of CACHE-240 for importing the CacheManager service from OSGi:

  1. If you import it via an <component-import> element in atlassian-plugin.xml, you’re safe.
  2. If you import it via Spring Scanner’s @ComponentImport annotation, you’re safe.
  3. If you import it via Spring Java Config, then you need to use @Bean(destroyMethod="") instead of just @Bean in your configuration class, otherwise your app will shut down the imported CacheManager if your app is ever disabled or uninstalled.

Unfortunately there’s no way to make CacheManager unconditionally “safe” for apps to use, because it needs to have the “dangerous” shutdown method so that the product can legitimately shut it down. The CacheFactory API was explicitly designed to be the safe way for apps to create a cache. It’s regrettable that Confluence app developers have no choice but to use CacheManager (noting that they can use the fix described above). As far as I know, apps for other products can quite happily use CacheFactory. So to put this problem in perspective, CACHE-240 only affects apps that run in Confluence AND use Spring Java Config (and for that edge case, use the above workaround).

Changing the public API isn’t an option, that’s a recipe for trouble. The workaround described above will need to be used until Confluence provides a CacheFactory implementation that’s suitable for apps to use (and updates their doco accordingly). Let me repeat that this only relates to a tiny fraction of apps, noting that we only announced Spring Java Config late last year.

4 Likes