From 9fbc08391a1dca2f948597a790c03b05823b7581 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Thu, 29 Jun 2023 15:49:36 +0800 Subject: [PATCH] fix NPE for transform aggregations (#830) Signed-off-by: Hailong Cui --- .../opensearch/indexmanagement/transform/model/Transform.kt | 4 +++- .../opensearch/indexmanagement/transform/TransformRunnerIT.kt | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt index b6ed9357d..38925d65d 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt @@ -363,7 +363,9 @@ data class Transform( groups.add(Dimension.parse(xcp)) } } - AGGREGATIONS_FIELD -> aggregations = AggregatorFactories.parseAggregators(xcp) + AGGREGATIONS_FIELD -> { + AggregatorFactories.parseAggregators(xcp)?.let { aggregations = it } + } CONTINUOUS_FIELD -> continuous = xcp.booleanValue() USER_FIELD -> { user = if (xcp.currentToken() == Token.VALUE_NULL) null else User.parse(xcp) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt index f41e2e935..b0870005b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt @@ -321,7 +321,7 @@ class TransformRunnerIT : TransformRestTestCase() { assertTrue("Target transform index was not created", indexExists(transform.targetIndex)) } - waitFor(Instant.ofEpochSecond(60)) { + waitFor(Instant.ofEpochSecond(180)) { val transformJob = getTransform(transformId = transform.id) assertNotNull("Transform job doesn't have metadata set", transformJob.metadataId) val transformMetadata = getTransformMetadata(transformJob.metadataId!!) @@ -504,7 +504,7 @@ class TransformRunnerIT : TransformRestTestCase() { assertTrue("Target transform index was not created", indexExists(transform.targetIndex)) } - waitFor(Instant.ofEpochSecond(60)) { + waitFor(Instant.ofEpochSecond(180)) { val transformJob = getTransform(transformId = transform.id) assertNotNull("Transform job doesn't have metadata set", transformJob.metadataId) val transformMetadata = getTransformMetadata(transformJob.metadataId!!)