Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix jdbc catalog change password not effect (backport #51748) #51759

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ 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();
<<<<<<< HEAD
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(key, () -> {
ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {
driverURL,
});
=======
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(cacheKey, () -> {
ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {driverURL});
>>>>>>> acce535baf ([BugFix] Fix jdbc catalog change password not effect (#51748))
Thread.currentThread().setContextClassLoader(classLoader);
HikariConfig config = new HikariConfig();
config.setDriverClassName(scanContext.getDriverClassName());
Expand Down Expand Up @@ -118,6 +123,7 @@ public void open() throws Exception {
}
}

<<<<<<< HEAD
private static final Set<Class<?>> GENERAL_JDBC_CLASS_SET = new HashSet<>(Arrays.asList(
Boolean.class,
Short.class,
Expand All @@ -133,6 +139,16 @@ public void open() throws Exception {
Time.class,
String.class
));
=======
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,
LocalDateTime.class, Time.class, String.class));
>>>>>>> acce535baf ([BugFix] Fix jdbc catalog change password not effect (#51748))

private boolean isGeneralJDBCClassType(Class<?> clazz) {
return GENERAL_JDBC_CLASS_SET.contains(clazz);
Expand Down
Loading