From 5e43ef550faf35871d2b86cab24c59349c8a61b2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 2 May 2021 18:43:41 +0200 Subject: [PATCH] [openpgp] Improve control-flow logic in PainlessOpenPgpProvider Also remove superfluous toString(). --- .../smackx/ox/crypto/PainlessOpenPgpProvider.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/crypto/PainlessOpenPgpProvider.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/crypto/PainlessOpenPgpProvider.java index 28073421c..3a9ffa4d5 100644 --- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/crypto/PainlessOpenPgpProvider.java +++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/crypto/PainlessOpenPgpProvider.java @@ -71,11 +71,12 @@ public class PainlessOpenPgpProvider implements OpenPgpProvider { ArrayList recipientKeys = new ArrayList<>(); for (OpenPgpContact contact : recipients) { PGPPublicKeyRingCollection keys = contact.getTrustedAnnouncedKeys(); - if (keys != null) { - recipientKeys.add(keys); - } else { - LOGGER.log(Level.WARNING, "There are no suitable keys for contact " + contact.getJid().toString()); + if (keys == null) { + LOGGER.log(Level.WARNING, "There are no suitable keys for contact " + contact.getJid()); + } + + recipientKeys.add(keys); } EncryptionStream cipherStream = PGPainless.createEncryptor().onOutputStream(cipherText)