File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -207,14 +207,32 @@ tasks.test {
207207 html.required.set(true )
208208 }
209209
210+ // Increase heap size to prevent OOM during test execution with EhCache
211+ maxHeapSize = " 2g"
212+
210213 val jmockitPath = classpath.find { it.name.contains(" jmockit" ) }!! .absolutePath
211214 jvmArgs(" -javaagent:${jmockitPath} " )
212215
213216 // Cleanup test cache directories after tests complete
214217 doLast {
215- val tmpDir = File (System .getProperty(" java.io.tmpdir" ))
216- tmpDir.listFiles()?.filter { it.name.startsWith(" bsl-ls-cache-" ) }?.forEach { cacheDir ->
217- cacheDir.deleteRecursively()
218+ try {
219+ val tmpDir = File (System .getProperty(" java.io.tmpdir" ))
220+ // Use walkTopDown with maxDepth to avoid loading all temp files into memory
221+ tmpDir.walkTopDown()
222+ .maxDepth(1 ) // Only look at direct children, not subdirectories
223+ .drop(1 ) // Skip the root temp directory itself (first element in the sequence)
224+ .filter { it.isDirectory && it.name.startsWith(" bsl-ls-cache-" ) }
225+ .forEach { cacheDir ->
226+ try {
227+ cacheDir.deleteRecursively()
228+ logger.info(" Deleted test cache directory: ${cacheDir.name} " )
229+ } catch (e: Exception ) {
230+ logger.warn(" Failed to delete test cache directory ${cacheDir.name} : ${e.message} " )
231+ }
232+ }
233+ } catch (e: Exception ) {
234+ // Don't fail the build if cleanup fails
235+ logger.warn(" Failed to cleanup test cache directories: ${e.message} " )
218236 }
219237 }
220238}
You can’t perform that action at this time.
0 commit comments