/** * Wraps a channel exception in another providing wave and wavelet id context. */ private ChannelException exceptionWithContext(ChannelException e, WaveletId waveletId) { return new ChannelException(e.getResponseCode(), "Nested ChannelException", e, e.getRecoverable(), waveId, waveletId); }
/** * Handles failure of the view channel or an operation channel. * * @param e The exception that caused the channel to fail. */ private void onChannelException(ChannelException e) { if (e.getRecoverable() != Recoverable.RECOVERABLE) { shutdown(e.getResponseCode(), "Channel Exception", e); } else { reconnect(e); } }
/** * Tells the listener of an exception on handling server messages. Wave and * wavelet id context is attached to the exception. * * @param e exception causing failure * @param waveletId associated wavelet id (may be null) */ private void triggerOnException(ChannelException e, WaveletId waveletId) { if (openListener != null) { openListener.onException( new ChannelException(e.getResponseCode(), "Exception in view channel, state " + this, e, e.getRecoverable(), waveId, waveletId)); } }
public void testNackTooOldIsRecoverable() throws ChannelException { final long initialVersion = 0; checkedConnectChannel(initialVersion); // Submit delta. final long submitVersion = 0; final byte[] signature = sig(1); final int clientOps = 1; final WaveletDelta clientDelta = buildDelta(submitVersion, clientOps); submitDeltaOnConnectedChannel(clientDelta); // Nack delta immediately with TOO_OLD. try { nackDeltaOnConnectedChannel(submitVersion, signature, "too old", ResponseCode.TOO_OLD); fail("Expected an exception"); } catch (ChannelException e) { assertEquals(Recoverable.RECOVERABLE, e.getRecoverable()); } }
public void testNackTooOldIsRecoverable() throws ChannelException { final long initialVersion = 0; checkedConnectChannel(initialVersion); // Submit delta. final long submitVersion = 0; final byte[] signature = sig(1); final int clientOps = 1; final WaveletDelta clientDelta = buildDelta(submitVersion, clientOps); submitDeltaOnConnectedChannel(clientDelta); // Nack delta immediately with TOO_OLD. try { nackDeltaOnConnectedChannel(submitVersion, signature, "too old", ResponseCode.TOO_OLD); fail("Expected an exception"); } catch (ChannelException e) { assertEquals(Recoverable.RECOVERABLE, e.getRecoverable()); } }