Exception handling in NullableType - NullPointerException

Description

I think the exception handling in nullabletype is broken/non-aligned.

in nullsafeset:

catch (RuntimeException re) {
LogFactory.getLog( getClass() ).info(
"could not bind value '" + toString(value) +
"' to parameter: " + index
);
}

notice that there are no throw re; here. meaning an exception can occur but the code will just continue.
AND RuntimeException is catched instead of Throwable meaning SQLException's which is the most likely exception will not result in a logging.

Environment

None

Activity

Show:
Steve Ebersole
January 11, 2007, 2:57 PM

It is fixed. The code is the same on trunk as well as the 3.1 and 3.2 branches and looks like:

public final void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {
try {
if ( value == null ) {
if ( IS_TRACE_ENABLED ) {
log().trace( "binding null to parameter: " + index );
}

st.setNull( index, sqlType() );
}
else {
if ( IS_TRACE_ENABLED ) {
log().trace( "binding '" + toString( value ) + "' to parameter: " + index );
}

set( st, value, index );
}
}
catch ( RuntimeException re ) {
log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + re.getMessage() );
throw re;
}
catch ( SQLException se ) {
log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + se.getMessage() );
throw se;
}
}

Steve Ebersole
March 21, 2011, 7:04 PM

Bulk closing stale resolved issues

Rejected

Assignee

Steve Ebersole

Reporter

Krzysztof Adamski

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Critical
Configure