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

Make Logbook interceptors fault tolerant #1702

Closed
marcindabrowski opened this issue Dec 4, 2023 · 3 comments
Closed

Make Logbook interceptors fault tolerant #1702

marcindabrowski opened this issue Dec 4, 2023 · 3 comments
Labels

Comments

@marcindabrowski
Copy link

Since Logbook interceptors are not altering HTTP requests and responses they should do not throw Exceptions on they failure, because it could break HTTP connection.

Detailed Description

LogbookHttpRequestInterceptor.process method according to Apache HttpRequestInterceptor.process is allowed to throw HttpException and IOException, but actually it could throw any RuntimeExcpetion that happens during processing, ie.: #1693.

Context

With this change we will be sure that even if there will be some issues, for example after some libraries version bump, it will not affect my HTTP communication. Logbook is just logging, so if it fails, it should not break my HTTP communication.

Possible Implementation

This is example for LogbookHttpRequestInterceptor.process

try {
    LocalRequest request = new LocalRequest(httpRequest, entity);
    final ResponseProcessingStage stage = logbook.process(request).write();
    context.setAttribute(Attributes.STAGE, stage);
  } catch (HttpException | IOException exception) {
    throw exception;
  } catch (Exception ignored) {
  }
}

Of course it should be applied to all request and response interceptors.

Your Environment

  • Version used: 3.6.0
@kasmarian
Copy link
Member

@whiskeysierra @msdousti @ChristianLohmann what do you all think? I'm wondering why this wasn't the case all along for Logbook interceptors, as failures to log request/response shouldn't result in the whole request failure. On the other hand, I don't see this approach adopted in logbook and wonder if it's for a good reason.

@msdousti
Copy link
Collaborator

msdousti commented Dec 7, 2023

@kasmarian

Willi and I had a related discussion here: #1589 (comment)

My two cents is that under no circumstances should a fault in Logbook result in a failure in the application.

@kasmarian kasmarian mentioned this issue Jan 21, 2024
6 tasks
@kasmarian
Copy link
Member

@marcindabrowski now interceptors as well as DefaultLogbook will have the logic inside try-catch blocks, which should prevent failures of request/response processing and will only result in not logging them. Thanks for raising the issue. The fix will be part of the next release, I'll close the issue so that it's added to the release notes. But feel free to reopen it, if it's not fully addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants