Skip to content

Commit 6e5d442

Browse files
committed
For PooledConnection.resetForUse() remove the asserts
The resetForUse() is called "on borrow" just before the connection is returned to the application. As such we can't do anything that could throw any Exception here. All connection reset actions must be performed when the connection is returned to the pool.
1 parent b053076 commit 6e5d442

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,21 +385,12 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
385385
* Reset the connection for returning to the client. Resets the status,
386386
* startUseTime and hadErrors.
387387
*/
388-
void resetForUse() throws SQLException {
388+
void resetForUse() {
389389
this.status = STATUS_ACTIVE;
390390
this.startUseTime = System.currentTimeMillis();
391391
this.createdByMethod = null;
392392
this.lastStatement = null;
393393
this.hadErrors = false;
394-
// CHECKME: Shoud we keep the asserts here or should we even reset schema/catalog here
395-
assert schemaState != SCHEMA_CATALOG_CHANGED : "connection is in the wrong state (not properly closed)";
396-
if (schemaState == SCHEMA_CATALOG_KNOWN) {
397-
assert originalSchema.equals(getSchema()) : "connection is in the wrong schema: " + getSchema() + ", expected: " + originalSchema;
398-
}
399-
assert catalogState != SCHEMA_CATALOG_CHANGED : "connection is in the wrong state (not properly closed)";
400-
if (catalogState == SCHEMA_CATALOG_KNOWN) {
401-
assert originalCatalog.equals(getCatalog()) : "connection is in the wrong catalog: " + getCatalog() + ", expected: " + originalCatalog;
402-
}
403394
}
404395

405396
/**

ebean-datasource/src/test/java/io/ebean/datasource/test/PostgresInitTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void test_with_clientInfo() throws SQLException {
8181
void test_with_applicationNameAndSchema() throws SQLException {
8282
DataSourceConfig ds = new DataSourceConfig();
8383
ds.setUrl("jdbc:postgresql://127.0.0.1:9999/app");
84-
ds.setSchema("fred");
84+
ds.setSchema("public");
8585
ds.setUsername("db_owner");
8686
ds.setPassword("test");
8787
ds.setApplicationName("my-application-name");
@@ -112,7 +112,7 @@ void test_with_applicationNameAndSchema() throws SQLException {
112112
void test_password2() throws SQLException {
113113
DataSourceConfig ds = new DataSourceConfig();
114114
ds.setUrl("jdbc:postgresql://127.0.0.1:9999/app");
115-
ds.setSchema("fred");
115+
ds.setSchema("public");
116116
ds.setUsername("db_owner");
117117
ds.setPassword("test");
118118
ds.setPassword2("newRolledPassword");

0 commit comments

Comments
 (0)