From a19ca2b180445107f4b1cbed408449752ff4f635 Mon Sep 17 00:00:00 2001 From: Rudi Schlatte Date: Thu, 1 Aug 2024 12:00:24 +0200 Subject: [PATCH] Handle null value when parsing kubevela string This was the root cause of https://github.com/eu-nebulous/optimiser-utility-evaluator/issues/5 --- .../eu/nebulouscloud/optimiser/kubevela/KubevelaAnalyzer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nebulous-requirements-extractor/src/main/java/eu/nebulouscloud/optimiser/kubevela/KubevelaAnalyzer.java b/nebulous-requirements-extractor/src/main/java/eu/nebulouscloud/optimiser/kubevela/KubevelaAnalyzer.java index ecc19c0..dc46948 100644 --- a/nebulous-requirements-extractor/src/main/java/eu/nebulouscloud/optimiser/kubevela/KubevelaAnalyzer.java +++ b/nebulous-requirements-extractor/src/main/java/eu/nebulouscloud/optimiser/kubevela/KubevelaAnalyzer.java @@ -1,6 +1,7 @@ package eu.nebulouscloud.optimiser.kubevela; +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -494,6 +495,9 @@ public static Map> getBoundedRequirements(String kubev * @throws JsonProcessingException if kubevela does not contain valid YAML. */ public static JsonNode parseKubevela(String kubevela) throws JsonProcessingException { + if (kubevela == null) { + throw new JsonParseException("The provided string value was null"); + } return yamlMapper.readTree(kubevela); }