You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Kylin Soong (JIRA)" <ji...@apache.org> on 2015/01/12 16:13:34 UTC

[jira] [Commented] (PHOENIX-1577) java.lang.IllegalArgumentException: nanos > 999999999 or < 0 while use Calendar

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

Kylin Soong commented on PHOENIX-1577:
--------------------------------------

Timestamp's nanos filed should less or equal 999999999, and large or equal 0. But in some occasion PhoenixPreparedStatement try to set a value large than 999999999, I have done a quick debug, the code
     pstmt.setTimestamp(2, timestramp, cal);
execute logic like
---
long millis = cal.getTimeInMillis();
int nanos = x.getNanos();
Timestamp ts = new Timestamp(millis);
ts.setNanos(ts.getNanos() + nanos);
---

Why org.apache.phoenix.util.DateUtil getTimestamp()  try to plus the  nanos?

> java.lang.IllegalArgumentException: nanos > 999999999 or < 0 while use Calendar
> -------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1577
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1577
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.2
>            Reporter: Kylin Soong
>
> I use the link [1] code, there always nanos > 999999999 or < 0 error throw.
> If execute insert, the error looks like:
> ~~~
> Exception in thread "main" java.lang.IllegalArgumentException: nanos > 999999999 or < 0
> 	at java.sql.Timestamp.setNanos(Timestamp.java:386)
> 	at org.apache.phoenix.util.DateUtil.getTimestamp(DateUtil.java:142)
> 	at org.apache.phoenix.jdbc.PhoenixPreparedStatement.setTimestamp(PhoenixPreparedStatement.java:489)
> ~~~
> and select the error looks
> ~~~
> xception in thread "main" java.lang.IllegalArgumentException: nanos > 999999999 or < 0
> 	at java.sql.Timestamp.setNanos(Timestamp.java:386)
> 	at org.apache.phoenix.util.DateUtil.getTimestamp(DateUtil.java:142)
> 	at org.apache.phoenix.jdbc.PhoenixResultSet.getTimestamp(PhoenixResultSet.java:638)
> ~~~
> Does this can be a bug?
> [1] https://github.com/kylinsoong/data/blob/master/phoenix-quickstart/src/test/java/org/apache/phoenix/examples/BugReproduce.java



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