Skip to content

FELIX-6817 Find no resources in a closed bundle revision - #577

Open
sharanggupta wants to merge 1 commit into
apache:masterfrom
sharanggupta:FELIX-6817-closed-revision-resource
Open

sharanggupta wants to merge 1 commit into
apache:masterfrom
sharanggupta:FELIX-6817-closed-revision-resource

Conversation

@sharanggupta

Copy link
Copy Markdown
Contributor

Fixes FELIX-6817.

The NullPointerException in the report (Content.hasEntry(String) called on a null element of the content path, from BundleRevisionImpl.getResourceLocal) happens when a resource lookup through the class loader of a wiring reaches the revision after a refresh has closed it.

BundleWiringImpl.findClassOrResourceByDelegation() checks that the wiring is not disposed before it calls BundleClassLoader.findResource(), but a concurrent refresh can close the revision in between. close() sets the content to null and drops the content path. getContentPath() then rebuilds the path from the null content: MultiReleaseContent.wrap() swallows the resulting exception and returns null, so the cached path is a list holding null, and every later lookup on that revision fails the same way.

initializeContentPath() now returns an empty content path for a closed revision, so the lookup finds nothing, like getResourcesLocal() already does when there is no content path. The empty path is not cached, because a refresh closes all revisions of the bundle and then reopens the current one with resetContent(), after which the path must be computed again.

Test: ResourceLoadingTest.resourceLoadingFromClosedRevisionFindsNothing keeps the class loader of a bundle's wiring, updates and refreshes the bundle, and then calls findResource() and findResources() on the old class loader, which is the state the race leads to. On master it fails with the NullPointerException from the report; with the change it passes, and mvn clean verify of the framework module passes locally.

A lookup through the class loader of a wiring can still reach the
revision after a refresh closed it. The content path was then rebuilt
from the null content and cached as a list holding null, so
getResourceLocal() failed with a NullPointerException. A closed revision
now has an empty content path, which is not cached since the refresh can
reopen the revision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant