Component
References
Problem details
16 times reported by shuang
file text mismatch:
matching=true
injected=false
injectedFile=false
committed=true
file=OrderRuleService.java
file class=class com.intellij.psi.impl.source.PsiJavaFileImpl
file.valid=true
file.physical=true
file.eventSystemEnabled=true
language=Language: JAVA
doc.length=7384
psiFile.length=11478
cached.psiFiles=1
code.insight.contexts=1
psiFile.text.length=7384
node.length=11478
node.text.length=11478
contents.length=7384
viewProvider=com.intellij.psi.SingleRootFileViewProvider{
vFile=file:///Users/shuang/owner/work/yao/ykq-order-center/ykq-order-center-service/src/main/java/com/xyy/ykq/order/service/rule/OrderRuleService.java,
vFileId=788220,
content=VirtualFileContent{size=8058},
eventSystemEnabled=true
}
virtualFile=file:///Users/shuang/owner/work/yao/ykq-order-center/ykq-order-center-service/src/main/java/com/xyy/ykq/order/service/rule/OrderRuleService.java
virtualFile.class=class com.intellij.openapi.vfs.newvfs.impl.VirtualFileImpl
java.lang.Throwable at
com.intellij.util.ExceptionUtil.currentStackTrace(ExceptionUtil.java:79) at
com.intellij.psi.impl.DebugUtil.currentStackTrace(DebugUtil.java:511) at
com.intellij.psi.impl.source.PsiConsistencyAssertions.assertNoFileTextMismatch(PsiConsistencyAssertions.java:78) at
com.intellij.psi.impl.source.PsiFileImpl.getText(PsiFileImpl.java:339) at
com.intellij.psi.stubs.StubTextInconsistencyException.<init>(StubTextInconsistencyException.java:36) at
com.intellij.psi.stubs.StubTextInconsistencyException.checkStubTextConsistency(StubTextInconsistencyException.java:104) at
com.intellij.psi.stubs.StubProcessingHelperBase.inconsistencyDetected(StubProcessingHelperBase.java:214) at
com.intellij.psi.stubs.StubProcessingHelperBase.checkType(StubProcessingHelperBase.java:147) at
com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:77) at
com.intellij.psi.stubs.StubIndexEx.lambda$processElements$6(StubIndexEx.java:170) at
com.intellij.psi.stubs.StubIndexEx.processElements(StubIndexEx.java:221) at
com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:101) at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:90) at
com.intellij.psi.impl.java.stubs.index.JavaAnnotationIndex.getAnnotations(JavaAnnotationIndex.java:41) at
com.intellij.psi.impl.search.AnnotatedElementsSearcher.lambda$getAnnotationCandidates$3(AnnotatedElementsSearcher.java:71) at
com.intellij.openapi.application.impl.AppImplKt$rethrowCheckedExceptions$2.invoke(appImpl.kt:126) at
com.intellij.platform.locking.impl.NestedLocksThreadingSupport.runReadAction(NestedLocksThreadingSupport.kt:856) at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:1069) at
com.intellij.openapi.application.ReadAction.compute(ReadAction.java:66) at
com.intellij.psi.impl.search.AnnotatedElementsSearcher.getAnnotationCandidates(AnnotatedElementsSearcher.java:69) at
com.intellij.psi.impl.search.AnnotatedElementsSearcher.execute(AnnotatedElementsSearcher.java:35) at
com.intellij.psi.impl.search.AnnotatedElementsSearcher.execute(AnnotatedElementsSearcher.java:21) at
com.intellij.util.ExecutorsQuery.processResults(ExecutorsQuery.java:31) at
com.intellij.util.AbstractQuery.doProcessResults(AbstractQuery.java:84) at
com.intellij.util.AbstractQuery.delegateProcessResults(AbstractQuery.java:101) at
com.intellij.util.InstanceofQuery.processResults(InstanceofQuery.java:22) at
com.intellij.util.AbstractQuery.doProcessResults(AbstractQuery.java:84) at com.intellij.util.AbstractQuery.forEach(AbstractQuery.java:76) at
com.intellij.util.AbstractQuery.findAll(AbstractQuery.java:25) at com.intellij.util.Query.asIterable(Query.kt:140) at
com.intellij.util.Query.iterator(Query.kt:153) at com.intellij.util.AbstractQuery.iterator(AbstractQuery.java:35) at
kotlin.sequences.SequencesKt___SequencesKt$flatMap$1.invoke(_Sequences.kt:869) at
kotlin.sequences.SequencesKt___SequencesKt$flatMap$1.invoke(_Sequences.kt:869) at
kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:363) at
kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:351) at
kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:202) at
kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:227) at
kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:202) at
kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:227) at
kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:247) at
kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:853) at
com.explyt.spring.core.service.SpringSearchService.searchBeanPsiClassesByAnnotations(SpringSearchService.kt:431) at
com.explyt.spring.core.service.SpringSearchService.getBeanPsiClassesAnnotatedByComponent$lambda$26$lambda$25(SpringSearchService.kt:270) at
com.intellij.psi.impl.AbstractPsiCachedValue.doCompute(PsiCachedValueImpl.kt:21) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:299) at
com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:37) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:299) at
com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:113) at
com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:28) at
com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at
com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:300) at
com.intellij.psi.impl.AbstractPsiCachedValue.getValue(PsiCachedValueImpl.kt:15) at
com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:83) at
com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126) at
com.explyt.spring.core.service.SpringSearchService.getBeanPsiClassesAnnotatedByComponent(SpringSearchService.kt:265) at
com.explyt.spring.core.service.SpringSearchService.searchAllBeanClasses(SpringSearchService.kt:93) at
com.explyt.spring.core.service.SpringSearchService.searchAllBeanLight$lambda$14$lambda$13(SpringSearchService.kt:186) at
com.intellij.psi.impl.AbstractPsiCachedValue.doCompute(PsiCachedValueImpl.kt:21) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:299) at
com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:37) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:299) at
com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:113) at
com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:28) at
com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at
com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:300) at
com.intellij.psi.impl.AbstractPsiCachedValue.getValue(PsiCachedValueImpl.kt:15) at
com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:83) at
com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126) at
com.explyt.spring.core.service.SpringSearchService.searchAllBeanLight(SpringSearchService.kt:184) at
com.explyt.spring.core.service.SpringSearchService.getAllBeansClasses$lambda$12$lambda$11(SpringSearchService.kt:174) at
com.intellij.psi.impl.AbstractPsiCachedValue.doCompute(PsiCachedValueImpl.kt:21) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:299) at
com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:37) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:299) at
com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:113) at
com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:28) at
com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at
com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:300) at
com.intellij.psi.impl.AbstractPsiCachedValue.getValue(PsiCachedValueImpl.kt:15) at
com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:83) at
com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126) at
com.explyt.spring.core.service.SpringSearchService.getAllBeansClasses(SpringSearchService.kt:172) at
com.explyt.spring.core.service.SpringSearchService.getActiveBeansClasses(SpringSearchService.kt:200) at
com.explyt.spring.core.service.SpringSearchService.getAllBeanByNames$lambda$16(SpringSearchService.kt:207) at
com.intellij.psi.impl.AbstractPsiCachedValue.doCompute(PsiCachedValueImpl.kt:21) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:299) at
com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:37) at
com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:299) at
com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:113) at
com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:28) at
com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at
com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:300) at
com.intellij.psi.impl.AbstractPsiCachedValue.getValue(PsiCachedValueImpl.kt:15) at
com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:83) at
com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126) at
com.explyt.spring.core.service.SpringSearchService.getAllBeanByNames(SpringSearchService.kt:205) at
com.explyt.spring.core.service.SpringSearchServiceFacade.getAllBeanByNames(SpringSearchServiceFacade.kt:89) at
com.explyt.spring.core.inspections.SpringDependsOnBeanInspection.check(SpringDependsOnBeanInspection.kt:62) at
com.explyt.spring.core.inspections.SpringDependsOnBeanInspection.checkMethod(SpringDependsOnBeanInspection.kt:43) at
com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool$1.visitMethod(AbstractBaseUastLocalInspectionTool.java:90) at
org.jetbrains.uast.UMethod.accept(UMethod.kt:42) at
com.intellij.uast.UastHintedVisitorAdapter.visitElement(UastHintedVisitorAdapter.kt:28) at
com.intellij.psi.impl.source.PsiMethodImpl.accept(PsiMethodImpl.java:293) at
com.intellij.codeInsight.daemon.impl.InspectionRunner$InspectionProblemHolder.visitElement(InspectionRunner.java:616) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processContext$19(InspectionRunner.java:416) at
com.intellij.codeInsight.daemon.impl.InspectionVisitorOptimizer.acceptElements(InspectionVisitorOptimizer.java:219) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.processContext(InspectionRunner.java:414) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$7(InspectionRunner.java:179) at
com.intellij.platform.locking.impl.NestedLocksThreadingSupport.tryRunReadAction(NestedLocksThreadingSupport.kt:902) at
com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1237) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$executeInImpatientReadAction$16(InspectionRunner.java:393) at
com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:158) at
com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:150) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$executeInImpatientReadAction$17(InspectionRunner.java:384) at
com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:129) at
com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:118) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.executeInImpatientReadAction(InspectionRunner.java:384) at
com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$8(InspectionRunner.java:173) at
com.intellij.concurrency.ApplierCompleter.processArrayItem(ApplierCompleter.java:121) at
com.intellij.concurrency.ApplierCompleter.processArray(ApplierCompleter.java:221) at
com.intellij.concurrency.ApplierCompleter.helpOthers(ApplierCompleter.java:241) at
com.intellij.concurrency.ApplierCompleter.lambda$helpAll$3(ApplierCompleter.java:182) at
com.intellij.concurrency.ThreadContext.resetThreadContext(threadContext.kt:294) at
com.intellij.concurrency.ApplierCompleter.helpAll(ApplierCompleter.java:181) at
com.intellij.concurrency.ApplierCompleter.lambda$exec$0(ApplierCompleter.java:111) at
com.intellij.platform.locking.impl.NestedLocksThreadingSupport.tryRunReadAction(NestedLocksThreadingSupport.kt:902) at
com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1237) at
com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$2(ApplierCompleter.java:153) at
com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:717) at
com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:792) at
com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:748) at
com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:716) at
com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:75) at
com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:164) at
com.intellij.concurrency.ApplierCompleter.lambda$wrapAndRun$1(ApplierCompleter.java:145) at
com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:259) at
com.intellij.concurrency.ApplierCompleter.wrapAndRun(ApplierCompleter.java:145) at
com.intellij.concurrency.ApplierCompleter.exec(ApplierCompleter.java:113) at
java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507) at
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491) at
java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073) at
java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035) at
java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Steps to reproduce
No response
Additional information
No response
Plugin version
253.30
Build system
Gradle
Additional context
LLM cause analysis:
Cause Analysis
The "file text mismatch" error with StubTextInconsistencyException is occurring in your IntelliJ-based plugin code (SpringSearchService). This is a PSI consistency error that happens when:
- PSI/Stub Index Inconsistency: The IntelliJ Platform's PSI system maintains an index (stubs) of Java/Kotlin files for faster processing. The error indicates that there's a mismatch between what's stored in the stub index and the actual file content.
- Root Cause Location: The error is triggered in SpringSearchService.searchBeanPsiClassesByAnnotations method at line 431, which is performing annotation-based search using AnnotatedElementsSearch.searchPsiClasses.
- Specific Issue: The error message shows:
- file.text.length=7384 vs psiFile.text.length=11478 vs node.text.length=11478
- This indicates that different components of the PSI system have different understandings of the file's text length
Common Causes in IntelliJ Plugin Development:
- Concurrent File Modification: The file (OrderRuleService.java) was modified while the PSI system was processing it
- Stub Index Corruption: The stub index for the file became corrupted or out of sync
- File System vs In-Memory Discrepancy: The file on disk doesn't match what's loaded in memory
- Plugin Code Modifying PSI Incorrectly: Your plugin code might be modifying PSI trees without proper write actions or consistency checks
- Caching Issue: Cached PSI data is stale compared to actual file content
The Specific Problem in Your Code:
Looking at SpringSearchService.kt, the code is performing PSI operations (searching for annotated classes) in a read action context. The error occurs because:
- The file OrderRuleService.java is being processed
- The PSI system detects that the file's text in the stub index doesn't match what's in the PSI tree
- This triggers StubTextInconsistencyException which is caught by StubProcessingHelperBase.inconsistencyDetected
Solution Approach:
- Wrap in Proper Read Action: Ensure all PSI access is properly wrapped in runReadAction blocks
- Handle Stale Data: Add checks for isValid on PSI elements before using them
- Use Cached Values Properly: The code already uses CachedValuesManager - ensure cache invalidation happens when files change
- Add Error Handling: Catch and handle StubTextInconsistencyException gracefully
- Consider File Events: The file might have changed externally - check file timestamps or use VirtualFile listeners
The error is likely intermittent and occurs when files are modified during IDE operation. The fix would involve adding proper error handling and validity checks in the PSI traversal code.
Component
References
Problem details
16 times reported by shuang
Steps to reproduce
No response
Additional information
No response
Plugin version
253.30
Build system
Gradle
Additional context
LLM cause analysis:
Cause Analysis
The "file text mismatch" error with StubTextInconsistencyException is occurring in your IntelliJ-based plugin code (SpringSearchService). This is a PSI consistency error that happens when:
Common Causes in IntelliJ Plugin Development:
The Specific Problem in Your Code:
Looking at SpringSearchService.kt, the code is performing PSI operations (searching for annotated classes) in a read action context. The error occurs because:
Solution Approach:
The error is likely intermittent and occurs when files are modified during IDE operation. The fix would involve adding proper error handling and validity checks in the PSI traversal code.