AlfieLyu6 opened a new pull request, #10870: URL: https://github.com/apache/gravitino/pull/10870
### What changes were proposed in this pull request? Added an `instanceof` check in `JdbcCatalogMetricsSource.registerDatasourceMetrics()` before casting to `BasicDataSource`. If the provided `DataSource` is not a `BasicDataSource`, the method logs a warning and returns early instead of throwing a `ClassCastException`. ### Why are the changes needed? The original implementation performed an unconditional cast of `DataSource` to `BasicDataSource`, which would throw a `ClassCastException` at runtime for any non-DBCP `DataSource` implementation. This makes the method unsafe for callers that may pass a different `DataSource` type. Fix: #10122 ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Added `TestJdbcCatalogMetricsSource.testRegisterDatasourceMetricsWithNonBasicDataSource()` which passes an anonymous `DataSource` implementation (non-DBCP) and asserts that no exception is thrown. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
