1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 20:12:07 +01:00

Return empty map in SpoilerElement.getSpoilers() instead of null

This commit is contained in:
Florian Schmaus 2018-02-22 09:03:33 +01:00
parent 4292659f22
commit bde6239c26
2 changed files with 3 additions and 2 deletions

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.spoiler.element;
import static org.jivesoftware.smackx.spoiler.SpoilerManager.NAMESPACE_0; import static org.jivesoftware.smackx.spoiler.SpoilerManager.NAMESPACE_0;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -110,7 +111,7 @@ public class SpoilerElement implements ExtensionElement {
*/ */
public static Map<String, String> getSpoilers(Message message) { public static Map<String, String> getSpoilers(Message message) {
if (!containsSpoiler(message)) { if (!containsSpoiler(message)) {
return null; return Collections.emptyMap();
} }
List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE_0); List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE_0);

View file

@ -97,7 +97,7 @@ public class SpoilerTest extends SmackTestSuite {
@Test @Test
public void getSpoilersTest() { public void getSpoilersTest() {
Message m = new Message(); Message m = new Message();
assertNull(SpoilerElement.getSpoilers(m)); assertTrue(SpoilerElement.getSpoilers(m).isEmpty());
SpoilerElement.addSpoiler(m); SpoilerElement.addSpoiler(m);
assertTrue(SpoilerElement.containsSpoiler(m)); assertTrue(SpoilerElement.containsSpoiler(m));