[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5703) EJB3PostLoadEventListener, as created by EventListenerConfigurator, throws NullPointerException.
Eduardo Born (JIRA)
noreply at atlassian.com
Sat Oct 30 17:42:47 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38954#action_38954 ]
Eduardo Born commented on HHH-5703:
-----------------------------------
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.
> EJB3PostLoadEventListener, as created by EventListenerConfigurator, throws NullPointerException.
> ------------------------------------------------------------------------------------------------
>
> Key: HHH-5703
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5703
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.6
> Reporter: Eduardo Born
>
> 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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list