Skip to content

Conversation

john9x
Copy link
Contributor

@john9x john9x commented May 7, 2025

Fix NPE

java.lang.NullPointerException: Cannot invoke "String.toLowerCase()" because "url" is null
        at org.apache.skywalking.apm.plugin.jdbc.connectionurl.parser.URLParser.parser(URLParser.java:47)
        at org.apache.skywalking.apm.plugin.hikaricp.PoolingSealInterceptor.afterMethod(PoolingSealInterceptor.java:52)
        at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:110)
        at com.zaxxer.hikari.HikariDataSource.seal(HikariDataSource.java)
        at com.zaxxer.hikari.HikariDataSource.$sw$original$getConnection$08spks0(HikariDataSource.java:112)
        at com.zaxxer.hikari.HikariDataSource.$sw$original$getConnection$08spks0$accessor$$sw$6kb3bn3(HikariDataSource.java)
        at com.zaxxer.hikari.HikariDataSource$$sw$auxiliary$93993q0.call(Unknown Source)
        at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:95)

The pool can be configured with data source options but not JDBC URL so in this case we can use pool name for metrics.

  • Add a unit test to verify that the fix works.
  • Explain briefly why the bug exists and how to fix it.
  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
  • Update the CHANGES log.

@wu-sheng
Copy link
Member

wu-sheng commented May 7, 2025

Please provide the demo codes to represent two ways of using.
And changes.md should be updated. Please follow PR template.

@wu-sheng wu-sheng added this to the 9.5.0 milestone May 7, 2025
@wu-sheng wu-sheng added enhancement New feature or request plugin labels May 7, 2025
@john9x
Copy link
Contributor Author

john9x commented May 7, 2025

Please provide the demo codes to represent two ways of using.

@wu-sheng How should I do this?

https://github.com/brettwooldridge/HikariCP/?tab=readme-ov-file#rocket-initialization
HikariCP pool can be configured using JDBC URL:

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");

or using data source properties

Properties props = new Properties();
props.setProperty("dataSourceClassName", "org.postgresql.ds.PGSimpleDataSource");
props.setProperty("dataSource.serverName", "localhost");
...
HikariConfig config = new HikariConfig(props);
HikariDataSource ds = new HikariDataSource(config)

@wu-sheng wu-sheng merged commit f971bcf into apache:main May 7, 2025
194 of 195 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants