From dc64a43f126ae25c0e98c3be2df958be1d79849b Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 17 May 2020 17:01:42 +0200 Subject: [PATCH] Prevent NPE when closing trust store stream --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 87f6f091e..e7d8daebb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -126,6 +126,7 @@ import org.jivesoftware.smack.sasl.SASLMechanism; import org.jivesoftware.smack.sasl.core.SASLAnonymous; import org.jivesoftware.smack.sasl.packet.SaslNonza; import org.jivesoftware.smack.util.Async; +import org.jivesoftware.smack.util.CloseableUtil; import org.jivesoftware.smack.util.CollectionUtil; import org.jivesoftware.smack.util.Consumer; import org.jivesoftware.smack.util.DNSUtil; @@ -2291,7 +2292,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { try { ks.load(stream, password); } finally { - stream.close(); + CloseableUtil.maybeClose(stream); } } catch (IOException e) { LOGGER.log(Level.FINE, "KeyStore load() threw, attempting 'jks' fallback", e); @@ -2302,7 +2303,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { try { ks.load(stream, null); } finally { - stream.close(); + CloseableUtil.maybeClose(stream); } } }