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

Fix the SecureVault bundle activator exception handling issue #55

Merged
merged 2 commits into from
Sep 11, 2018

Conversation

ksdperera
Copy link
Contributor

Purpose

Resolves issue in SecureVault bundle activator exception handling. The existing implementation throws the errors while initializing the component bubble up to OSGi framework, but the problem is carbon logging uses pax logging as logging framework and it's not supported for Eclipse Equinox logging framework. Hence this OSGi bundle exception not captured by the logging framework.

Goals

Fix the SecureVault bundle activator exception handling issue

Approach

Catch the Throwable and logging the exception with compatible logging framework and bubble-up the exception to OSGi framework.

User stories

N/A

Release note

N/A

Documentation

N/A

Training

N/A

Certification

N/A

Marketing

N/A

Automation tests

  • Unit tests
  • Integration tests

Security checks

Samples

N/A

Related PRs

N/A

Migrations (if applicable)

N/A

Test environment

N/A

Learning

N/A

"secure vault configuration.")));
logger.debug("Secure vault config successfully initialized");
} catch (Throwable throwable) {
logger.error("Error occurred when initializing secure vault " + throwable.getMessage(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending throwable.getMessage() doesn't add any value. Exception message will be automatically printed by the logger when printing the throwable. So let's remove that.

logger.error("Cannot initialize secure vault.", throwable);

} catch (Throwable throwable) {
logger.error("Error occurred when initializing secure vault " + throwable.getMessage(),
throwable);
throw new SecureVaultException("Error occurred when initializing secure vault " + throwable.getMessage(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above applies here too.

throw new SecureVaultException("Cannot initialize secure vault.", throwable);

(secureVaultYAMLPath).orElseThrow(() -> new SecureVaultException("Error occurred when obtaining " +
"secure vault configuration.")));
logger.debug("Secure vault config successfully initialized");
} catch (Throwable throwable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we really need to catch Throwable here. Any reason why Exception (or any other exception) is not sufficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we shouldn't catch Throwable: https://stackoverflow.com/a/6083271/1577286

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes apply: ff567a8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reg: Throwable, yes it may be best practise to catch the Exception only. But here the problem is there is issue in carbon logging framework where it coudn't catch the eclipse equinox frameowrk logs and becouse of the it may hidden the Throwable causes without logging to carbon log file.

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

Successfully merging this pull request may close these issues.

None yet

4 participants