From d133f25ca6ddc9bedcdb96213680be2e9f7ce6e0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 17 Aug 2018 12:23:20 +0200 Subject: [PATCH] Do not mask FileNotFoundException in FileBasedOpenPgpKeyStore --- .../store/filebased/FileBasedOpenPgpKeyStore.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/filebased/FileBasedOpenPgpKeyStore.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/filebased/FileBasedOpenPgpKeyStore.java index f516d2011..277ca3986 100644 --- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/filebased/FileBasedOpenPgpKeyStore.java +++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/store/filebased/FileBasedOpenPgpKeyStore.java @@ -113,13 +113,10 @@ public class FileBasedOpenPgpKeyStore extends AbstractOpenPgpKeyStore { public PGPPublicKeyRingCollection readPublicKeysOf(BareJid owner) throws IOException, PGPException { File file = getPublicKeyRingPath(owner); - - FileInputStream inputStream; - try { - inputStream = FileUtils.prepareFileInputStream(file); - } catch (FileNotFoundException e) { + if (!file.exists()) { return null; } + FileInputStream inputStream = FileUtils.prepareFileInputStream(file); PGPPublicKeyRingCollection collection = PGPainless.readKeyRing().publicKeyRingCollection(inputStream); inputStream.close(); @@ -129,13 +126,10 @@ public class FileBasedOpenPgpKeyStore extends AbstractOpenPgpKeyStore { @Override public PGPSecretKeyRingCollection readSecretKeysOf(BareJid owner) throws IOException, PGPException { File file = getSecretKeyRingPath(owner); - - FileInputStream inputStream; - try { - inputStream = FileUtils.prepareFileInputStream(file); - } catch (FileNotFoundException e) { + if (!file.exists()) { return null; } + FileInputStream inputStream = FileUtils.prepareFileInputStream(file); PGPSecretKeyRingCollection collection = PGPainless.readKeyRing().secretKeyRingCollection(inputStream); inputStream.close();