Use Future.get() @Deterministic annotation in OfflineLicenseHelper

This means we don't need to manually store the result of `get()` into a
local to convince the nullness checker that it remains non-null.

PiperOrigin-RevId: 520576719
This commit is contained in:
ibaker 2023-03-30 09:07:57 +00:00 committed by Tianyi Feng
parent f599a9b8f9
commit f4a3478d84

View File

@ -376,27 +376,25 @@ public final class OfflineLicenseHelper {
// (drmSession.state == STATE_ERROR).
drmListenerConditionVariable.block();
SettableFuture<@NullableType DrmSessionException> drmSessionErrorFuture =
SettableFuture.create();
SettableFuture<@NullableType DrmSessionException> drmSessionError = SettableFuture.create();
handler.post(
() -> {
try {
DrmSessionException drmSessionError = drmSession.getError();
DrmSessionException error = drmSession.getError();
if (drmSession.getState() == DrmSession.STATE_ERROR) {
drmSession.release(eventDispatcher);
drmSessionManager.release();
}
drmSessionErrorFuture.set(drmSessionError);
drmSessionError.set(error);
} catch (Throwable e) {
drmSessionErrorFuture.setException(e);
drmSessionError.setException(e);
drmSession.release(eventDispatcher);
drmSessionManager.release();
}
});
try {
DrmSessionException drmSessionError = drmSessionErrorFuture.get();
if (drmSessionError != null) {
throw drmSessionError;
if (drmSessionError.get() != null) {
throw drmSessionError.get();
} else {
return drmSession;
}