SonarLint抛出IllegalStateException->无法读取本地问题存储索引

2019年1月9日 36点热度 0条评论

我目前正在使用Eclipse和Java工作。我们应该使用SonarLint来获取一些更简洁的代码,直到昨天一切都很好。
但是昨天早晨,当我打开Eclipse时,SonarLint向我抛出了以下错误消息。

我已经在Google中搜索过,删除了.sonarlint文件夹,eclipse的settingsfolder和eclipse-workspace内的.sonarlint文件夹。他们每个人都通过重新启动Eclipse重新创建,但没有任何帮助。我仍然收到错误:

Starting SonarLint for Eclipse 4.2.0.201909192007
SonarLint processing file /rap-server-core/src/main/java/com/rapidclipse/framework/server/ui/filter/FilterComponent.java...
Starting standalone SonarLint engine 4.2.0.201909192007...
Found 17 issue(s)
Error during execution of SonarLint analysis
java.lang.IllegalStateException: Failed to read local issue store index
    at org.sonarlint.eclipse.core.internal.tracking.StringStoreIndex.load(StringStoreIndex.java:55)
    at org.sonarlint.eclipse.core.internal.tracking.StringStoreIndex.keys(StringStoreIndex.java:45)
    at org.sonarlint.eclipse.core.internal.tracking.IndexedObjectStore.deleteInvalid(IndexedObjectStore.java:78)
    at org.sonarlint.eclipse.core.internal.tracking.IssueStore.<init>(IssueStore.java:62)
    at org.sonarlint.eclipse.core.internal.SonarLintCorePlugin.lambda$0(SonarLintCorePlugin.java:102)
    at org.sonarlint.eclipse.core.internal.tracking.IssueTrackerRegistry.newTracker(IssueTrackerRegistry.java:54)
    at org.sonarlint.eclipse.core.internal.tracking.IssueTrackerRegistry.getOrCreate(IssueTrackerRegistry.java:43)
    at org.sonarlint.eclipse.core.internal.SonarLintCorePlugin.getOrCreateIssueTracker(SonarLintCorePlugin.java:146)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.trackIssues(AbstractAnalyzeProjectJob.java:317)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.lambda$15(AbstractAnalyzeProjectJob.java:302)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2295)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.updateMarkers(AbstractAnalyzeProjectJob.java:302)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.runAnalysisAndUpdateMarkers(AbstractAnalyzeProjectJob.java:209)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.doRun(AbstractAnalyzeProjectJob.java:169)
    at org.sonarlint.eclipse.core.internal.jobs.AbstractSonarProjectJob.run(AbstractSonarProjectJob.java:45)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
    at com.google.protobuf.InvalidProtocolBufferException.invalidTag(InvalidProtocolBufferException.java:102)
    at com.google.protobuf.CodedInputStream$StreamDecoder.readTag(CodedInputStream.java:2066)
    at org.sonarlint.eclipse.core.internal.proto.Sonarlint$StorageIndex.<init>(Sonarlint.java:2496)
    at org.sonarlint.eclipse.core.internal.proto.Sonarlint$StorageIndex.<init>(Sonarlint.java:2482)
    at org.sonarlint.eclipse.core.internal.proto.Sonarlint$StorageIndex$1.parsePartialFrom(Sonarlint.java:3126)
    at org.sonarlint.eclipse.core.internal.proto.Sonarlint$StorageIndex$1.parsePartialFrom(Sonarlint.java:1)
    at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:215)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:232)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:237)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:48)
    at com.google.protobuf.GeneratedMessageV3.parseWithIOException(GeneratedMessageV3.java:332)
    at org.sonarlint.eclipse.core.internal.proto.Sonarlint$StorageIndex.parseFrom(Sonarlint.java:2746)
    at org.sonarlint.eclipse.core.internal.tracking.StringStoreIndex.load(StringStoreIndex.java:53)
    ... 16 more

我不知道问题出在什么地方,正如我所说的,谷歌不能为我提供太多帮助(也许我只是对谷歌idk感到愚蠢)

解决方案如下:

我有同样的问题。

我曾尝试从5.0降级到4.3,但这并不能解决问题。

因此,我进行了一些调查,发现在源代码中sonarlint-eclipse/org.sonarlint.eclipse.core/src/org/sonarlint/eclipse/core/internal/tracking/StringStoreIndex.java 53行最终导致了public static final String INDEX_FILENAME = "index.pb";(34行)。

所以我要做的是在Eclipse,Maven和Workspace文件夹中的del /s /q /f index.pb。它在Workspace .metadata\.plugins文件夹下。

现在,错误似乎消失了。 SonarLint最终报告了“臭味”代码所在的位置。

我感觉index.pb的权限混乱或未更新,并且无法按照错误消息提示加载文件。

但是现在恢复正常。 :)