Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public void resetPassword(@Parameter(description = "The representation must cont
logger.error(e.getMessage(), e);
throw ErrorResponse.error(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
} catch (ModelException e) {
logger.warn("Could not update user password.", e);
logger.warnf("Could not update password for user %s. Reason: %s", user.getUsername(), e.getCause().getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that test failures are regression of this change.

I guess that e.getCause() is sometimes null? So perhaps might be rather something to check nulls. IMO it would be also good to still log original exception at least at the trace level as it is sometimes useful to see the whole trace for debugging/investigating the cause of some particular issue.

Suggested change
logger.warnf("Could not update password for user %s. Reason: %s", user.getUsername(), e.getCause().getMessage());
String exceptionMessage = e.getCause() == null ? e.getMessage() : e.getCause().getMessage();
logger.warnf("Could not update password for user %s. Reason: %s", user.getUsername(), exceptionMessage);
if (log.isTraceEnabled()) {
log.tracef("Could not update user password.", e);
}

Properties messages = AdminRoot.getMessages(session, realm, auth.adminAuth().getToken().getLocale());
throw new ErrorResponseException(e.getMessage(), MessageFormat.format(messages.getProperty(e.getMessage(), e.getMessage()), e.getParameters()),
Status.BAD_REQUEST);
Expand Down
Loading