-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improve error message when the keystore/truststore type cannot be detected from the file extension #39164
Conversation
@@ -66,7 +70,8 @@ public static TrustOptions computeTrustOptions(CertificateConfig certificates, O | |||
} | |||
|
|||
if (singleTrustStoreFile != null) { // We have a single trust store file. | |||
String type = certificates.trustStoreFileType.orElse(getTypeFromFileName(singleTrustStoreFile)); | |||
String type = certificates.trustStoreFileType.map(String::toLowerCase) |
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.
changes are fine, however always calling certificates.trustStoreFileType.map(String::toLowerCase).orElse(getTypeFromFileName("truststore", singleTrustStoreFile))
means that when file extension is not present or when truststore file type can't be matched based on the file extension, an exception is thrown, doesn't it? wouldn't orElseGet
be better?
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.
ah yes, you are right!
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.
Fixed, in addition, I added a few tests.... because at least we have a baseline.
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 didn't use orElseGet, as it introduces a lambda, in this case, the imperative if/then block is more efficient)
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.
Great, thank you.
This comment has been minimized.
This comment has been minimized.
a4f07c2
to
3d1645a
Compare
…ected from the file extension.
3d1645a
to
7904bba
Compare
Status for workflow
|
The error message was misleading when the type of a keystore or truststore cannot be found from the file extension.
This PR fixes and improves it by indicating the property to configure.
@michalvavrik Your previous report highlighted a problem in the error message. Here is the fix.