Overview
Test file recreation (anti-cheating mechanism) blocks background threads unnecessarily during task checking, potentially causing performance issues.
Location
File: intellij-plugin/hs-core/src/org/hyperskill/academy/learning/actions/CheckAction.kt
Function: recreateTestFiles (lines 167-194)
Problem
Test file recreation is done synchronously during check with invokeAndWaitIfNeeded + runWriteAction. This blocks the background thread that's running the check operation.
override fun run(indicator: ProgressIndicator) {
// Running on background thread
recreateTestFiles(project, task) // But this blocks with invokeAndWaitIfNeeded
}
What needs to be fixed
- The operation is already on a background thread (line 133
run(indicator: ProgressIndicator)) but uses invokeAndWaitIfNeeded which blocks unnecessarily
- Consider using
runWriteActionAndWait or restructuring to avoid blocking
- Add proper error handling for individual file recreation failures (currently just logs warnings)
- The same pattern exists in
FrameworkLessonManagerImpl.recreateTestFiles (lines 219-245) - fix both locations consistently
Tests understanding of
- Background task threading in IntelliJ Platform
- When to use
invokeAndWaitIfNeeded vs other patterns
- Write action requirements and proper usage
- Progress indicator usage
- Command processor for undo/redo support
- Anti-cheating mechanisms in educational plugins
Validation
- Create a task with many test files
- Run checker repeatedly and measure performance
- Ensure smooth operation without blocking
- Verify files are still recreated correctly
Estimated time
3-4 hours
Overview
Test file recreation (anti-cheating mechanism) blocks background threads unnecessarily during task checking, potentially causing performance issues.
Location
File:
intellij-plugin/hs-core/src/org/hyperskill/academy/learning/actions/CheckAction.ktFunction:
recreateTestFiles(lines 167-194)Problem
Test file recreation is done synchronously during check with
invokeAndWaitIfNeeded+runWriteAction. This blocks the background thread that's running the check operation.What needs to be fixed
run(indicator: ProgressIndicator)) but usesinvokeAndWaitIfNeededwhich blocks unnecessarilyrunWriteActionAndWaitor restructuring to avoid blockingFrameworkLessonManagerImpl.recreateTestFiles(lines 219-245) - fix both locations consistentlyTests understanding of
invokeAndWaitIfNeededvs other patternsValidation
Estimated time
3-4 hours