Skip to content

Commit

Permalink
MID-7101: removed potential for DB connection leak if commit before c…
Browse files Browse the repository at this point in the history
…lose fails

This may or may not fix the issue, but is in line with changes made for 4.4.
  • Loading branch information
virgo47 committed Jun 16, 2021
1 parent 233db62 commit f247299
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void cleanup() {
jdbcSession.newDelete(QAuditResourceMapping.INSTANCE.defaultAlias()).execute();
jdbcSession.newDelete(QAuditRefValueMapping.INSTANCE.defaultAlias()).execute();
jdbcSession.newDelete(QAuditEventRecordMapping.INSTANCE.defaultAlias()).execute();
jdbcSession.commit();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private void initCustomColumns(
.startTransaction(Connection.TRANSACTION_READ_COMMITTED)) {
jdbcSession.addColumn(QAuditEventRecord.TABLE_NAME,
ColumnMetadata.named(columnName).ofType(Types.VARCHAR).withSize(255));
jdbcSession.commit();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void auditAttempt(AuditEventRecord record) {
insertProperties(jdbcSession, recordId, record.getProperties());
insertReferences(jdbcSession, recordId, record.getReferences());
insertResourceOids(jdbcSession, recordId, record.getResourceOids());
jdbcSession.commit();
} catch (RuntimeException ex) {
jdbcSession.handleGeneralException(ex, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ public SupportedDatabase databaseType() {
@Override
public void close() {
try {
if (!connection.getAutoCommit()) {
commit();
}
connection.close();
} catch (SQLException e) {
throw new SystemException(e);
Expand Down

0 comments on commit f247299

Please sign in to comment.