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

Issue while logging MDC values with Jetty 12 #11715

Open
narharim opened this issue Apr 29, 2024 · 1 comment
Open

Issue while logging MDC values with Jetty 12 #11715

narharim opened this issue Apr 29, 2024 · 1 comment
Labels
Bug For general bugs on Jetty side

Comments

@narharim
Copy link

Jetty version(s)

Jetty 12.0.8

Jetty Environment

core

Java version/vendor (use: java -version)
Amazon Corretto 17.0.9

OS type/version
Ubuntu 22.04.4 LTS

Description

We have a service A that initiates an API call to another service B. In response service B transfers zip file in chunk to service A. We have written a custom response listener which transfer chunk from service A to its client without storing it in buffer.

while doing so when ever connection is aborted from client of service A, key-value pair which we are inserting into MDC map are getting cleared out and we are unable to log those key-value.

for example
MDC.put(ABORTED, "true") is not printed in log

logback-access version
2.0.2

Note: we are using kotlin as our programming language

How to reproduce?
Attached code for ref
logging.txt
handler.txt

@narharim narharim added the Bug For general bugs on Jetty side label Apr 29, 2024
@sbordet
Copy link
Contributor

sbordet commented Apr 29, 2024

This does not seem a Jetty issue.

Jetty will (possibly) use different threads to invoke handle(), onContent() and onComplete(), but you seem to take care of this by passing the MDC map around.

If these 3 consecutive lines do not work, then Jetty is out of the picture:

MDC.setContextMap(mdc)
MDC.put(ABORTED, "true")
log.debug("aborted")

Do you have a Java reproducer that we can try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants