mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
Make synchronization point return the exception
instead of a boolean value.
This commit is contained in:
parent
72972dad82
commit
989076a166
1 changed files with 10 additions and 9 deletions
|
@ -68,9 +68,9 @@ public class SynchronizationPoint<E extends Exception> {
|
|||
* @param request the plain stream element to send.
|
||||
* @throws NoResponseException if no response was received.
|
||||
* @throws NotConnectedException if the connection is not connected.
|
||||
* @return <code>true</code> if synchronization point was successful, <code>false</code> on failure.
|
||||
* @return <code>null</code> if synchronization point was successful, or the failure Exception.
|
||||
*/
|
||||
public boolean sendAndWaitForResponse(TopLevelStreamElement request) throws NoResponseException,
|
||||
public E sendAndWaitForResponse(TopLevelStreamElement request) throws NoResponseException,
|
||||
NotConnectedException, InterruptedException {
|
||||
assert (state == State.Initial);
|
||||
connectionLock.lock();
|
||||
|
@ -133,17 +133,17 @@ public class SynchronizationPoint<E extends Exception> {
|
|||
* Check if this synchronization point is successful or wait the connections reply timeout.
|
||||
* @throws NoResponseException if there was no response marking the synchronization point as success or failed.
|
||||
* @throws InterruptedException
|
||||
* @return <code>true</code> if synchronization point was successful, <code>false</code> on failure.
|
||||
* @return <code>null</code> if synchronization point was successful, or the failure Exception.
|
||||
*/
|
||||
public boolean checkIfSuccessOrWait() throws NoResponseException, InterruptedException {
|
||||
public E checkIfSuccessOrWait() throws NoResponseException, InterruptedException {
|
||||
connectionLock.lock();
|
||||
try {
|
||||
switch (state) {
|
||||
// Return immediately on success or failure
|
||||
case Success:
|
||||
return true;
|
||||
return null;
|
||||
case Failure:
|
||||
return false;
|
||||
return failureException;
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
|
@ -249,18 +249,19 @@ public class SynchronizationPoint<E extends Exception> {
|
|||
* <p>
|
||||
* The exception is thrown, if state is one of 'Initial', 'NoResponse' or 'RequestSent'
|
||||
* </p>
|
||||
* @return <code>true</code> if synchronization point was successful, <code>false</code> on failure.
|
||||
* @throws NoResponseException
|
||||
*/
|
||||
private boolean checkForResponse() throws NoResponseException {
|
||||
private E checkForResponse() throws NoResponseException {
|
||||
switch (state) {
|
||||
case Initial:
|
||||
case NoResponse:
|
||||
case RequestSent:
|
||||
throw NoResponseException.newWith(connection, waitFor);
|
||||
case Success:
|
||||
return true;
|
||||
return null;
|
||||
case Failure:
|
||||
return false;
|
||||
return failureException;
|
||||
default:
|
||||
throw new AssertionError("Unknown state " + state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue