Issue Details (XML | Word | Printable)

Key: NUCCORE-866
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Yevgeny Shakhnovich
Votes: 0
Watchers: 0
Operations

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

NullPointerException in NucleusContext.getStatistics()

Created: 28/Jun/12 11:12 PM   Updated: 06/Jul/12 10:00 AM   Resolved: 29/Jun/12 07:27 AM
Component/s: None
Affects Version/s: 3.1.0.m4
Fix Version/s: 3.1.0.m5

Environment: Linux, actually does not matter


 Description  « Hide
This code contains a bug. When statistics is null, using it in statistics.getClass() leads to NullPointerException. Actually, this code is full of bugs. Assume that getJMXManager returns null, you will use null as a name for FactoryStatistics

public synchronized FactoryStatistics getStatistics()
    {
        if (statistics == null && statisticsEnabled())
        {
            String name = null;
            if (getJMXManager() != null)
            {
                // Register the MBean with the active JMX manager
                name = jmxManager.getDomainName() + ":InstanceName=" + jmxManager.getInstanceName() +
                    ",Type=" + ClassUtils.getClassNameForClass(statistics.getClass()) +
                    ",Name=Factory" + random.nextInt();
            }
            statistics = new FactoryStatistics(name);
            if (jmxManager != null)
            {
                // Register the MBean with the active JMX manager
                jmxManager.registerMBean(this.statistics, name);
            }
        }
        return statistics;
    }

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 29/Jun/12 07:27 AM
SVN trunk uses FactoryStatistics to set the "name" (which is only relevant if using JMX anyway, so is irrelevant if null for non-JMX cases). And no, that code was not "full of bugs", just had a cut and paste on the class name to use in the name. Perhaps as your code must be so perfect you can just contribute a patch next time ... as the bug reporting guide asks.