throw IllegalStateException when trying to finish from a non terminal state

This commit is contained in:
Daniel Gultsch 2020-05-08 18:36:52 +02:00
parent 350fc57d87
commit 285c750e69
1 changed files with 12 additions and 5 deletions

View File

@ -58,6 +58,9 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
);
private static final long BUSY_TIME_OUT = 30;
private static final List<State> TERMINATED = Arrays.asList(
State.ACCEPTED,
State.REJECTED,
State.RETRACTED,
State.TERMINATED_SUCCESS,
State.TERMINATED_DECLINED_OR_BUSY,
State.TERMINATED_CONNECTIVITY_ERROR,
@ -642,13 +645,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
try {
setupWebRTC(media, iceServers);
} catch (WebRTCWrapper.InitializationException e) {
} catch (final WebRTCWrapper.InitializationException e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize WebRTC");
webRTCWrapper.close();
//todo we havent actually initiated the session yet; so sending sessionTerminate makes no sense
//todo either we dont ring ever at all or maybe we should send a retract or something
transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE);
this.finish();;
this.finish();
return;
}
try {
@ -1142,9 +1145,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
private void finish() {
if (isTerminated()) {
this.cancelRingingTimeout();
this.webRTCWrapper.verifyClosed();
this.jingleConnectionManager.finishConnection(this);
} else {
throw new IllegalStateException(String.format("Unable to call finish from %s", this.state));
}
}
private void writeLogMessage(final State state) {