-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ced723f
commit f0287bb
Showing
2 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...app/src/main/java/io/github/dbmdz/metadata/server/interceptors/MdcLoggingInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.github.dbmdz.metadata.server.interceptors; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.slf4j.MDC; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
public class MdcLoggingInterceptor implements HandlerInterceptor { | ||
/** Clear MDC to avoid data leaking between two requests handled by the same thread. */ | ||
@Override | ||
public void afterCompletion( | ||
@NonNull HttpServletRequest request, | ||
@NonNull HttpServletResponse response, | ||
@NonNull Object handler, | ||
Exception ex) | ||
throws Exception { | ||
MDC.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters