Chris Dutrow
Chris Dutrow

Reputation: 50362

ThreadLocal on Google App Engine (GAE)

I would like to make some request-wide data available in my app engine application.

Examples:

I see that ThreadLocal is on GAE's JRE whitelist.

Is ThreadLocala good and safe way to make this information available? Are there alternative / better / more accepted ways?

Upvotes: 5

Views: 1352

Answers (1)

Bozho
Bozho

Reputation: 597124

Yes, it is an accepted practice to store these things in a ThreadLocal. However, a more preferable approach is to pass these values around (as method arguments) wherever they are needed, instead of reaching for them. It's more preferable, because it's more testable at least.

Upvotes: 8

Related Questions