eclipse-tm4e / tm4e

TextMate support in Eclipse IDE
https://projects.eclipse.org/projects/technology.tm4e
Eclipse Public License 2.0
93 stars 56 forks source link

Lot of errors logged on non existing resources since 0.9.0 #661

Closed iloveeclipse closed 9 months ago

iloveeclipse commented 9 months ago

I've tried to update from 0.8.1 to 0.9.0 but in our automates tests we see huge number of fails because the code now logs lot of errors during testing.

The problem is that the content type checks that run in UI thread are running asynchronously to the resource changes and if tests create/delete/move files the HasLanguageConfigurationPropertyTester may be queried on stale resources, flooding the log with errors.

!ENTRY org.eclipse.tm4e.ui 4 0 2024-01-11 00:04:40.410
!MESSAGE Resource '/xxx.txt' does not exist.
!STACK 1
org.eclipse.core.internal.resources.ResourceException(/xxx.txt)[368]: java.lang.Exception: Resource '/xxx.txt' does not exist.
    at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
    at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
    at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:367)
    at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:241)
    at org.eclipse.core.internal.resources.File.getContentDescription(File.java:276)
    at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.getContentType(ResourceTextFileBuffer.java:187)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.getContentTypes(ContentTypeHelper.java:109)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.findContentTypesFromFileBuffers(ContentTypeHelper.java:92)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.findContentTypes(ContentTypeHelper.java:55)
    at org.eclipse.tm4e.languageconfiguration.internal.HasLanguageConfigurationPropertyTester.test(HasLanguageConfigurationPropertyTester.java:46)
    at org.eclipse.core.internal.expressions.Property.test(Property.java:65)
    at org.eclipse.core.expressions.TestExpression.evaluate(TestExpression.java:107)
    at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
    at org.eclipse.core.expressions.WithExpression.evaluate(WithExpression.java:84)
    at org.eclipse.core.expressions.ReferenceExpression.evaluate(ReferenceExpression.java:72)
    at org.eclipse.ui.internal.services.EvaluationReference.evaluate(EvaluationReference.java:79)
    at org.eclipse.ui.internal.services.EvaluationReference.evaluate(EvaluationReference.java:109)
    at org.eclipse.ui.internal.services.EvaluationReference.changed(EvaluationReference.java:103)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:105)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:358)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:374)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.activate(EclipseContext.java:661)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.activateBranch(EclipseContext.java:670)
    at org.eclipse.e4.ui.internal.workbench.PartActivationHistory.activate(PartActivationHistory.java:60)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:767)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:686)
    at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63)
!SUBENTRY 1 org.eclipse.core.filesystem 4 269 2024-01-11 00:01:00.404
!MESSAGE File not found: /workspaces/xxx/yyy.
!STACK 0
java.io.FileNotFoundException: /workspaces/xxx/yyy (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
    at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:453)
    at org.eclipse.core.internal.filebuffers.FileStoreTextFileBuffer.getContentType(FileStoreTextFileBuffer.java:282)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.getContentTypes(ContentTypeHelper.java:109)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.findContentTypesFromFileBuffers(ContentTypeHelper.java:92)
    at org.eclipse.tm4e.ui.internal.utils.ContentTypeHelper.findContentTypes(ContentTypeHelper.java:55)
    at org.eclipse.tm4e.languageconfiguration.internal.HasLanguageConfigurationPropertyTester.test(HasLanguageConfigurationPropertyTester.java:46)
    at org.eclipse.core.internal.expressions.Property.test(Property.java:65)
    at org.eclipse.core.expressions.TestExpression.evaluate(TestExpression.java:107)
    at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
    at org.eclipse.core.expressions.WithExpression.evaluate(WithExpression.java:84)
    at org.eclipse.core.expressions.ReferenceExpression.evaluate(ReferenceExpression.java:72)
    at org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer.isCoreExpressionVisible(ContributionsAnalyzer.java:281)
    at org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer.isVisible(ContributionsAnalyzer.java:255)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributionRecord.computeVisibility(ContributionRecord.java:170)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributionRecord.updateVisibility(ContributionRecord.java:101)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter.updateElementVisibility(MenuManagerRendererFilter.java:191)
    at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter.updateElementVisibility(MenuManagerRendererFilter.java:202)
    at org.eclipse.ui.internal.WorkbenchWindow.lambda$3(WorkbenchWindow.java:868)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5039)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4519)

I will propose a trivial patch in a moment.

sebthom commented 9 months ago

Can you please check if this issue is solved with the latest snapshot version?

iloveeclipse commented 9 months ago

Can you please check if this issue is solved with the latest snapshot version?

I've tested with my PR https://github.com/eclipse/tm4e/pull/662 and it isn't much different to the version on master yet, so I assume we should be fine here.

Thanks for fast fix.