alibaba / alibaba/druid

调用ps.execute()报NPE

Open
#4,151 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
28.2k
Forks
8.6k
PR merge metrics
No merged PRs in 30d

Description

java.lang.NullPointerException
at com.alibaba.druid.pool.DruidPooledConnection.transactionRecord(DruidPooledConnection.java:726)
at com.alibaba.druid.pool.DruidPooledStatement.transactionRecord(DruidPooledStatement.java:285)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:491)
at com.dmall.tm.TransactionServerRecord.setClientStatus(TransactionServerRecord.java:139)
at com.dmall.tm.TransactionServerRecord.commit(TransactionServerRecord.java:86)
at com.dmall.netty.server.ServerHandler.channelRead(ServerHandler.java:50)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)

String sql = "update client_log set branch_status = ? where transactional_id = ? and branch_id = ?";
ps = connection.prepareStatement(sql);
ps.setInt(1, status);
ps.setString(2, transactionalId);
ps.setString(3, branchId);
ps.execute();
调用ps.execute()时,报这个异常,找了很久,不知道什么原因

Contributor guide

Open the contributing guide

Research direction

Start at DruidPooledConnection.java:726 and follow the transactionRecord calls from DruidPooledStatement.java:285 and DruidPooledPreparedStatement.java:491. Reproduce the supplied prepareStatement and ps.execute() sequence with the reporter's database and configuration, then identify the missing state and add a regression test showing that the call no longer raises a NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.