-
Notifications
You must be signed in to change notification settings - Fork 2
Cluster redirect #35
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
base: master
Are you sure you want to change the base?
Cluster redirect #35
Changes from all commits
192bcfc
0b1e507
7552bcb
ec30ba9
0667609
11a248f
e3d18c4
a73d91c
7935112
a979a9c
7ac0f44
06df35d
91e9839
042da9b
83c3b9b
96c8f21
0d04822
e41bd7c
0b75fc5
6836b17
f951cd3
ab43018
6c05f75
9ffc83b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,18 +22,22 @@ | |||||||||||||||
| import java.util.HashMap; | ||||||||||||||||
| import java.util.Map; | ||||||||||||||||
| import java.util.Properties; | ||||||||||||||||
| import java.util.Set; | ||||||||||||||||
| import java.util.concurrent.ConcurrentHashMap; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * UserConfigurations for JDBC impersonation. | ||||||||||||||||
| */ | ||||||||||||||||
| public class JDBCUserConfigurations { | ||||||||||||||||
| private final Map<String, Statement> paragraphIdStatementMap; | ||||||||||||||||
| private PoolingDriver poolingDriver; | ||||||||||||||||
| private final Set<String> registeredPools; | ||||||||||||||||
| private Properties properties; | ||||||||||||||||
| private Boolean isSuccessful; | ||||||||||||||||
|
|
||||||||||||||||
| public JDBCUserConfigurations() { | ||||||||||||||||
| paragraphIdStatementMap = new HashMap<>(); | ||||||||||||||||
| registeredPools = ConcurrentHashMap.newKeySet(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public void initStatementMap() throws SQLException { | ||||||||||||||||
|
|
@@ -45,6 +49,7 @@ public void initStatementMap() throws SQLException { | |||||||||||||||
|
|
||||||||||||||||
| public void initConnectionPoolMap() throws SQLException { | ||||||||||||||||
| this.poolingDriver = null; | ||||||||||||||||
| this.registeredPools.clear(); | ||||||||||||||||
| this.isSuccessful = null; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -83,8 +88,31 @@ public void saveDBDriverPool(PoolingDriver driver) throws SQLException { | |||||||||||||||
| this.isSuccessful = false; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public void saveDBDriverPool(PoolingDriver driver, String poolName) throws SQLException { | ||||||||||||||||
| this.poolingDriver = driver; | ||||||||||||||||
| this.registeredPools.add(poolName); | ||||||||||||||||
| this.isSuccessful = false; | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+91
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Two issues here:
🛡️ Proposed defensive fix public void saveDBDriverPool(PoolingDriver driver, String poolName) throws SQLException {
+ if (poolName == null) {
+ throw new IllegalArgumentException("poolName must not be null");
+ }
+ if (this.poolingDriver != null && this.poolingDriver != driver) {
+ throw new IllegalStateException("Cannot register pool '" + poolName + "' against a different PoolingDriver instance");
+ }
this.poolingDriver = driver;
this.registeredPools.add(poolName);
this.isSuccessful = false;
}🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Returns the current PoolingDriver without removing it. | ||||||||||||||||
| * Use this when you need to close a single named pool without discarding all pool state. | ||||||||||||||||
| */ | ||||||||||||||||
| public PoolingDriver getPoolingDriver() { | ||||||||||||||||
| return this.poolingDriver; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Removes a single pool name from the registered set. | ||||||||||||||||
| * Does NOT clear the PoolingDriver reference — other pools remain accessible. | ||||||||||||||||
| */ | ||||||||||||||||
| public void removePoolName(String poolName) { | ||||||||||||||||
| this.registeredPools.remove(poolName); | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+109
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🛡️ Proposed fix public void removePoolName(String poolName) {
+ if (poolName == null) return;
this.registeredPools.remove(poolName);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| public PoolingDriver removeDBDriverPool() throws SQLException { | ||||||||||||||||
| this.isSuccessful = null; | ||||||||||||||||
| this.registeredPools.clear(); | ||||||||||||||||
| PoolingDriver tmp = poolingDriver; | ||||||||||||||||
| this.poolingDriver = null; | ||||||||||||||||
| return tmp; | ||||||||||||||||
|
|
@@ -94,6 +122,10 @@ public boolean isConnectionInDBDriverPool() { | |||||||||||||||
| return this.poolingDriver != null; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public boolean isConnectionInDBDriverPool(String poolName) { | ||||||||||||||||
| return this.poolingDriver != null && this.registeredPools.contains(poolName); | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+125
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🛡️ Proposed fix public boolean isConnectionInDBDriverPool(String poolName) {
+ if (poolName == null) return false;
return this.poolingDriver != null && this.registeredPools.contains(poolName);
}🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| public void setConnectionInDBDriverPoolSuccessful() { | ||||||||||||||||
| this.isSuccessful = true; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.