soulgalore / jdbcmetrics

Get information from your JDBC driver.
39 stars 12 forks source link

Nullpointer when doing batch inserts #18

Closed lhallowes closed 11 years ago

lhallowes commented 11 years ago

When doing batch inserts I am getting a null pointer exception in StatementInvocationHandler line 86. Basically the args array is null but there is no null guard around the code and it tries to get the first element from the array.

All other db operations I have tried have been working fine with the metrics. Could the 'addBatch' part not be done in the same way as the 'execute' condition where it falls back to the sql if args is null?

The relevant stack trace is:

! java.lang.NullPointerException: null
! at com.soulgalore.jdbcmetrics.proxy.StatementInvocationHandler.invoke(StatementInvocationHandler.java:86) ~[jdbcmetrics-1.1.jar:na]
! at com.sun.proxy.$Proxy112.addBatch(Unknown Source) ~[na:na]
! at org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:903) ~[spring-jdbc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
! at org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:890) 
! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589) 
! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617) 
! at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:890) 
! at org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeBatchInternal(AbstractJdbcInsert.java:581) 
! at org.springframework.jdbc.core.simple.AbstractJdbcInsert.doExecuteBatch(AbstractJdbcInsert.java:554) 
! at org.springframework.jdbc.core.simple.SimpleJdbcInsert.executeBatch(SimpleJdbcInsert.java:138)
soulgalore commented 11 years ago

hello, thanks for the info. yes it doesn't look ok. yes that is an ok solution, give a a couple of minutes ...

soulgalore commented 11 years ago

thanks for reporting the bug! I have released 1.1.1

lhallowes commented 11 years ago

Nice one, thanks for fixing it so quickly. I have tried 1.1.1 and addBatch is now working

soulgalore commented 11 years ago

np, you pointed out the problem and also wrote the solution :) thanks again