phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Josh Elser (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-2372) PhoenixResultSet.getDate(int, Calendar) causes NPE on a null value
Date Thu, 05 Nov 2015 16:27:27 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-2372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14991921#comment-14991921
] 

Josh Elser commented on PHOENIX-2372:
-------------------------------------

Looks like the only other null-related issue was on BigDecimal. If we got a null value back
from {{getBigDecimal(int)}}, we would been calling {{setScale}} on a null instance.

{code}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java
index 60a6957..13ea7da 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java
@@ -242,6 +242,9 @@ public class PhoenixResultSet implements ResultSet, SQLCloseable, org.apache.pho
     @Override
     public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
         BigDecimal value = getBigDecimal(columnIndex);
+        if (wasNull) {
+          return null;
+        }
         return value.setScale(scale);
     }
{code}

Updated patch imminent.

> PhoenixResultSet.getDate(int, Calendar) causes NPE on a null value
> ------------------------------------------------------------------
>
>                 Key: PHOENIX-2372
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2372
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.4.0, 4.5.0, 4.6.0
>            Reporter: Josh Elser
>            Assignee: Josh Elser
>         Attachments: PHOENIX-2372.001.patch
>
>
> Ran a simple query through PQS:
> {code}
> select * from system.stats;
> {code}
> and got back a stack trace (trimmed for relevance)
> {noformat}
> java.lang.NullPointerException
>         at java.util.Calendar.setTime(Calendar.java:1770)
>         at org.apache.phoenix.jdbc.PhoenixResultSet.getDate(PhoenixResultSet.java:377)
>         at org.apache.calcite.avatica.jdbc.JdbcResultSet.getValue(JdbcResultSet.java:172)
>         at org.apache.calcite.avatica.jdbc.JdbcResultSet.frame(JdbcResultSet.java:142)
> {noformat}
> It looks like the {{getDate(int, Calendar)}} method on PhoenixResultSet doesn't check
the value before passing it into the calendar.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message