Skip to content

Commit

Permalink
fixed npe
Browse files Browse the repository at this point in the history
  • Loading branch information
Katzen48 committed Dec 17, 2021
1 parent 4316d35 commit b35a5ff
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions shared/src/main/java/net/chrotos/ingress/minecraft/Watcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ public Watcher(PodRessourceHandler handler) throws IOException {
new ResourceEventHandler<>() {
@Override
public void onAdd(V1Pod obj) {
Stream<V1ContainerStatus> stream = Objects.requireNonNull(Objects.requireNonNull(
obj.getStatus()).getContainerStatuses()).stream()
.filter(V1ContainerStatus::getReady);
if (obj.getStatus() == null || obj.getStatus().getContainerStatuses() == null) {
return;
}

Stream<V1ContainerStatus> stream = obj.getStatus().getContainerStatuses().stream()
.filter(V1ContainerStatus::getReady);

if (stream.findAny().isPresent()) {
handler.onEventReceived(obj, false);
Expand All @@ -59,13 +62,17 @@ public void onAdd(V1Pod obj) {

@Override
public void onUpdate(V1Pod oldObj, V1Pod newObj) {
Stream<V1ContainerStatus> oldStream = Objects.requireNonNull(Objects.requireNonNull(
oldObj.getStatus()).getContainerStatuses()).stream()
.filter(V1ContainerStatus::getReady);
if (oldObj.getStatus() == null || newObj.getStatus() == null
|| oldObj.getStatus().getContainerStatuses() == null
|| newObj.getStatus().getContainerStatuses() == null) {
return;
}

Stream<V1ContainerStatus> oldStream = oldObj.getStatus().getContainerStatuses().stream()
.filter(V1ContainerStatus::getReady);

Stream<V1ContainerStatus> newStream = Objects.requireNonNull(Objects.requireNonNull(
newObj.getStatus()).getContainerStatuses()).stream()
.filter(V1ContainerStatus::getReady);
Stream<V1ContainerStatus> newStream = newObj.getStatus().getContainerStatuses().stream()
.filter(V1ContainerStatus::getReady);

if (!oldStream.findAny().isPresent() && newStream.findAny().isPresent()) {
handler.onEventReceived(newObj, false);
Expand Down

0 comments on commit b35a5ff

Please sign in to comment.