EJB3PostLoadEventListener, as created by EventListenerConfigurator, throws NullPointerException.

Description

EJB3PostLoadEventListener is created by EventListenerConfigurator with its default constructor:

listenerConfig.setPostLoadEventListeners(
new PostLoadEventListener[] { new EJB3PostLoadEventListener(), new DefaultPostLoadEventListener() }
);

The problem is that it has a callbackHandler field called which remains null, and there is no check in the postLoad method before invoking callbackHandler.postLoad( entity );. This causes a NullPointerException to be thrown there in a few situations.

The fix is simple. H+In the EJB3PostLoadEventListener's postLoad() method, replace:

public void onPostLoad(PostLoadEvent event) {
Object entity = event.getEntity();
callbackHandler.postLoad( entity );
}
by:

public void onPostLoad(PostLoadEvent event) {
if (callbackHandler == null) return;
Object entity = event.getEntity();
callbackHandler.postLoad( entity );
}

This would prevent the NullPointerException to be thrown when there is no callbackHandler.

Activity

Brett MeyerJuly 8, 2014 at 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Brett MeyerApril 7, 2014 at 5:44 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Eduardo BornOctober 30, 2010 at 11:41 PM

Actually the callback handler might be set during the execution of EventListenerConfigurator's configure() method, but it mist not as well so a check for null is still required.

Rejected

Details

Assignee

Reporter

Components

Affects versions

Priority

Created October 30, 2010 at 11:37 PM
Updated July 8, 2014 at 3:10 PM
Resolved July 8, 2014 at 3:10 PM