Skip to content

Commit b3077ee

Browse files
committed
Add initialisedSchema and initialisedCatalog to handle the null schema/catalog case
1 parent f9466b1 commit b3077ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnection.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ final class PooledConnection extends ConnectionDelegator {
8484
private boolean resetAutoCommit;
8585
private boolean resetSchema;
8686
private boolean resetCatalog;
87+
private boolean initialisedSchema;
88+
private boolean initialisedCatalog;
8789
private String currentSchema;
8890
private String currentCatalog;
8991
private String originalSchema;
@@ -120,6 +122,8 @@ final class PooledConnection extends ConnectionDelegator {
120122
this.name = pool.name() + uniqueId;
121123
this.originalSchema = pool.schema();
122124
this.originalCatalog = pool.catalog();
125+
this.initialisedSchema = originalSchema != null;
126+
this.initialisedCatalog = originalCatalog != null;
123127
this.pstmtCache = new PstmtCache(pool.pstmtCacheSize());
124128
this.maxStackTrace = pool.maxStackTraceSize();
125129
this.creationTime = System.currentTimeMillis();
@@ -700,9 +704,10 @@ public void setSchema(String schema) throws SQLException {
700704
if (status == STATUS_IDLE) {
701705
throw new SQLException(IDLE_CONNECTION_ACCESSED_ERROR + "setSchema()");
702706
}
703-
if (originalSchema == null) {
707+
if (!initialisedSchema) {
704708
// lazily initialise the originalSchema
705709
originalSchema = getSchema();
710+
initialisedSchema = true;
706711
}
707712
currentSchema = schema;
708713
resetSchema = true;
@@ -714,9 +719,9 @@ public void setCatalog(String catalog) throws SQLException {
714719
if (status == STATUS_IDLE) {
715720
throw new SQLException(IDLE_CONNECTION_ACCESSED_ERROR + "setCatalog()");
716721
}
717-
if (originalCatalog == null) {
718-
// lazily initialise the originalCatalog
722+
if (!initialisedCatalog) {
719723
originalCatalog = getCatalog();
724+
initialisedCatalog = true;
720725
}
721726
currentCatalog = catalog;
722727
resetCatalog = true;

0 commit comments

Comments
 (0)