From bd323ad69ad6978d4eda77f4c94a9f5f12c9ba90 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Fri, 29 Mar 2024 18:12:52 +0200 Subject: [PATCH] Avoid a very rare case, where we might get an "IllegalArgumentException" from "Lists.partition()", in case the "sizeOfUrlReports" is <= 3. --- .../java/eu/openaire/urls_controller/util/ParquetFileUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java b/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java index 6e23478..dc63ae5 100644 --- a/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java +++ b/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java @@ -192,6 +192,8 @@ public class ParquetFileUtils { // In case the above method returns an error, nothing happens. We just have only the initial payloads to insert to the DB. int sizeOfEachSubList = (int)(sizeOfUrlReports * 0.33); // We want 3 sub-lists for the payloads. + if ( sizeOfEachSubList == 0 ) // If the "sizeOfUrlReports" is <= 3. + sizeOfEachSubList = 1; // There may be 1 more with very few elements, due to non-persisted splitting. Unfortunately, we cannot st the number of splits, only the size of most splits. if ( sizeOfEachSubList > 10 ) { List> finalSubLists = Lists.partition(urlReports, sizeOfEachSubList); // This needs the "sizeOfEachSubList" to be above < 0 >.