Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 c538918ad -> 1ca62e4a4


PHOENIX-4072 Prevent NPE for PreparedStatement.setObject of null


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ce4b1112
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ce4b1112
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ce4b1112

Branch: refs/heads/4.x-HBase-1.1
Commit: ce4b11124f6a51cde78852358d2cdf595c5f80ea
Parents: 5c16a29
Author: James Taylor <[email protected]>
Authored: Mon Aug 7 11:56:23 2017 -0700
Committer: James Taylor <[email protected]>
Committed: Mon Aug 7 23:05:00 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ce4b1112/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
index 9bba3d3..71ecb8d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
@@ -444,8 +444,10 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
     @Override
     public void setObject(int parameterIndex, Object o, int targetSqlType) 
throws SQLException {
         PDataType targetType = PDataType.fromTypeId(targetSqlType);
-        PDataType sourceType = PDataType.fromLiteral(o);
-        o = targetType.toObject(o, sourceType);
+        if (o != null) {
+            PDataType sourceType = PDataType.fromLiteral(o);
+            o = targetType.toObject(o, sourceType);
+        }
         setParameter(parameterIndex, o);
     }
 

Reply via email to