You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2019/05/06 23:50:54 UTC

[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-3413 Ineffective null check in LiteralExpression#newConstant()

This is an automated email from the ASF dual-hosted git repository.

tdsilva pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
     new 613f32e  PHOENIX-3413 Ineffective null check in LiteralExpression#newConstant()
613f32e is described below

commit 613f32e1991b6456451f6cfd3f618ec5f1b0bbb9
Author: kliewkliew <kl...@apache.org>
AuthorDate: Mon Feb 6 19:53:58 2017 -0800

    PHOENIX-3413 Ineffective null check in LiteralExpression#newConstant()
---
 .../src/main/java/org/apache/phoenix/expression/LiteralExpression.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java
index f20d7e2..110177a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java
@@ -184,6 +184,7 @@ public class LiteralExpression extends BaseTerminalExpression {
             return getBooleanLiteralExpression((Boolean)value, determinism);
         }
         PDataType actualType = PDataType.fromLiteral(value);
+        type = type == null ? actualType : type;
         try {
             value = type.toObject(value, actualType);
         } catch (IllegalDataException e) {
@@ -208,7 +209,7 @@ public class LiteralExpression extends BaseTerminalExpression {
             return getTypedNullLiteralExpression(type, determinism);
         }
         if (maxLength == null) {
-            maxLength = type == null || !type.isFixedWidth() ? null : type.getMaxLength(value);
+            maxLength = type.isFixedWidth() ? type.getMaxLength(value) : null;
         }
         return new LiteralExpression(value, type, b, maxLength, scale, sortOrder, determinism);
     }