From bde6239c261c15734a3432cd734a6f9411b1264e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 22 Feb 2018 09:03:33 +0100 Subject: [PATCH] Return empty map in SpoilerElement.getSpoilers() instead of null --- .../jivesoftware/smackx/spoiler/element/SpoilerElement.java | 3 ++- .../test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java index 3ee6b08ee..f0c53a71f 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java @@ -18,6 +18,7 @@ package org.jivesoftware.smackx.spoiler.element; import static org.jivesoftware.smackx.spoiler.SpoilerManager.NAMESPACE_0; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -110,7 +111,7 @@ public class SpoilerElement implements ExtensionElement { */ public static Map getSpoilers(Message message) { if (!containsSpoiler(message)) { - return null; + return Collections.emptyMap(); } List spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE_0); diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java index 3049e44df..d1a77cff3 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java @@ -97,7 +97,7 @@ public class SpoilerTest extends SmackTestSuite { @Test public void getSpoilersTest() { Message m = new Message(); - assertNull(SpoilerElement.getSpoilers(m)); + assertTrue(SpoilerElement.getSpoilers(m).isEmpty()); SpoilerElement.addSpoiler(m); assertTrue(SpoilerElement.containsSpoiler(m));