1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02: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.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);
}

View file

@ -233,7 +233,6 @@ public final class PubSubManager extends Manager {
* exception if it does not.
*
* @param id - The unique id of the node
* @param <T> 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 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);
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