From 27164f4c06eeada645c4c8131e7f830a2916da41 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 16 Aug 2018 15:24:43 +0200 Subject: [PATCH] Do not use a generic return parameter in PubSubManager.getNode() --- .../java/org/jivesoftware/smackx/pep/PepManager.java | 6 ++++-- .../org/jivesoftware/smackx/pubsub/PubSubManager.java | 11 ++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PepManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PepManager.java index 1c3037a7d..f581e9830 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PepManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PepManager.java @@ -40,6 +40,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.pubsub.EventElement; import org.jivesoftware.smackx.pubsub.Item; import org.jivesoftware.smackx.pubsub.LeafNode; +import org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException; import org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException; import org.jivesoftware.smackx.pubsub.PubSubFeature; import org.jivesoftware.smackx.pubsub.PubSubManager; @@ -157,10 +158,11 @@ public final class PepManager extends Manager { * @throws XMPPErrorException * @throws NoResponseException * @throws NotAPubSubNodeException + * @throws NotALeafNodeException */ public void publish(Item item, String node) throws NotConnectedException, InterruptedException, - NoResponseException, XMPPErrorException, NotAPubSubNodeException { - LeafNode pubSubNode = pepPubSubManager.getNode(node); + NoResponseException, XMPPErrorException, NotAPubSubNodeException, NotALeafNodeException { + LeafNode pubSubNode = pepPubSubManager.getLeafNode(node); pubSubNode.publish(item); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java index 9a248d2b5..465ebeb3d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java @@ -233,7 +233,6 @@ public final class PubSubManager extends Manager { * exception if it does not. * * @param id - The unique id of the node - * @param type of the node. * * @return the node * @throws XMPPErrorException The node does not exist @@ -242,7 +241,7 @@ public final class PubSubManager extends Manager { * @throws InterruptedException * @throws NotAPubSubNodeException */ - public T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { + public Node getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { Node node = nodeMap.get(id); if (node == null) { @@ -263,9 +262,7 @@ public final class PubSubManager extends Manager { } nodeMap.put(id, node); } - @SuppressWarnings("unchecked") - T res = (T) node; - return res; + return node; } /** @@ -283,7 +280,7 @@ public final class PubSubManager extends Manager { public LeafNode getOrCreateLeafNode(final String id) throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException { try { - return getNode(id); + return getLeafNode(id); } catch (NotAPubSubNodeException e) { return createNode(id); @@ -297,7 +294,7 @@ public final class PubSubManager extends Manager { if (e2.getStanzaError().getCondition() == Condition.conflict) { // The node was created in the meantime, re-try getNode(). Note that this case should be rare. try { - return getNode(id); + return getLeafNode(id); } catch (NotAPubSubNodeException e) { // Should not happen