Skip to content

Commit

Permalink
fixes #208: NPE when retrieving logs for empty room
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Dec 14, 2021
1 parent 8f9bbf2 commit ab17b1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ <h1>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/192'>Issue #192</a>] - Combining keyword and participant(s) makes search fail</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/195'>Issue #195</a>] - Class incompatibility with latest OF MUC</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/200'>Issue #200</a>] - Remove references to deprecated logger methods</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/208'>Issue #208</a>] - Prevent NullPointerException when retrieving logs for empty room</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/210'>Issue #210</a>] - Update Jersey library to 2.35</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,13 @@ public static Instant getDateOfFirstLog( MUCRoom room )
}
rs = pstmt.executeQuery();
if (rs.next()) {
return new Date(Long.parseLong(rs.getString(1).trim())).toInstant();
// Note that 'min()' will return a single 'null' value if the 'where' condition does not match.
final String minValue = rs.getString(1);
if (minValue == null || rs.wasNull()) {
return null;
} else {
return new Date(Long.parseLong(minValue.trim())).toInstant();
}
}
} catch (SQLException e) {
Log.error("SQL failure while trying to find the timestamp of the earliest message for room {} in MAM-MUC: ", room.getJID(), e);
Expand Down

0 comments on commit ab17b1c

Please sign in to comment.