PromiseImpl extends Promise<R> implements ActionHandle { @Override public void forget() { final ResourceCleaner<R> cleaner = mCleaner; final R result = mResult; mResult = null; mCleaner = null; if (result != null && cleaner != null) { cleaner.clean(result); } } PromiseImpl(@Nullable R result, @Nullable ResourceCleaner<R> cleaner); @Override void thenNothing(); @NonNull @Override ActionHandle then(@Nullable ResultListener<R> listener); @NonNull @Override ActionHandle then(@NonNull ActorThread thread, @Nullable ResultListener<R> listener); @Nullable @Override R get(); @Override void forget();  }
@Test public void forget_cleanRefs_always() throws Exception { PromiseImpl<Object> promise = new PromiseImpl<>(mResult, mCleaner); promise.forget(); Mockito.verify(mCleaner).clean(mResult); }