Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 🐛 Error should not be logged twice #879

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- [BUG] :goal_net: Catch all LdapException when using mono connection
- [REL] :rocket: release version 2.1.2


# 2.1.2

- [BUG] :bug: Fix max time before a connection is dropped from ldap connection pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ public class SugoiAdviceController {
@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity<ErrorView> exception(Exception e) {
ErrorView errorView = new ErrorView(e.getMessage());
HttpStatus status = computeStatusFromException(e);
if (status.is5xxServerError()) {
ResponseEntity<ErrorView> errorView = createErrorView(e);
if (errorView.getStatusCode().is5xxServerError()) {
logger.error(e.getMessage(), e);
}
return errorView;
}

public ResponseEntity<ErrorView> createErrorView(Exception e) {
ErrorView errorView = new ErrorView(e.getMessage());
HttpStatus status = computeStatusFromException(e);
return new ResponseEntity<>(errorView, status);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Object logArroundExec(ProceedingJoinPoint pjp) throws Throwable {

@AfterThrowing(pointcut = POINTCUT, throwing = "e")
public void logAfterException(JoinPoint jp, Exception e) {
ResponseEntity<?> error = sugoiAdviceController.exception(e);
ResponseEntity<?> error = sugoiAdviceController.createErrorView(e);
if (log.isInfoEnabled())
log.info(
"type={} user={} requestArguments='{}' responseCode='{}' exception='{}'",
Expand Down
Loading