brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #196: Close streams after usage
Date Wed, 15 Jun 2016 10:38:16 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/196#discussion_r67138867
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/crypto/SecureKeys.java ---
    @@ -78,11 +78,11 @@ public static X509Principal getX509PrincipalWithCommonName(String
commonName) {
             return new X509Principal("" + "C=None," + "L=None," + "O=None," + "OU=None,"
+ "CN=" + commonName);
         }
     
    -    /** reads RSA or DSA / pem style private key files (viz {@link #toPem(KeyPair)}),
extracting also the public key if possible
    +    /** reads RSA or DSA / pem style private key files (viz {@link #toPem(KeyPair)}),
extracting also the public key if possible. Closes the stream.
          * @throws IllegalStateException on errors, in particular {@link PassphraseProblem}
if that is the problem */
         public static KeyPair readPem(InputStream input, final String passphrase) {
             // TODO cache is only for fallback "reader" strategy (2015-01); delete when Parser
confirmed working
    -        byte[] cache = Streams.readFully(input);
    +        byte[] cache = Streams.readFullyAndClose(input);
    --- End diff --
    
    @neykov How about overloading `readPem` to take a byte array? It looks like that is the
way it is used anyway.
    
    And for the tests that call it, I wonder if we should add `byte[] ResourceUtils.getResourceAsBytes(String
url)`. Again it feels like many callers of the existing `getResourceFromUrl` either want it
as a string or as bytes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message