From 4baf2b695ae4d031cb0c50c7c75ff87d2757ff1b Mon Sep 17 00:00:00 2001 From: ramya vasanth Date: Fri, 9 Oct 2020 14:13:31 +0530 Subject: [PATCH] [OLINGO-1191]Fix null issue in Edm.String --- .../olingo/commons/core/edm/primitivetype/EdmString.java | 5 ++++- .../olingo/commons/core/edm/primitivetype/EdmStringTest.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java index 8e9a42a59..29b44b426 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java @@ -99,7 +99,10 @@ public final class EdmString extends SingletonPrimitiveType { } @Override - public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException { + public String fromUriLiteral(String literal) throws EdmPrimitiveTypeException { + if (literal != null && literal.equalsIgnoreCase("null")) { + literal = "'" + literal + "'"; + } return literal == null ? null : super.fromUriLiteral(literal).replace("''", "'"); } } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java index b5f2a89d5..68b58200a 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java @@ -38,6 +38,7 @@ public class EdmStringTest extends PrimitiveTypeBaseTest { @Test public void fromUriLiteral() throws Exception { assertEquals("String''Value", instance.fromUriLiteral("'String''''Value'")); + assertEquals("null", instance.fromUriLiteral("null")); expectErrorInFromUriLiteral(instance, ""); expectErrorInFromUriLiteral(instance, "'");