1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 08:12:05 +01:00

Do not use a generic return parameter in PubSubManager.getNode()

This commit is contained in:
Florian Schmaus 2018-08-16 15:24:43 +02:00
parent 528e170b99
commit 27164f4c06
2 changed files with 8 additions and 9 deletions

View file

@ -40,6 +40,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.pubsub.EventElement; import org.jivesoftware.smackx.pubsub.EventElement;
import org.jivesoftware.smackx.pubsub.Item; import org.jivesoftware.smackx.pubsub.Item;
import org.jivesoftware.smackx.pubsub.LeafNode; 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.PubSubException.NotAPubSubNodeException;
import org.jivesoftware.smackx.pubsub.PubSubFeature; import org.jivesoftware.smackx.pubsub.PubSubFeature;
import org.jivesoftware.smackx.pubsub.PubSubManager; import org.jivesoftware.smackx.pubsub.PubSubManager;
@ -157,10 +158,11 @@ public final class PepManager extends Manager {
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws NoResponseException * @throws NoResponseException
* @throws NotAPubSubNodeException * @throws NotAPubSubNodeException
* @throws NotALeafNodeException
*/ */
public void publish(Item item, String node) throws NotConnectedException, InterruptedException, public void publish(Item item, String node) throws NotConnectedException, InterruptedException,
NoResponseException, XMPPErrorException, NotAPubSubNodeException { NoResponseException, XMPPErrorException, NotAPubSubNodeException, NotALeafNodeException {
LeafNode pubSubNode = pepPubSubManager.getNode(node); LeafNode pubSubNode = pepPubSubManager.getLeafNode(node);
pubSubNode.publish(item); pubSubNode.publish(item);
} }

View file

@ -233,7 +233,6 @@ public final class PubSubManager extends Manager {
* exception if it does not. * exception if it does not.
* *
* @param id - The unique id of the node * @param id - The unique id of the node
* @param <T> type of the node.
* *
* @return the node * @return the node
* @throws XMPPErrorException The node does not exist * @throws XMPPErrorException The node does not exist
@ -242,7 +241,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException * @throws InterruptedException
* @throws NotAPubSubNodeException * @throws NotAPubSubNodeException
*/ */
public <T extends Node> 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); Node node = nodeMap.get(id);
if (node == null) { if (node == null) {
@ -263,9 +262,7 @@ public final class PubSubManager extends Manager {
} }
nodeMap.put(id, node); nodeMap.put(id, node);
} }
@SuppressWarnings("unchecked") return node;
T res = (T) node;
return res;
} }
/** /**
@ -283,7 +280,7 @@ public final class PubSubManager extends Manager {
public LeafNode getOrCreateLeafNode(final String id) public LeafNode getOrCreateLeafNode(final String id)
throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException { throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException {
try { try {
return getNode(id); return getLeafNode(id);
} }
catch (NotAPubSubNodeException e) { catch (NotAPubSubNodeException e) {
return createNode(id); return createNode(id);
@ -297,7 +294,7 @@ public final class PubSubManager extends Manager {
if (e2.getStanzaError().getCondition() == Condition.conflict) { if (e2.getStanzaError().getCondition() == Condition.conflict) {
// The node was created in the meantime, re-try getNode(). Note that this case should be rare. // The node was created in the meantime, re-try getNode(). Note that this case should be rare.
try { try {
return getNode(id); return getLeafNode(id);
} }
catch (NotAPubSubNodeException e) { catch (NotAPubSubNodeException e) {
// Should not happen // Should not happen