You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Thomas de Grenier de Latour <no...@github.com> on 2017/11/13 17:02:08 UTC

[jclouds/jclouds] [JCLOUDS-1354] avoid memory leak by reusing BouncyCastleProvider (#1156)

See [JCLOUDS-1354](https://issues.apache.org/jira/browse/JCLOUDS-1354).  Reuse a single instance of `BouncyCastleProvider`, because every instance used at least once will be retained forever in the JCE providers map (in `javax.crypto.JceSecurity` - see also [JDK-8168469](https://bugs.openjdk.java.net/browse/JDK-8168469)).
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds/pull/1156

-- Commit Summary --

  * [JCLOUDS-1354] avoid memory leak by reusing BouncyCastleProvider

-- File Changes --

    M drivers/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/BouncyCastleCrypto.java (19)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/1156.patch
https://github.com/jclouds/jclouds/pull/1156.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1156

Re: [jclouds/jclouds] [JCLOUDS-1354] avoid memory leak by reusing BouncyCastleProvider (#1156)

Posted by Ignasi Barrera <no...@github.com>.
Thanks for the detailed bug report and for the PR @thomasgl-orange!

Although I fully understand the memory leak, I'm a bit concerned about introducing a cross-context instance. If at some point the JDK bug gets fixed, users might expect all context-scoped resources to be released when the context is closed, and having a static reference by default there might not be expected.

Instead of preconfiguring a shared instance, what about modifying the [BouncyCastleCryptoModule](https://github.com/jclouds/jclouds/blob/master/drivers/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/config/BouncyCastleCryptoModule.java) to provide an alternate constructor that gets a `BouncyCastleProvider`, and have that one (or a per-context default one, to keep the current behavior) injected? This way users could keep using the current behavior or instantiate the provider themselves (by passing a reference to a static instance). This is also the approach we already use in the [CredentialStoreModule](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/rest/config/CredentialStoreModule.java) for users that want credential persistence across contexts.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1156#issuecomment-344000530

Re: [jclouds/jclouds] [JCLOUDS-1354] avoid memory leak by reusing BouncyCastleProvider (#1156)

Posted by Andrew Gaul <no...@github.com>.
Please reopen against apache/jclouds if this is still relevant.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1156#issuecomment-663855761

Re: [jclouds/jclouds] [JCLOUDS-1354] avoid memory leak by reusing BouncyCastleProvider (#1156)

Posted by Andrew Gaul <no...@github.com>.
Closed #1156.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1156#event-3586273632