Fix deferred null.

This commit is contained in:
Koen 2023-10-20 12:20:56 +02:00
commit 242728fbe7

View file

@ -61,9 +61,21 @@ public class PolycentricModelLoader implements ModelLoader<String, ByteBuffer> {
_deferred.invokeOnCompletion(throwable -> { _deferred.invokeOnCompletion(throwable -> {
if (throwable != null) { if (throwable != null) {
callback.onLoadFailed(new Exception(throwable)); callback.onLoadFailed(new Exception(throwable));
return Unit.INSTANCE;
} }
final ByteBuffer completed = _deferred.getCompleted();
Deferred<ByteBuffer> deferred = _deferred;
if (deferred == null) {
callback.onLoadFailed(new Exception("Deferred is null"));
return Unit.INSTANCE;
}
ByteBuffer completed = deferred.getCompleted();
if (completed != null) {
callback.onDataReady(completed); callback.onDataReady(completed);
} else {
callback.onLoadFailed(new Exception("Completed is null"));
}
return Unit.INSTANCE; return Unit.INSTANCE;
}); });
} }