From 29233fb6c74bb78993f8898ddf54822404374e21 Mon Sep 17 00:00:00 2001 From: Matt Riben Date: Fri, 21 Feb 2025 20:25:27 -0600 Subject: [PATCH] fix: prevent null pointer exception Signed-off-by: Matt Riben --- .../java/io/javaoperatorsdk/operator/processing/MDCUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MDCUtils.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MDCUtils.java index e26df4d5a9..5717f0438e 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MDCUtils.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MDCUtils.java @@ -33,7 +33,9 @@ public static void addResourceInfo(HasMetadata resource) { if (resource.getMetadata().getNamespace() != null) { MDC.put(NAMESPACE, resource.getMetadata().getNamespace()); } - MDC.put(RESOURCE_VERSION, resource.getMetadata().getResourceVersion()); + if (resource.getMetadata().getResourceVersion() != null) { + MDC.put(RESOURCE_VERSION, resource.getMetadata().getResourceVersion()); + } if (resource.getMetadata().getGeneration() != null) { MDC.put(GENERATION, resource.getMetadata().getGeneration().toString()); }