You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql/connect/server/src/main/scala/org/apache/spark/sql/connect/service/SparkConnectAddArtifactsHandler.scala
+32-1Lines changed: 32 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,23 @@ class SparkConnectAddArtifactsHandler(val responseObserver: StreamObserver[AddAr
142
142
}
143
143
144
144
protecteddefcleanUpStagedArtifacts():Unit= {
145
+
// Close all staged artifacts to release file handles and stream resources
146
+
stagedArtifacts.foreach { artifact =>
147
+
try {
148
+
artifact.close()
149
+
} catch {
150
+
caseNonFatal(_) =>// Ignore errors during cleanup
151
+
}
152
+
}
153
+
// Close the chunked artifact if it's still active
154
+
if (chunkedArtifact !=null) {
155
+
try {
156
+
chunkedArtifact.close()
157
+
} catch {
158
+
caseNonFatal(_) =>// Ignore errors during cleanup
159
+
}
160
+
chunkedArtifact =null
161
+
}
145
162
Utils.deleteRecursively(stagingDir.toFile)
146
163
stagedArtifacts.clear()
147
164
}
@@ -262,11 +279,25 @@ class SparkConnectAddArtifactsHandler(val responseObserver: StreamObserver[AddAr
262
279
263
280
defclose():Unit= {
264
281
if (artifactSummary ==null) {
265
-
checksumOut.close()
282
+
// Close streams defensively: even if outer stream close fails, try inner streams.
283
+
// Normally checksumOut.close() cascades to inner streams, but if it throws an
284
+
// exception, we still attempt to close the inner streams to prevent resource leaks.
285
+
varcloseException:Throwable=null
286
+
try {
287
+
checksumOut.close()
288
+
} catch {
289
+
caseNonFatal(e) =>
290
+
closeException = e
291
+
// Try to close inner streams directly as fallback
0 commit comments