From 5ab567d51f8fdadecb3329e5d2dd9274313b3bc0 Mon Sep 17 00:00:00 2001 From: chathuranga95 Date: Mon, 12 Feb 2024 15:18:32 +0530 Subject: [PATCH] Fix empty pipeline checking logic --- .../java/org/ballerinalang/mongodb/MongoDBCollectionUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/main/java/org/ballerinalang/mongodb/MongoDBCollectionUtil.java b/native/src/main/java/org/ballerinalang/mongodb/MongoDBCollectionUtil.java index aed0e4b..e76b5fb 100644 --- a/native/src/main/java/org/ballerinalang/mongodb/MongoDBCollectionUtil.java +++ b/native/src/main/java/org/ballerinalang/mongodb/MongoDBCollectionUtil.java @@ -53,9 +53,9 @@ public class MongoDBCollectionUtil { public static Object countDocuments(BHandle collection, Object filter, BArray pipeline) { MongoCollection mongoCollection = (MongoCollection) collection.getValue(); try { - if (pipeline != null) { + long pipelineLength = pipeline.getLength(); + if (pipelineLength != 0) { List pipelineDoc = new ArrayList<>(); - long pipelineLength = pipeline.getLength(); for (int i = 0; i < pipelineLength; i++) { pipelineDoc.add(Document.parse(pipeline.get(i).toString())); }