Repository navigation
Conversation
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the
NullPointerExceptionin the PostgreSQL plugin for statements prepared with generated keys (apache/skywalking#14138)PgConnection#prepareStatement(String, String[])is intercepted byJDBCPrepareStatementWithStringArrayInterceptor, which wraps the result inSWPreparedStatementbut does not set the dynamic field of the realPgPreparedStatement. pgjdbc 42.x constructs that statement directly instead of going through the intercepted 4-argumentprepareStatement, so its dynamic field stays null.prepareStatement(String, int)withStatement.RETURN_GENERATED_KEYSdelegates to this method, and Hibernate and MyBatis use it for generated keys.PgPreparedStatementis still enhanced, so whenSWPreparedStatementcalls the realexecuteUpdate(and the nestedexecuteWithFlags),PreparedStatementExecuteMethodsInterceptordereferences the null dynamic field. The agent logs 4 NPEs for every such insert, while the SQL span is still recorded bySWPreparedStatement.This PR skips the interceptor when the dynamic field or its
ConnectionInfois null, which is the same guard the MySQL plugin'sPreparedStatementExecuteMethodsInterceptoralready has. Tracing of this path is unchanged. The new unit test fails with the NPE from the issue before this change.CHANGESlog.