Skip to content

Commit

Permalink
[BugFix] Fix jdbc catalog change password not effect (backport #51748) (
Browse files Browse the repository at this point in the history
#51758)

Co-authored-by: Smith Cruise <[email protected]>
  • Loading branch information
mergify[bot] and Smith-Cruise authored Oct 11, 2024
1 parent a8c8b5c commit 62020cb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public JDBCScanner(String driverLocation, JDBCScanContext scanContext) {
}

public void open() throws Exception {
String key = scanContext.getUser() + "/" + scanContext.getJdbcURL();
String cacheKey = computeCacheKey(scanContext.getUser(), scanContext.getPassword(), scanContext.getJdbcURL());
URL driverURL = new File(driverLocation).toURI().toURL();
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(key, () -> {
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(cacheKey, () -> {
ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {driverURL});
Thread.currentThread().setContextClassLoader(classLoader);
HikariConfig config = new HikariConfig();
Expand Down Expand Up @@ -116,6 +116,10 @@ public void open() throws Exception {
}
}

private static String computeCacheKey(String username, String password, String jdbcUrl) {
return username + "/" + password + "/" + jdbcUrl;
}

private static final Set<Class<?>> GENERAL_JDBC_CLASS_SET = new HashSet<>(
Arrays.asList(Boolean.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class,
BigInteger.class, BigDecimal.class, java.sql.Date.class, Timestamp.class, LocalDate.class,
Expand Down

0 comments on commit 62020cb

Please sign in to comment.