Skip to content

Commit

Permalink
FINERACT-2081: Fix `Connection is not available, request timed out af…
Browse files Browse the repository at this point in the history
…ter 30000ms` issue of "read-only" check
  • Loading branch information
adamsaghy committed Dec 22, 2024
1 parent c2ec015 commit 23850a1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.jdbc.datasource.JdbcTransactionObjectSupport;
import org.springframework.orm.jpa.EntityManagerHolder;
import org.springframework.orm.jpa.JpaTransactionManager;
Expand Down Expand Up @@ -65,10 +66,13 @@ protected void doCommit(DefaultTransactionStatus status) {
}

public boolean isReadOnlyConnection() {
try (Connection connection = getDataSource().getConnection()) {
Connection connection = DataSourceUtils.getConnection(getDataSource());
try {
return connection.isReadOnly();
} catch (SQLException e) {
throw new IllegalStateException(e);
} finally {
DataSourceUtils.releaseConnection(connection, getDataSource());
}
}

Expand Down

0 comments on commit 23850a1

Please sign in to comment.