You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Niels Basjes (Jira)" <ji...@apache.org> on 2020/03/30 13:16:00 UTC

[jira] [Issue Comment Deleted] (DRILL-7677) NPE in getStringFromVarCharHolder(NullableVarCharHolder)

     [ https://issues.apache.org/jira/browse/DRILL-7677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niels Basjes updated DRILL-7677:
--------------------------------
    Comment: was deleted

(was: This seems a sensible fix, yet I expect side effects and I'm currently no able to verify the build locally.
{code:java}
diff --git exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
index 02b053f..8b26104 100644
--- exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
+++ exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
@@ -184,6 +184,9 @@ public class StringFunctionHelpers {
    * Convert a NullableVarCharHolder to a String.
    */
   public static String getStringFromVarCharHolder(NullableVarCharHolder varCharHolder) {
+    if (varCharHolder == null || varCharHolder.isSet == 0 || varCharHolder.buffer == null) {
+      return null;
+    }
     return toStringFromUTF8(varCharHolder.start, varCharHolder.end, varCharHolder.buffer);
   }

{code})

> NPE in getStringFromVarCharHolder(NullableVarCharHolder) 
> ---------------------------------------------------------
>
>                 Key: DRILL-7677
>                 URL: https://issues.apache.org/jira/browse/DRILL-7677
>             Project: Apache Drill
>          Issue Type: Bug
>            Reporter: Niels Basjes
>            Priority: Major
>
> Assume you have a function ([like this one|https://github.com/apache/drill/blob/master/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java#L110]) that has
> {code:java}
> @Param
> NullableVarCharHolder input;
> {code}
> and in the {code:java}eval(){code} function you do
> {code:java}String inputString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(input);{code}
> When this function is called with the input actually being null the 'input' parameter is an instance of NullableVarCharHolder where isSet is 0 and buffer is null.
> The buffer being null causes an NPE in the call to getStringFromVarCharHolder(NullableVarCharHolder)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)