Skip to content

Write access exception during new SARIF file generation #651

Closed
@dtim

Description

@dtim

Description

An exception is thrown when a new SARIF file is generated:

java.lang.Throwable: Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction())

To Reproduce

Make sure that the resources directory in the test root does not contain utbot-sarif-report* directories.

Generate the test suite for a class or a method so an error suite is generated. Sample code:

public class Foo {
    public int bar(String x) {
        return x.indexOf('a');
    }
}

Expected behavior

Tests are generated, SARIF file is generated, no exception is thrown.

Actual behavior

Tests are generated, SARIF file is generated, an exception is thrown and reported by IDEA as an internal IDE error.

Visual proofs (screenshots, logs, images)

java.lang.Throwable: Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction())
	at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:179)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertWriteAccessAllowed(ApplicationImpl.java:1284)
	at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.processEvent(PersistentFSImpl.java:738)
	at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.createChildDirectory(PersistentFSImpl.java:467)
	at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.createChildDirectory(VirtualFileSystemEntry.java:296)
	at com.intellij.openapi.vfs.VfsUtil.createDirectoryIfMissing(VfsUtil.java:374)
	at com.intellij.openapi.vfs.VfsUtil.createDirectoryIfMissing(VfsUtil.java:364)
	at com.intellij.openapi.vfs.VfsUtil.createDirectoryIfMissing(VfsUtil.java:348)
	at org.utbot.intellij.plugin.sarif.SarifReportIdea.createAndSave(SarifReportIdea.kt:28)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$saveSarifReport$$inlined$executeCommand$1.run(actions.kt:13)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:177)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:167)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:153)
	at org.utbot.intellij.plugin.generator.CodeGenerationController.saveSarifReport(CodeGenerationController.kt:613)
	at org.utbot.intellij.plugin.generator.CodeGenerationController.access$saveSarifReport(CodeGenerationController.kt:84)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1$2$1.run(CodeGenerationController.kt:319)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$run$$inlined$let$lambda$4.run(ApplicationUtils.kt:59)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:322)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:132)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:188)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:967)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:839)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:450)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:449)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:497)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Environment

I can reproduce this issue when no test/resources/utbot-sarif-report directory exists. It seems that the exception is not thrown when the existing SARIF file is not updated.

Additional context

Reproduced in the debug IDEA when building the current main (commit de28e4db5a4722874114196d894530db8ad20633).

Metadata

Metadata

Labels

comp-uiImprovements of plugin UI appearence and functionalityctg-bugIssue is a bugstatus-verifiedBug fix is verified

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions