From 208e91cdfe96985e5d0a91623b385ab2ad4e4dc7 Mon Sep 17 00:00:00 2001 From: Roman Zolotov Date: Tue, 11 Oct 2022 12:35:50 +0300 Subject: [PATCH] ADBDEV-3096: Add function to split value --- .../OracleParallelSessionParamFactory.java | 19 +++++++++++-------- ...OracleParallelSessionParamFactoryTest.java | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/pxf-jdbc/src/main/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactory.java b/server/pxf-jdbc/src/main/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactory.java index 1ab24736f9..38285539f9 100644 --- a/server/pxf-jdbc/src/main/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactory.java +++ b/server/pxf-jdbc/src/main/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactory.java @@ -7,9 +7,9 @@ public class OracleParallelSessionParamFactory { public OracleParallelSessionParam create(String property, String value, String delimiter) { - validateValue(property, value, delimiter); + String[] values = splitValue(property, value, delimiter); - HashMap map = getParallelSessionParam(value.split(delimiter)); + HashMap map = getParallelSessionParam(values); String clause = map.get("clause").toUpperCase(); String statementType = map.get("statement_type").toUpperCase(); String degreeOfParallelism = map.get("degree_of_parallelism"); @@ -21,12 +21,8 @@ public OracleParallelSessionParam create(String property, String value, String d return param; } - private void validateValue(String property, String value, String delimiter) { - if (StringUtils.isBlank(value)) { - throw new IllegalArgumentException(String.format( - "The parameter '%s' is empty in jdbc-site.xml", property) - ); - } + private String[] splitValue(String property, String value, String delimiter) { + validateValue(property, value); String[] values = value.split(delimiter); if (values.length < 2 || values.length > 3) { throw new IllegalArgumentException(String.format( @@ -34,6 +30,13 @@ private void validateValue(String property, String value, String delimiter) { property, delimiter) ); } + return values; + } + + private void validateValue(String property, String value) { + if (StringUtils.isBlank(value)) { + throw new IllegalArgumentException(String.format("The parameter '%s' is blank in jdbc-site.xml", property)); + } } private HashMap getParallelSessionParam(String[] values) { diff --git a/server/pxf-jdbc/src/test/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactoryTest.java b/server/pxf-jdbc/src/test/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactoryTest.java index 31faf25479..840d56dd7d 100644 --- a/server/pxf-jdbc/src/test/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactoryTest.java +++ b/server/pxf-jdbc/src/test/java/org/greenplum/pxf/plugins/jdbc/utils/oracle/OracleParallelSessionParamFactoryTest.java @@ -103,7 +103,7 @@ void createWithBlankValue() { String value = " "; Exception exception = assertThrows(IllegalArgumentException.class, () -> oracleParallelSessionParamFactory.create(property, value, delimiter)); - String expectedMessage = "The parameter 'jdbc.session.property.alter_session_parallel.1' is empty in jdbc-site.xml"; + String expectedMessage = "The parameter 'jdbc.session.property.alter_session_parallel.1' is blank in jdbc-site.xml"; String actualMessage = exception.getMessage(); assertEquals(expectedMessage, actualMessage); }