Don't log and rethrow exceptions in AbstractFlushingEventListener

Description

For a similar issue covering logging-and-rethrowing overall, see http://opensource.atlassian.com/projects/hibernate/browse/HB-1308. This issue covers a specific instance in order to minimize the impact on the codebase. However, I would be all for elimination of every instance of log-and-rethrow in the codebase.

In this particular instance, I have a table A with a foreign key referencing records in table B. In my user interface, I give the user the ability to delete records from table B. If the user attempts to delete a record from table B that is referred to in table A, the database throws an integrity constraint violation. This exception is caught in AbstractFlushingEventListener.performExecutions, logged, and rethrown. My code sees the exception and informs the user that the record cannot be deleted because it's already in use in the system. So the exception ends up showing up in my logs (from the log.error() statement in AbstractFlushingEventListener.performExecutions) even though I'm handling it properly. I would like the log.error() statement removed since the code propagates the exception. Attached is a patchfile.

I'm not including a test case because I feel the issue is so simplistic that one isn't necessary.

Attachments

3

Activity

Show:

Brett MeyerMarch 7, 2014 at 10:09 PM

Bulk closing tickets resolved in released versions

Former userMarch 9, 2011 at 10:20 PM

Fixed in git hibernate-core master and 3.6

GreggSeptember 24, 2010 at 6:26 PM

An alternative solution is to use a chained exception via the following patch

GreggSeptember 24, 2010 at 6:20 PM

Uploaded the correct patchfile

Fixed

Details

Assignee

Reporter

Original estimate

Time tracking

No time logged0.17h remaining

Components

Fix versions

Affects versions

Priority

Created September 24, 2010 at 6:07 PM
Updated March 7, 2014 at 10:09 PM
Resolved March 9, 2011 at 10:20 PM