Skip to content

Conversation

gzlicanyi
Copy link
Contributor

…nown JDBC URLs.

Fix

  • Add a unit test to verify that the fix works.
  • Explain briefly why the bug exists and how to fix it.
  • Update the CHANGES log.

problem

ERROR 2023-11-06 16:46:59.170 defaultEventExecutorGroup-2-59 InstMethodsInter : class[class com.mysql.jdbc.Driver] before method[connect] intercept failure 
java.lang.NullPointerException
        at org.apache.skywalking.apm.plugin.jdbc.connectionurl.parser.URLParser.parser(URLParser.java:64)
        at org.apache.skywalking.apm.plugin.jdbc.mysql.DriverConnectInterceptor.beforeMethod(DriverConnectInterceptor.java:36)
        at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:76)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:208)
        at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
        at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
        at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
        at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:138)
        at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:60)
        at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)

Causes

I used two JDBC drivers in a project, one of which was developed by NetEase and the other was mysql Driver.
At present, all connections are obtained by calling the getConnection method of DriverManager.

Therefore, when the self-developed jdbc url is parsed in the beforeMethod method of DriverConnectInterceptor, a null pointer exception occurs.

how to fix it

Make the beforeMethod of DriverConnectInterceptor compatible with unknown JDBC URLs.

@wu-sheng
Copy link
Member

wu-sheng commented Nov 6, 2023

Why we are going to add a null check for the URL rather than fixing the identification?

@gzlicanyi
Copy link
Contributor Author

Why we are going to add a null check for the URL rather than fixing the identification?

Because NetEase self-developed database is not open source, so I choose to be compatible with it.

@wu-sheng
Copy link
Member

wu-sheng commented Nov 6, 2023

This would be too tricky for upstream. We can't afford to support commercial and/or not-source-open thing. Sorry.

Because this may somehow work for you, but it would swallow the error for code bugs, and our end users will be confused.

@wu-sheng wu-sheng added this to the 9.1.0 milestone Nov 6, 2023
@wu-sheng wu-sheng closed this Nov 6, 2023
@gzlicanyi gzlicanyi deleted the feature/compatible_with_unknown_db_url branch May 17, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants