From f42b439acb43eaea999358db10168edd164646d3 Mon Sep 17 00:00:00 2001 From: Matteo Saloni Date: Mon, 13 May 2024 17:05:17 +0200 Subject: [PATCH] fix: fix name in pom + fix nullpointer in k8serve --- application/pom.xml | 2 +- .../infrastructure/k8s/K8sServeFramework.java | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/application/pom.xml b/application/pom.xml index c61f6754..f69f2dc6 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -17,7 +17,7 @@ it.smartcommunitylabdhub core - core + dhcore ${revision} Digital Hub Core diff --git a/modules/framework-k8s/src/main/java/it/smartcommunitylabdhub/framework/k8s/infrastructure/k8s/K8sServeFramework.java b/modules/framework-k8s/src/main/java/it/smartcommunitylabdhub/framework/k8s/infrastructure/k8s/K8sServeFramework.java index e4861d1c..d81d23bc 100644 --- a/modules/framework-k8s/src/main/java/it/smartcommunitylabdhub/framework/k8s/infrastructure/k8s/K8sServeFramework.java +++ b/modules/framework-k8s/src/main/java/it/smartcommunitylabdhub/framework/k8s/infrastructure/k8s/K8sServeFramework.java @@ -119,12 +119,18 @@ public V1Service build(K8sServeRunnable runnable) throws K8sFrameworkException { } //build ports - List ports = runnable - .getServicePorts() - .stream() - .filter(p -> p.port() != null && p.targetPort() != null) - .map(p -> new V1ServicePort().port(p.port()).targetPort(new IntOrString(p.targetPort())).protocol("TCP")) - .collect(Collectors.toList()); + List ports = Optional + .ofNullable(runnable.getServicePorts()) + .map(list -> + list + .stream() + .filter(p -> p.port() != null && p.targetPort() != null) + .map(p -> + new V1ServicePort().port(p.port()).targetPort(new IntOrString(p.targetPort())).protocol("TCP") + ) + .collect(Collectors.toList()) + ) + .orElse(null); // service type (ClusterIP or NodePort) String type = Optional.of(runnable.getServiceType().name()).orElse("NodePort");