Skip to content

Commit 9c7612f

Browse files
committed
fix(database): add timeout to SQL execution future
Add a 5-second timeout to `future.get()` in `SQLExecutor.kt` to prevent potential indefinite blocking during SQL execution.
1 parent abad8e3 commit 9c7612f

File tree

1 file changed

+2
-2
lines changed
  • exts/ext-database/src/241/main/kotlin/cc/unitmesh/database/util

1 file changed

+2
-2
lines changed

exts/ext-database/src/241/main/kotlin/cc/unitmesh/database/util/SQLExecutor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object SQLExecutor {
121121
}
122122

123123
private fun executeSql(project: Project, dataSource: RawDataSource, query: String): String? {
124-
val future: java.util.concurrent.CompletableFuture<String> = java.util.concurrent.CompletableFuture()
124+
val future: CompletableFuture<String> = CompletableFuture()
125125
val localDs = com.intellij.database.util.DbImplUtilCore.getLocalDataSource(dataSource)
126126

127127
val session = com.intellij.database.console.session.DatabaseSessionManager.getSession(project, localDs)
@@ -140,7 +140,7 @@ object SQLExecutor {
140140
object : com.intellij.database.datagrid.DataRequest.QueryRequest(session, query,
141141
newConstraints(dataSource.dbms), null) {}
142142
messageBus.dataProducer.processRequest(request)
143-
return future.get()
143+
return future.get(5, java.util.concurrent.TimeUnit.SECONDS)
144144
}
145145

146146
private fun createConsole(project: Project, file: LightVirtualFile): JdbcConsole? {

0 commit comments

Comments
 (0)