-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix contract for FileSourceBlobStore #2451
Conversation
…it should return Optional.empty() wiremock#2420
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay though I would think about proper diagnostics logs, because now all exceptions would be silently suppressed. Would be also nice to add a human readable PR title for the changelog
@oleg-nenashev Can you tell me how nice it is to make diagnostic logs? maybe there is an example somewhere? |
WireMock uses
I normally use stock logging frameworks, so not sure how much of debug logging we can make with it |
fix code style, add logs
@oleg-nenashev thanks for the hint, I added it in the next commit+ fixed code style |
return Optional.of(fileSource.getBinaryFileNamed(key).readContents()); | ||
try { | ||
return Optional.of(fileSource.getBinaryFileNamed(key).readContents()); | ||
} catch (Exception exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we catch FileNotFoundException
and don't log anything, since this is a normal event, then log at error for any other type of exception (which in practice would probably indicate a misconfigured file system)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I used instanceof because FileNotFoundException is cast to Throwable in the BinaryFile class via the throwUnchecked method
fix comment
notifier() | ||
.info("Error when working with FileSource:\n" + Json.write(exception.getMessage())); | ||
} | ||
return Optional.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still throw the exception if it's not FileNotFoundException
. Only return empty when it's exactly that exception.
We can probably do this with two catch blocks rather than instanceof
.
The notifier call should be at error
if it's not a not-found error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, catch FileNotFoundException is unavailable due to wrapping into an unchecked exception in the Binary File class via the throwUnchecked method.
Other comments fixed
fix comment
Thanks! |
Fix for: FileSourceBlobStore throws FileNotFoundExceptions when it should return Optional.empty() wiremock#2420 --------- Co-authored-by: d.khoziainov <d.khoziainov@uzum.com>
Fix for: FileSourceBlobStore throws FileNotFoundExceptions when it should return Optional.empty() wiremock#2420 --------- Co-authored-by: d.khoziainov <d.khoziainov@uzum.com>
Greetings, please look at my PR for #2420
Submitter checklist
#help-contributing
or a project-specific channel like#wiremock-java