From 153aa48c6945cfc54ceb1b3f6a38508ad93f1d16 Mon Sep 17 00:00:00 2001
From: danielhanrahan <daniel.hanrahan@est.tech>
Date: Wed, 2 Oct 2024 21:31:04 +0100
Subject: [BUG] Fix memory leak related to using arrays in Hibernate

The use of arrays like String[] instead of Collection<String> in
JpaRepository methods is causing a memory leak, most likely due to a
bug in the hypersistence-utils dependency which provides the feature.
Note code using arrays in JDBC (via jdbcTemplate) is not affected.

This patch removes most uses of arrays in Java, except one needed for
FragmentPrefetchRepository using JDBC setArray(), which is safe.

Issue-ID: CPS-2430
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I94f8c3d4c8c32ebe0978c08d3226a196a95bf3b9
---
 .../src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java    | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

(limited to 'cps-path-parser/src/main/java/org/onap')

diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
index bde9b0638f..4ede0d9c90 100644
--- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
+++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023 Nordix Foundation
+ *  Copyright (C) 2022-2024 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -59,12 +59,10 @@ public class CpsPathUtil {
         return getCpsPathBuilder(xpathSource).build().getNormalizedParentPath();
     }
 
-    public static String[] getXpathNodeIdSequence(final String xpathSource) {
-        final List<String> containerNames = getCpsPathBuilder(xpathSource).build().getContainerNames();
-        return containerNames.toArray(new String[containerNames.size()]);
+    public static List<String> getXpathNodeIdSequence(final String xpathSource) {
+        return getCpsPathBuilder(xpathSource).build().getContainerNames();
     }
 
-
     /**
      * Returns boolean indicating xpath is an absolute path to a list element.
      *
-- 
cgit