PersistentStateComponent is inconsistent

Answered

I have implemented the PersistentStateComponent in my plugin.  However, it doesn't always write the data to the disk.  

I have been using intellj-community as a test bed and find that executing  code analysis programmatically vs. through the IDE (Ultimate) behaves differently, throwing recursion exceptions when done programmatically.   These exceptions appear to interfere with the PersistentStateComponent causing it to fail.  This is very bad considering it takes many hours to perform an analysis of intellij-community with the default inspection profile.

ASIDE:  The same analysis took about 3 hours, finding over 130k errors, when called programmatically and about 7 hours from the IDE, finding over 190k errors , why is there that much difference?!?!  Runs were made back-to-back with the same computer.

All that time, data has been loading into the data structure to be persisted, but when the project and/or application are closed, the data is not persisted.  Doing the same thing with a smaller project _mostly_ works, though also, not consistently.

Application.save and Project.save don't work to persist the data either.  Further, locking up the EDT for the write is terrible due to the large amount of data that can be collected over time, which results in an unresponsive IDE.  I assume I must be missing something or I must have misinterpreted/misunderstood what I read about persisting data requiring use of the EDT, particularly since the data generated is not displayed to the user.

All this information is to ask: what can be done to improve the reliability of PersistentStateComponent or to trigger a write to disk without locking the IDE/EDT?  I would rather not have to right my own persistence mechanism, but it looks like I may have to.

0
1 comment

Hi Todd,

Regarding the differences between executing analysis, it's hard to say without more details. If it is running an inspection profile, then the difference in the setup may be the reason. If you are running the same inspection profile from the same IDE instance, then I suggest sharing the code.

If the data is not persisted, are there any errors in the log?

I suggest describing your use case in more detail, so we can propose a better solution.

0

Please sign in to leave a comment.