Hi all,

We are trying to upgrade from H2 1.3.153 to 1.4.200, and are running into 
the following NPE:

org.h2.jdbc.JdbcSQLNonTransientException: General error: 
"java.lang.NullPointerException"; SQL statement:
select time_value, formatdatetime(time_value, 'HH:mm:ss.SSS') from 
JDBCHelperTest where test_name = ? [50000-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
at org.h2.message.DbException.get(DbException.java:194)
at org.h2.message.DbException.convert(DbException.java:347)
at org.h2.command.Command.executeQuery(Command.java:212)
at 
org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:114)
at com.xxx.JDBCHelperTest.checkTime(JDBCHelperTest.java:428)
at com.xxx.JDBCHelperTest.testBindByPosition_Time(JDBCHelperTest.java:1272)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at junit.framework.TestCase.runTest(TestCase.java:177)
at 
com.redwood.testtools.junit.RedwoodTestCase.runBare(RedwoodTestCase.java:154)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:130)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.NullPointerException
at org.h2.value.Value.convertToTimestamp(Value.java:1146)
at org.h2.value.Value.convertTo(Value.java:822)
at org.h2.value.Value.convertTo(Value.java:737)
at org.h2.value.Value.getTimestamp(Value.java:591)
at org.h2.expression.function.Function.getValueWithArgs(Function.java:1530)
at org.h2.expression.function.Function.getValue(Function.java:672)
at 
org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1851)
at org.h2.result.LazyResult.hasNext(LazyResult.java:101)
at org.h2.result.LazyResult.next(LazyResult.java:60)
at org.h2.command.dml.Select.queryFlat(Select.java:737)
at org.h2.command.dml.Select.queryWithoutCache(Select.java:844)
at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:201)
at org.h2.command.dml.Query.query(Query.java:489)
at org.h2.command.dml.Query.query(Query.java:451)
at org.h2.command.CommandContainer.query(CommandContainer.java:285)
at org.h2.command.Command.executeQuery(Command.java:195)
... 25 more

As far as I can tell, this would still fail on current master as well, it's 
a little more difficult to test there though, as there are no pre-built 
binaries that I could find…

However, what happens is that `Value.getTimesstamp(TimeZone)` calls 
`Value. convertTo(Value.*TIMESTAMP*))`, which in turn calls 
`Value.convertTo(targetType, *null*, *null*, *false*, *null*)`.  That third 
*null*, is `CastDataProvider provider`. This provider is `null`, however 
when it is passed to `Value.convertToTimestamp(provider, forComparison)`, 
that method assumes that *provider*, isn't null, and thus we get the NPE.

The SQL that we are passing in can be seen in the stack trace. I can't see 
anything wrong with the query, nor can I see any obvious workaround. I am 
hoping that someone here will be able to help me see what we have done 
wrong, and how we can fix it without needing to wait for 2.0.202.

Cheers,
Paul

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/5a52bd05-c037-4886-8ae9-1e72c0d77455n%40googlegroups.com.

Reply via email to