forked from j62/ctbrec
1
0
Fork 0

Avoid NPE in onError

This commit is contained in:
0xboobface 2018-12-17 15:21:36 +01:00
parent 5145ed0ce2
commit 47d8101ce8
1 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package ctbrec.ui.controls;
import java.io.InterruptedIOException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -161,8 +162,9 @@ public class StreamPreview extends StackPane {
private void onError(MediaPlayer videoPlayer) {
LOG.error("Error while starting preview stream", videoPlayer.getError());
if(videoPlayer.getError().getCause() != null) {
LOG.error("Error while starting preview stream root cause:", videoPlayer.getError().getCause());
Optional<Throwable> cause = Optional.ofNullable(videoPlayer).map(v -> v.getError()).map(e -> e.getCause());
if(cause.isPresent()) {
LOG.error("Error while starting preview stream root cause:", cause.get());
}
showTestImage();
}