DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-813
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Danny van Leiden
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.
DataNucleus Core

OSGi performance improvement for MetaDataManager#getMetaDataForImplementationOfReference

Created: 23/Feb/12 01:25 PM   Updated: 30/Mar/12 09:25 AM   Resolved: 23/Feb/12 02:44 PM
Component/s: MetaData
Affects Version/s: 3.0.0.release
Fix Version/s: 3.0.9, 3.1.0.m1

Environment: OSGi (Equinox)

 Description  « Hide
MetaDataManager#getMetaDataForImplementationOfReference uses the following code to load classes by name:

Class cls = referenceClass.getClassLoader().loadClass(class_name);

In some environments, like OSGi, referenceClass.getClassLoader() may return null if referenceClass was loaded by the bootstrap class loader. This may be the case if referenceClass is java.util.Set or another collection interface.

The resulting NullPointerException is swallowed by the surrounding try/catch statement and does not seem to result in any defect. This does however mean that a NullPointerException is thrown and caught for each iteration over the classMetaDataByClass keyset, resulting in a performance penalty.

This may be improved by checking if referenceClass.getClassLoader() is null before iterating over the classMetaDataByClass keyset and returning null immediately if it is the case.

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 23/Feb/12 02:44 PM
SVN trunk and branches/3.0 check for null class loader, thx. For any future contribs, a "patch" would be much better ;-)