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:
parent
f599a9b8f9
commit
f4a3478d84
@ -376,27 +376,25 @@ public final class OfflineLicenseHelper {
|
|||||||
// (drmSession.state == STATE_ERROR).
|
// (drmSession.state == STATE_ERROR).
|
||||||
drmListenerConditionVariable.block();
|
drmListenerConditionVariable.block();
|
||||||
|
|
||||||
SettableFuture<@NullableType DrmSessionException> drmSessionErrorFuture =
|
SettableFuture<@NullableType DrmSessionException> drmSessionError = SettableFuture.create();
|
||||||
SettableFuture.create();
|
|
||||||
handler.post(
|
handler.post(
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
DrmSessionException drmSessionError = drmSession.getError();
|
DrmSessionException error = drmSession.getError();
|
||||||
if (drmSession.getState() == DrmSession.STATE_ERROR) {
|
if (drmSession.getState() == DrmSession.STATE_ERROR) {
|
||||||
drmSession.release(eventDispatcher);
|
drmSession.release(eventDispatcher);
|
||||||
drmSessionManager.release();
|
drmSessionManager.release();
|
||||||
}
|
}
|
||||||
drmSessionErrorFuture.set(drmSessionError);
|
drmSessionError.set(error);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
drmSessionErrorFuture.setException(e);
|
drmSessionError.setException(e);
|
||||||
drmSession.release(eventDispatcher);
|
drmSession.release(eventDispatcher);
|
||||||
drmSessionManager.release();
|
drmSessionManager.release();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
DrmSessionException drmSessionError = drmSessionErrorFuture.get();
|
if (drmSessionError.get() != null) {
|
||||||
if (drmSessionError != null) {
|
throw drmSessionError.get();
|
||||||
throw drmSessionError;
|
|
||||||
} else {
|
} else {
|
||||||
return drmSession;
|
return drmSession;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user