@Test(timeout = 10000) public void testOnFailure() { ProviderFuture future = futuresFactory.createFuture(); ProviderException ex = new ProviderException("Failed"); future.onFailure(ex); try { future.sync(5, TimeUnit.SECONDS); fail("Should throw an error"); } catch (ProviderException cause) { assertSame(cause, ex); } }
@Override public void onFailure(ProviderException result) { if (STATE_FIELD_UPDATER.compareAndSet(this, INCOMPLETE, COMPLETING)) { error = result; if (synchronization != null) { synchronization.onPendingFailure(error); } STATE_FIELD_UPDATER.lazySet(this, FAILURE); synchronized(this) { if (waiting > 0) { notifyAll(); } } } }
ProviderFuture implements AsyncResult { @Override public void onFailure(ProviderException result) { if (STATE_FIELD_UPDATER.compareAndSet(this, INCOMPLETE, COMPLETING)) { error = result; if (synchronization != null) { synchronization.onPendingFailure(error); } STATE_FIELD_UPDATER.lazySet(this, FAILURE); synchronized(this) { if (waiting > 0) { notifyAll(); } } } } }
ProviderFuture implements AsyncResult { @Override public void onFailure(ProviderException result) { if (STATE_FIELD_UPDATER.compareAndSet(this, INCOMPLETE, COMPLETING)) { error = result; if (synchronization != null) { synchronization.onPendingFailure(error); } STATE_FIELD_UPDATER.lazySet(this, FAILURE); synchronized(this) { if (waiting > 0) { notifyAll(); } } } } ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); }
ProviderFuture implements AsyncResult { @Override public void onFailure(ProviderException result) { if (STATE_FIELD_UPDATER.compareAndSet(this, INCOMPLETE, COMPLETING)) { error = result; if (synchronization != null) { synchronization.onPendingFailure(error); } STATE_FIELD_UPDATER.lazySet(this, FAILURE); synchronized(this) { if (waiting > 0) { notifyAll(); } } } } ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); @Override boolean isComplete(); @Override void onFailure(ProviderException result); @Override void onSuccess(); abstract void sync(); abstract boolean sync(long amount, TimeUnit unit); }
ProviderFuture implements AsyncResult { @Override public void onFailure(ProviderException result) { if (STATE_FIELD_UPDATER.compareAndSet(this, INCOMPLETE, COMPLETING)) { error = result; if (synchronization != null) { synchronization.onPendingFailure(error); } STATE_FIELD_UPDATER.lazySet(this, FAILURE); synchronized(this) { if (waiting > 0) { notifyAll(); } } } } ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); @Override boolean isComplete(); @Override void onFailure(ProviderException result); @Override void onSuccess(); abstract void sync(); abstract boolean sync(long amount, TimeUnit unit);  }