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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ public class SecureVaultActivator implements BundleActivator {

@Override
public void start(BundleContext bundleContext) throws Exception {
SecureVaultDataHolder.getInstance().setBundleContext(bundleContext);
logger.debug("Starting Secure Vault bundle");
logger.debug("Initializing Secure Vault config...");
Path secureVaultYAMLPath = Utils.getRuntimeConfigPath().resolve(Constants.DEPLOYMENT_CONFIG_YAML);
SecureVaultDataHolder.getInstance().setSecureVaultConfiguration(SecureVaultUtils.getSecureVaultConfig
(secureVaultYAMLPath).orElseThrow(() -> new SecureVaultException("Error occurred when obtaining " +
"secure vault configuration.")));
logger.debug("Secure vault config successfully initialized");
try {
SecureVaultDataHolder.getInstance().setBundleContext(bundleContext);
logger.debug("Starting Secure Vault bundle");
logger.debug("Initializing Secure Vault config...");
Path secureVaultYAMLPath = Utils.getRuntimeConfigPath().resolve(Constants.DEPLOYMENT_CONFIG_YAML);
SecureVaultDataHolder.getInstance().setSecureVaultConfiguration(SecureVaultUtils.getSecureVaultConfig
(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.

logger.error("Error occurred when initializing secure vault.", throwable);
throw new SecureVaultException("Error occurred when initializing secure vault.", throwable);
}
}

@Override
Expand Down