mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Expose InterruptedException
SMACK-632
This commit is contained in:
parent
43b99a2a85
commit
bc61527bd2
124 changed files with 977 additions and 597 deletions
|
@ -91,8 +91,9 @@ public class Chat {
|
|||
*
|
||||
* @param text the text to send.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendMessage(String text) throws NotConnectedException {
|
||||
public void sendMessage(String text) throws NotConnectedException, InterruptedException {
|
||||
Message message = new Message();
|
||||
message.setBody(text);
|
||||
sendMessage(message);
|
||||
|
@ -104,8 +105,9 @@ public class Chat {
|
|||
*
|
||||
* @param message the message to send.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendMessage(Message message) throws NotConnectedException {
|
||||
public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
|
||||
// Force the recipient, message type, and thread ID since the user elected
|
||||
// to send the message through this chat object.
|
||||
message.setTo(participant);
|
||||
|
|
|
@ -351,7 +351,7 @@ public class ChatManager extends Manager{
|
|||
chat.deliver(message);
|
||||
}
|
||||
|
||||
void sendMessage(Chat chat, Message message) throws NotConnectedException {
|
||||
void sendMessage(Chat chat, Message message) throws NotConnectedException, InterruptedException {
|
||||
for(Map.Entry<MessageListener, PacketFilter> interceptor : interceptors.entrySet()) {
|
||||
PacketFilter filter = interceptor.getValue();
|
||||
if(filter != null && filter.accept(message)) {
|
||||
|
|
|
@ -211,7 +211,7 @@ public class Roster extends Manager {
|
|||
try {
|
||||
Roster.this.reload();
|
||||
}
|
||||
catch (SmackException e) {
|
||||
catch (InterruptedException | SmackException e) {
|
||||
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
|
||||
return;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class Roster extends Manager {
|
|||
try {
|
||||
reload();
|
||||
}
|
||||
catch (SmackException e) {
|
||||
catch (InterruptedException | SmackException e) {
|
||||
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +271,9 @@ public class Roster extends Manager {
|
|||
* reloaded at a later point when the server responds to the reload request.
|
||||
* @throws NotLoggedInException If not logged in.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void reload() throws NotLoggedInException, NotConnectedException{
|
||||
public void reload() throws NotLoggedInException, NotConnectedException, InterruptedException{
|
||||
final XMPPConnection connection = connection();
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new NotLoggedInException();
|
||||
|
@ -298,9 +299,10 @@ public class Roster extends Manager {
|
|||
*
|
||||
* @throws NotLoggedInException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @since 4.1
|
||||
*/
|
||||
public void reloadAndWait() throws NotLoggedInException, NotConnectedException {
|
||||
public void reloadAndWait() throws NotLoggedInException, NotConnectedException, InterruptedException {
|
||||
reload();
|
||||
waitUntilLoaded();
|
||||
}
|
||||
|
@ -317,14 +319,14 @@ public class Roster extends Manager {
|
|||
try {
|
||||
reload();
|
||||
}
|
||||
catch (NotLoggedInException | NotConnectedException e) {
|
||||
catch (InterruptedException | NotLoggedInException | NotConnectedException e) {
|
||||
LOGGER.log(Level.FINER, "Could not reload roster", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean waitUntilLoaded() {
|
||||
protected boolean waitUntilLoaded() throws InterruptedException {
|
||||
final XMPPConnection connection = connection();
|
||||
while (!loaded) {
|
||||
long waitTime = connection.getPacketReplyTimeout();
|
||||
|
@ -332,17 +334,11 @@ public class Roster extends Manager {
|
|||
if (waitTime <= 0) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
synchronized (this) {
|
||||
if (!loaded) {
|
||||
wait(waitTime);
|
||||
}
|
||||
synchronized (this) {
|
||||
if (!loaded) {
|
||||
wait(waitTime);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOGGER.log(Level.FINE, "interrupted", e);
|
||||
break;
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
waitTime -= now - start;
|
||||
start = now;
|
||||
|
@ -423,8 +419,9 @@ public class Roster extends Manager {
|
|||
* @throws XMPPErrorException if an XMPP exception occurs.
|
||||
* @throws NotLoggedInException If not logged in.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void createEntry(String user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
public void createEntry(String user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
final XMPPConnection connection = connection();
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new NotLoggedInException();
|
||||
|
@ -464,9 +461,10 @@ public class Roster extends Manager {
|
|||
* @throws NotLoggedInException if not logged in.
|
||||
* @throws NoResponseException SmackException if there was no response from the server.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @throws IllegalStateException if connection is not logged in or logged in anonymously
|
||||
*/
|
||||
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
final XMPPConnection connection = connection();
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new NotLoggedInException();
|
||||
|
@ -913,7 +911,7 @@ public class Roster extends Manager {
|
|||
*/
|
||||
private void setOfflinePresencesAndResetLoaded() {
|
||||
Presence packetUnavailable;
|
||||
for (String user : presenceMap.keySet()) {
|
||||
outerloop: for (String user : presenceMap.keySet()) {
|
||||
Map<String, Presence> resources = presenceMap.get(user);
|
||||
if (resources != null) {
|
||||
for (String resource : resources.keySet()) {
|
||||
|
@ -927,6 +925,9 @@ public class Roster extends Manager {
|
|||
"presencePakcetListener should never throw a NotConnectedException when processPacket is called with a presence of type unavailable",
|
||||
e);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1140,7 +1141,7 @@ public class Roster extends Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
final XMPPConnection connection = connection();
|
||||
Presence presence = (Presence) packet;
|
||||
String from = presence.getFrom();
|
||||
|
|
|
@ -93,8 +93,9 @@ public class RosterEntry {
|
|||
* @throws NotConnectedException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException {
|
||||
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
|
||||
// Do nothing if the name hasn't changed.
|
||||
if (name != null && name.equals(this.name)) {
|
||||
return;
|
||||
|
|
|
@ -75,8 +75,9 @@ public class RosterGroup {
|
|||
* @throws NotConnectedException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException {
|
||||
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
|
||||
synchronized (entries) {
|
||||
for (RosterEntry entry : entries) {
|
||||
RosterPacket packet = new RosterPacket();
|
||||
|
@ -169,8 +170,9 @@ public class RosterGroup {
|
|||
* @throws XMPPErrorException if an error occured while trying to add the entry to the group.
|
||||
* @throws NoResponseException if there was no response from the server.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
public void addEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PacketCollector collector = null;
|
||||
// Only add the entry if it isn't already in the list.
|
||||
synchronized (entries) {
|
||||
|
@ -200,8 +202,9 @@ public class RosterGroup {
|
|||
* @throws XMPPErrorException if an error occurred while trying to remove the entry from the group.
|
||||
* @throws NoResponseException if there was no response from the server.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PacketCollector collector = null;
|
||||
// Only remove the entry if it's in the entry list.
|
||||
// Remove the entry locally, if we wait for RosterPacketListenerprocess>>Packet(Packet)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue