From 0e9cfc01a81b68e81d05c4294906e1ce742d68b4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 23 Jul 2024 23:19:28 +0000 Subject: [PATCH] Fix SparkSubmitParameterModifier issue (#2837) (#2839) (cherry picked from commit 607354c90cad2308fc1d6278684534f152305276) Signed-off-by: Tomoyuki Morita Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] (cherry picked from commit bebf31aaa00e3924c312ec1cd3ed0e68d7676135) Signed-off-by: github-actions[bot] --- .../sql/spark/parameter/SparkSubmitParametersBuilder.java | 4 +++- .../spark/parameter/SparkSubmitParametersBuilderTest.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java index 01a665a485..3fe7d99373 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java @@ -154,7 +154,9 @@ public SparkSubmitParametersBuilder sessionExecution(String sessionId, String da } public SparkSubmitParametersBuilder acceptModifier(SparkSubmitParameterModifier modifier) { - modifier.modifyParameters(this); + if (modifier != null) { + modifier.modifyParameters(this); + } return this; } diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java index 3f4bea02f2..8947cb61f7 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java @@ -152,6 +152,11 @@ public void testAcceptModifier() { verify(sparkSubmitParameterModifier).modifyParameters(sparkSubmitParametersBuilder); } + @Test + public void testAcceptNullModifier() { + sparkSubmitParametersBuilder.acceptModifier(null); + } + @Test public void testDataSource() { when(sparkParameterComposerCollection.isComposerRegistered(DataSourceType.S3GLUE))