Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import oracle.kubernetes.operator.DomainStatusUpdater;
import oracle.kubernetes.operator.MakeRightDomainOperation;
import oracle.kubernetes.operator.ProcessingConstants;
import oracle.kubernetes.operator.calls.AsyncRequestStep;
import oracle.kubernetes.operator.calls.CallResponse;
import oracle.kubernetes.operator.helpers.EventHelper.EventData;
import oracle.kubernetes.operator.helpers.EventHelper.EventItem;
Expand Down Expand Up @@ -80,12 +79,12 @@ public NextAction onSuccess(Packet packet, CallResponse<V1SecretList> callRespon
}

static List<V1Secret> getSecrets(Packet packet) {
return Optional.ofNullable(getSecretsIfContinue(packet)).orElse(new ArrayList<>());
return Optional.ofNullable(getSecretsFromPacket(packet)).orElse(new ArrayList<>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just inline (List) packet.get(SECRETS) here and remove the getSecretsFromPacket method.

}

@SuppressWarnings("unchecked")
private static List<V1Secret> getSecretsIfContinue(Packet packet) {
return packet.get(AsyncRequestStep.CONTINUE) != null ? (List<V1Secret>) packet.get(SECRETS) : null;
private static List<V1Secret> getSecretsFromPacket(Packet packet) {
return packet.get(SECRETS) != null ? (List<V1Secret>) packet.get(SECRETS) : null;
}
}

Expand All @@ -105,12 +104,12 @@ public NextAction onSuccess(Packet packet, CallResponse<V1ConfigMapList> callRes
}

static List<V1ConfigMap> getConfigMaps(Packet packet) {
return Optional.ofNullable(getConfigMapsIfContinue(packet)).orElse(new ArrayList<>());
return Optional.ofNullable(getConfigMapsFromPacket(packet)).orElse(new ArrayList<>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

}

@SuppressWarnings("unchecked")
private static List<V1ConfigMap> getConfigMapsIfContinue(Packet packet) {
return packet.get(AsyncRequestStep.CONTINUE) != null ? (List<V1ConfigMap>) packet.get(CONFIGMAPS) : null;
private static List<V1ConfigMap> getConfigMapsFromPacket(Packet packet) {
return packet.get(CONFIGMAPS) != null ? (List<V1ConfigMap>) packet.get(CONFIGMAPS) : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Dongbo's comment above is correct -- this code could be simplified or just inlined as it tests a key and then returns either the same value or null -- it could have just returned the packet.get() straight away.

}
}

Expand Down