smallrye-context-propagation icon indicating copy to clipboard operation
smallrye-context-propagation copied to clipboard

Add sys property to control how to cleanup context's ThreadLocal (Fixes #424)

Open franz1981 opened this issue 2 years ago • 5 comments

As explained in #424 this is added to control how to cleanup the context, but:

  • I have no idea if the initial ThreadLocal have some initialization lambdas: if yes, then set(null) and remove would behave differently because a subsequent get in the former case would return null while in the latter will cause the init lambda to be called again
  • what about clearedValue? I should set to that value instead of null?

franz1981 avatar Jun 20 '23 09:06 franz1981

https://github.com/Sanne/quarkus/commit/75e2d7e4b22ae72c1fa4f1ae51779488843e0f21 is a PoC branch that show how that can be used

@geoand

franz1981 avatar Jun 20 '23 09:06 franz1981

I think it makes sense.

geoand avatar Jun 20 '23 09:06 geoand

This is only for the TL we use to override settings locally. I don't think most people use this API. If you want to clear the TL for libs (CDI, Security, Transaction) you need to do it in the respective ThreadLocalProvider implementations. Of which there are many, honestly I've lost track.

FroMage avatar Jun 20 '23 13:06 FroMage

Yeah, we'll have to do the same in the providers we use in Quarkus

geoand avatar Jun 20 '23 13:06 geoand

I am also wondering whether we should have a way to have Quarkus pass this to CP when it bootstraps it

geoand avatar Jun 20 '23 13:06 geoand