Skip to content

Commit 36af991

Browse files
authored
Rename shouldCommit back to canCommit (#3464)
As a follow up correction to #3429, rename this function back.
1 parent 34aa559 commit 36af991

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/AbstractEmbeddedStatement.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ public boolean executeInternal(String sql) throws SQLException, RelationalExcept
109109
resultSetRetrieved = true;
110110
//ddl statements are updates that don't return results, so they get 0 for row count
111111
currentRowCount = 0;
112-
if (conn.shouldCommit()) {
112+
if (conn.canCommit()) {
113113
conn.commitInternal();
114114
}
115115
return false;
116116
}
117117
}
118118
} catch (RelationalException | SQLException | RuntimeException ex) {
119119
try {
120-
if (conn.inActiveTransaction() && conn.shouldCommit()) {
120+
if (conn.inActiveTransaction() && conn.canCommit()) {
121121
conn.rollbackInternal();
122122
}
123123
} catch (SQLException e) {
@@ -170,7 +170,7 @@ public void close() throws SQLException {
170170
closeOpenResultSets();
171171
closed = true;
172172
} catch (RuntimeException ex) {
173-
if (conn.shouldCommit()) {
173+
if (conn.canCommit()) {
174174
try {
175175
conn.rollbackInternal();
176176
} catch (SQLException e) {
@@ -209,12 +209,12 @@ private int countUpdates(@Nonnull ResultSet resultSet) throws SQLException {
209209
while (resultSet.next()) {
210210
count++;
211211
}
212-
if (conn.shouldCommit()) {
212+
if (conn.canCommit()) {
213213
conn.commitInternal();
214214
}
215215
return count;
216216
} catch (SQLException | RuntimeException ex) {
217-
if (conn.shouldCommit()) {
217+
if (conn.canCommit()) {
218218
conn.rollbackInternal();
219219
}
220220
throw ExceptionUtil.toRelationalException(ex).toSqlException();

fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/EmbeddedRelationalConnection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
* to be used to execute all statements and procedure. For consumer perspective, this is equivalent to {@code autoCommit}
8585
* being set to {@code true} since the {@link Connection#commit()} and {@link Connection#rollback()} wont be applicable.
8686
* However, all statements run within the external transaction. For internal usage, the consumer should check
87-
* {@link EmbeddedRelationalConnection#shouldCommit()} to see if they are allowed to manage a transaction.</li>
87+
* {@link EmbeddedRelationalConnection#canCommit()} to see if they are allowed to manage a transaction.</li>
8888
* </ul>
8989
*/
9090
@API(API.Status.EXPERIMENTAL)
@@ -185,7 +185,7 @@ public boolean getAutoCommit() throws SQLException {
185185
* @return {@code true} if the transaction can be committed by internal stakeholders, else {@code false}.
186186
* @throws SQLException if the connection is closed.
187187
*/
188-
boolean shouldCommit() throws SQLException {
188+
boolean canCommit() throws SQLException {
189189
checkOpen();
190190
return !usingAnExternalTransaction && this.autoCommit;
191191
}
@@ -492,7 +492,7 @@ public AbstractDatabase getRecordLayerDatabase() {
492492
*/
493493
boolean ensureTransactionActive() throws RelationalException, SQLException {
494494
if (inActiveTransaction()) {
495-
if (shouldCommit()) {
495+
if (canCommit()) {
496496
// canCommit() = true means that there is no external transaction and autoCommit is enabled, meaning
497497
// that the internal stakeholders can manage the transactions when required to.
498498
// As this implies that autoCommit is enabled, if there is an existing transaction in such a case, that

fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/EmbeddedRelationalStatement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private <T> T ensureTransaction(Supplier<T> operation) throws SQLException {
335335
} catch (SQLException sqle) {
336336
exception.addSuppressed(sqle);
337337
}
338-
} else if (conn.shouldCommit()) {
338+
} else if (conn.canCommit()) {
339339
conn.commitInternal();
340340
}
341341
}

fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/RecordLayerResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void close() throws SQLException {
9494
} catch (RelationalException e) {
9595
throw e.toSqlException();
9696
}
97-
if (connection != null && connection.shouldCommit() && connection.inActiveTransaction()) {
97+
if (connection != null && connection.canCommit() && connection.inActiveTransaction()) {
9898
connection.commitInternal();
9999
}
100100
this.closed = true;

0 commit comments

Comments
 (0)