Skip to content

Commit

Permalink
DOC-153. Closing resources fix
Browse files Browse the repository at this point in the history
  • Loading branch information
valb3r committed May 20, 2019
1 parent 75a83c7 commit 233d781
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Expand Up @@ -67,17 +67,18 @@ public GsonSerde() {
@SneakyThrows
private JsonPrimitive writePubKey(PublicKey publicKey) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bos);
os.writeObject(publicKey);

return new JsonPrimitive(new String(Base64.getEncoder().encode(bos.toByteArray())));
try (ObjectOutputStream os = new ObjectOutputStream(bos);) {
os.writeObject(publicKey);
return new JsonPrimitive(new String(Base64.getEncoder().encode(bos.toByteArray())));
}
}

@SneakyThrows
private PublicKey readPubKey(JsonElement in) {
byte[] bytes = Base64.getDecoder().decode(in.getAsString());
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream is = new ObjectInputStream(bis);
return (PublicKey) is.readObject();
try (ObjectInputStream is = new ObjectInputStream(bis)) {
return (PublicKey) is.readObject();
}
}
}
Expand Up @@ -39,7 +39,7 @@ public class KeyStoreGenerator {
private final Map<KeyID, Optional<SecretKeyEntry>> secretKeys;

@Builder
private KeyStoreGenerator(
protected KeyStoreGenerator(
KeyStoreCreationConfig config,
KeyStoreType keyStoreType,
String serverKeyPairAliasPrefix,
Expand Down
Expand Up @@ -2,7 +2,10 @@

import com.google.common.io.MoreFiles;
import de.adorsys.datasafe.business.api.storage.StorageService;
import de.adorsys.datasafe.business.api.types.resource.*;
import de.adorsys.datasafe.business.api.types.resource.AbsoluteLocation;
import de.adorsys.datasafe.business.api.types.resource.BasePrivateResource;
import de.adorsys.datasafe.business.api.types.resource.BaseResolvedResource;
import de.adorsys.datasafe.business.api.types.resource.ResolvedResource;
import de.adorsys.datasafe.business.api.types.utils.Log;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
Expand Down

0 comments on commit 233d781

Please sign in to comment.