Details about the known misuse from the MUBench dataset.
Description: | PersistentDateTime.nullSafeGet() may return null, while constructor of Interval expects non-null parameters.
|
Fix Description: |
(see diff) |
Violation Types: |
- missing/condition/null_check
|
In File: | org/joda/time/contrib/hibernate/PersistentInterval.java |
In Method: | nullSafeGet(ResultSet, String[], SessionImplementor, Object) |
Code with Misuse: |
class PersistentInterval {
public Object nullSafeGet(ResultSet resultSet, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException
{
if (resultSet == null)
{
return null;
}
PersistentDateTime pst = new PersistentDateTime();
DateTime start = (DateTime) pst.nullSafeGet(resultSet, names[0]);
DateTime end = (DateTime) pst.nullSafeGet(resultSet, names[1]);
return new Interval(start, end);
}
}
|
Code with Pattern(s): |
class CheckStartDateForNull {
void nullSafeGet(ResultSet resultSet, String[] names) throws HibernateException, SQLException {
PersistentDateTime pst = new PersistentDateTime();
DateTime start = (DateTime) pst.nullSafeGet(resultSet, names[0]);
DateTime end = (DateTime) pst.nullSafeGet(resultSet, names[1]);
if (start != null && end != null) {
new Interval(start, end);
}
}
}
|