From 96df1d5afec1d372001d55f1a069daf104ea5481 Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Wed, 7 Mar 2018 16:54:24 +0100 Subject: [PATCH] Fix UDF parsing from the configuration file. The end of the description of a UDF was not detected when this UDF was followed by another UDF definition. This was due to an incorrect double quote escape in the regular expression of a UDF's definition. --- buildTAP.xml | 2 +- src/tap/config/ConfigurableServiceConnection.java | 4 ++-- .../config/TestConfigurableServiceConnection.java | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/buildTAP.xml b/buildTAP.xml index dbedbec..65414d8 100644 --- a/buildTAP.xml +++ b/buildTAP.xml @@ -2,7 +2,7 @@ <!DOCTYPE project> <project name="tap" basedir="." default="buildLib"> - <property name="version" value="2.2" /> + <property name="version" value="2.3" /> <property name="srcDir" value="src" /> <property name="testDir" value="test" /> diff --git a/src/tap/config/ConfigurableServiceConnection.java b/src/tap/config/ConfigurableServiceConnection.java index f624992..bd3a994 100644 --- a/src/tap/config/ConfigurableServiceConnection.java +++ b/src/tap/config/ConfigurableServiceConnection.java @@ -129,7 +129,7 @@ import uws.service.log.UWSLog.LogLevel; * </p> * * @author Grégory Mantelet (ARI) - * @version 2.1 (02/2018) + * @version 2.3 (03/2018) * @since 2.0 */ public final class ConfigurableServiceConnection implements ServiceConnection { @@ -1124,7 +1124,7 @@ public final class ConfigurableServiceConnection implements ServiceConnection { private final String REGEXP_CLASSPATH = "\\{[^{}]*\\}"; - private final String REGEXP_DESCRIPTION = "\"((\\\"|[^\"])*)\""; + private final String REGEXP_DESCRIPTION = "\"((\\\\\"|[^\"])*)\""; private final String REGEXP_UDF = "\\[\\s*(" + REGEXP_SIGNATURE + ")\\s*(,\\s*(" + REGEXP_CLASSPATH + ")?\\s*(,\\s*(" + REGEXP_DESCRIPTION + ")?\\s*)?)?\\]"; diff --git a/test/tap/config/TestConfigurableServiceConnection.java b/test/tap/config/TestConfigurableServiceConnection.java index 45a2390..23ce7cb 100644 --- a/test/tap/config/TestConfigurableServiceConnection.java +++ b/test/tap/config/TestConfigurableServiceConnection.java @@ -308,7 +308,7 @@ public class TestConfigurableServiceConnection { udfsWithClassNameProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}]"); udfsWithClassNameAndDescriptionProp = (Properties)validProp.clone(); - udfsWithClassNameAndDescriptionProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}, \"Bla \"bla\".\"]"); + udfsWithClassNameAndDescriptionProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}, \"Bla \\\"bla\\\".\"], [ titi(b REAL) -> double, {adql.db.TestDBChecker$UDFToto}, \"Function titi.\"]"); udfsWithEmptyOptParamsProp = (Properties)validProp.clone(); udfsWithEmptyOptParamsProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR,, ]"); @@ -1060,12 +1060,18 @@ public class TestConfigurableServiceConnection { try{ ServiceConnection connection = new ConfigurableServiceConnection(udfsWithClassNameAndDescriptionProp); assertNotNull(connection.getUDFs()); - assertEquals(1, connection.getUDFs().size()); - FunctionDef def = connection.getUDFs().iterator().next(); + assertEquals(2, connection.getUDFs().size()); + Iterator<FunctionDef> itUdfs = connection.getUDFs().iterator(); + FunctionDef def = itUdfs.next(); assertEquals("toto(a VARCHAR) -> VARCHAR", def.toString()); assertEquals(UDFToto.class, def.getUDFClass()); - assertEquals("Bla \"bla\".", def.description); + assertEquals("Bla \\\"bla\\\".", def.description); + def = itUdfs.next(); + assertEquals("titi(b REAL) -> DOUBLE", def.toString()); + assertEquals(UDFToto.class, def.getUDFClass()); + assertEquals("Function titi.", def.description); }catch(Exception e){ + e.printStackTrace(); fail("This MUST have succeeded because the given list of UDFs contains valid items! \nCaught exception: " + getPertinentMessage(e)); } -- GitLab