sling-org-apache-sling-models-impl icon indicating copy to clipboard operation
sling-org-apache-sling-models-impl copied to clipboard

SLING-12376 : Use per thread resource resolver for disposable callbacks

Open cziegeler opened this issue 1 year ago • 6 comments

Instead of using different approaches (request attribute and phantom reference queue), we can use the thread resource resolver and store the disposables in the properties map of the resource resolver. When the resource resolver is closed, it closes all Closeable objects in the properties map With that we can remove the different cases, queue handling, and scheduling.

In addition I removed the anti pattern of registering services during activate

cziegeler avatar Jul 11 '24 07:07 cziegeler

what happens if sling models is used outside a request context, e.g. in a background job with a resource resolver created via getServiceResourceResolver?

stefanseifert avatar Jul 11 '24 07:07 stefanseifert

Then this code blows up with a NullPointerException...the same is true when using an administrative resource resolver

cziegeler avatar Jul 11 '24 07:07 cziegeler

it's a valid use case, although probably rare, to use sling models outside a request...

stefanseifert avatar Jul 11 '24 08:07 stefanseifert

not disagreeing, lets see if we can come up with something that is better than the previous solution

cziegeler avatar Jul 11 '24 08:07 cziegeler

Quality Gate Failed Quality Gate failed

Failed conditions
78.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jul 13 '24 11:07 sonarqubecloud[bot]

Quality Gate Failed Quality Gate failed

Failed conditions
78.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Nov 04 '24 20:11 sonarqubecloud[bot]