mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01:00
Expose InterruptedException
SMACK-632
This commit is contained in:
parent
43b99a2a85
commit
bc61527bd2
124 changed files with 977 additions and 597 deletions
|
|
@ -62,7 +62,8 @@ public interface BytestreamRequest {
|
|||
/**
|
||||
* Rejects the bytestream request by sending a reject error to the initiator.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void reject() throws NotConnectedException;
|
||||
public void reject() throws NotConnectedException, InterruptedException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class CloseListener extends AbstractIqRequestHandler {
|
|||
try {
|
||||
this.manager.replyItemNotFoundPacket(closeRequest);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ class CloseListener extends AbstractIqRequestHandler {
|
|||
try {
|
||||
ibbSession.closeByPeer(closeRequest);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
return null;
|
||||
}
|
||||
this.manager.getSessions().remove(closeRequest.getSessionID());
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DataListener implements PacketListener {
|
|||
this.manager = manager;
|
||||
}
|
||||
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
Data data = (Data) packet;
|
||||
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
|
||||
data.getDataPacketExtension().getSessionID());
|
||||
|
|
|
|||
|
|
@ -399,8 +399,9 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
* @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the
|
||||
* user prefers smaller block sizes
|
||||
* @throws SmackException if there was no response from the server.
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public InBandBytestreamSession establishSession(String targetJID) throws XMPPException, SmackException {
|
||||
public InBandBytestreamSession establishSession(String targetJID) throws XMPPException, SmackException, InterruptedException {
|
||||
String sessionID = getNextSessionID();
|
||||
return establishSession(targetJID, sessionID);
|
||||
}
|
||||
|
|
@ -416,9 +417,10 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
* user prefers smaller block sizes
|
||||
* @throws NoResponseException if there was no response from the server.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
|
||||
byteStreamRequest.setTo(targetJID);
|
||||
|
||||
|
|
@ -438,8 +440,9 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param request IQ packet that should be answered with a not-acceptable error
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected void replyRejectPacket(IQ request) throws NotConnectedException {
|
||||
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
|
|
@ -451,8 +454,9 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param request IQ packet that should be answered with a resource-constraint error
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
|
||||
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
|
|
@ -464,8 +468,9 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param request IQ packet that should be answered with a item-not-found error
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
|
||||
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
|
|
|
|||
|
|
@ -68,8 +68,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
*
|
||||
* @return the session to send/receive data
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public InBandBytestreamSession accept() throws NotConnectedException {
|
||||
public InBandBytestreamSession accept() throws NotConnectedException, InterruptedException {
|
||||
XMPPConnection connection = this.manager.getConnection();
|
||||
|
||||
// create In-Band Bytestream session and store it
|
||||
|
|
@ -88,8 +89,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
* Rejects the In-Band Bytestream request by sending a reject error to the
|
||||
* initiator.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void reject() throws NotConnectedException {
|
||||
public void reject() throws NotConnectedException, InterruptedException {
|
||||
this.manager.replyRejectPacket(this.byteStreamRequest);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,8 +160,9 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*
|
||||
* @param closeRequest the close request from the remote peer
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected void closeByPeer(Close closeRequest) throws NotConnectedException {
|
||||
protected void closeByPeer(Close closeRequest) throws NotConnectedException, InterruptedException {
|
||||
|
||||
/*
|
||||
* close streams without flushing them, because stream is already considered closed on the
|
||||
|
|
@ -447,7 +448,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
private long lastSequence = -1;
|
||||
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = ((Data) packet).getDataPacketExtension();
|
||||
|
||||
|
|
@ -613,8 +614,9 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* @param data the data packet
|
||||
* @throws IOException if an I/O error occurred while sending or if the stream is closed
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected abstract void writeToXML(DataPacketExtension data) throws IOException, NotConnectedException;
|
||||
protected abstract void writeToXML(DataPacketExtension data) throws IOException, NotConnectedException, InterruptedException;
|
||||
|
||||
public synchronized void write(int b) throws IOException {
|
||||
if (this.isClosed) {
|
||||
|
|
@ -718,7 +720,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
try {
|
||||
writeToXML(data);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
IOException ioException = new IOException();
|
||||
ioException.initCause(e);
|
||||
throw ioException;
|
||||
|
|
@ -803,7 +805,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
private class MessageIBBOutputStream extends IBBOutputStream {
|
||||
|
||||
@Override
|
||||
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException {
|
||||
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException, InterruptedException {
|
||||
// create message stanza containing data packet
|
||||
Message message = new Message(remoteJID);
|
||||
message.addExtension(data);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class InitiationListener extends AbstractIqRequestHandler {
|
|||
try {
|
||||
processRequest(packet);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
LOGGER.log(Level.WARNING, "proccessRequest", e);
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ class InitiationListener extends AbstractIqRequestHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void processRequest(Stanza packet) throws NotConnectedException {
|
||||
private void processRequest(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
Open ibbRequest = (Open) packet;
|
||||
|
||||
// validate that block size is within allowed range
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
try {
|
||||
processRequest(packet);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
catch (InterruptedException | NotConnectedException e) {
|
||||
LOGGER.log(Level.WARNING, "process request", e);
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void processRequest(Stanza packet) throws NotConnectedException {
|
||||
private void processRequest(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
Bytestream byteStreamRequest = (Bytestream) packet;
|
||||
|
||||
// ignore request if in ignore list
|
||||
|
|
|
|||
|
|
@ -527,8 +527,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, Bytestream.NAMESPACE);
|
||||
}
|
||||
|
||||
|
|
@ -540,8 +541,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
* @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies
|
||||
* @throws NoResponseException if there was no response from the server.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
|
||||
|
||||
List<String> proxies = new ArrayList<String>();
|
||||
|
|
@ -700,8 +702,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param packet Packet that should be answered with a not-acceptable error
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected void replyRejectPacket(IQ packet) throws NotConnectedException {
|
||||
protected void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
|
||||
this.connection.sendPacket(errorIQ);
|
||||
|
|
|
|||
|
|
@ -267,8 +267,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
/**
|
||||
* Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void reject() throws NotConnectedException {
|
||||
public void reject() throws NotConnectedException, InterruptedException {
|
||||
this.manager.replyRejectPacket(this.bytestreamRequest);
|
||||
}
|
||||
|
||||
|
|
@ -277,8 +278,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
* XMPP exception.
|
||||
* @throws XMPPErrorException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private void cancelRequest() throws XMPPErrorException, NotConnectedException {
|
||||
private void cancelRequest() throws XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
String errorMessage = "Could not establish socket with any provided host";
|
||||
XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
|
||||
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ class Socks5ClientForInitiator extends Socks5Client {
|
|||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @throws SmackException if there was no response from the server.
|
||||
*/
|
||||
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Bytestream activate = createStreamHostActivation();
|
||||
// if activation fails #nextResultOrThrow() throws an exception
|
||||
connection.createPacketCollectorAndSend(activate).nextResultOrThrow();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue