Persistent data get missing
I have implemented the PersistentStateComponent interface to persist the plugin setting data. Everything works fine as expected but if I keep the IDEA open for a long time (ex: more than 8 hours). PersistentStateComponent class values returns null when the getter methods are called. Need to restart the IDEA to make it work again.What is the possible cause for this issue
IDEA versions : 16.2.4
Following is the implementation
@State(name = "mySetting", storages = @Storage(id = "mySetting",
file = "com.mySetting.setting.xml"))
public class PreferenceManager implements PersistentStateComponent<PreferenceManager> {
public String credentialMap;
public void setCredentialObjectValue(String objValue) {
this.credentialMap = objValue;
}
public String getCredentialObjValue() {
return this.credentialMap;
}
@Nullable
@Override
public PreferenceManager getState() {
return this;
}
@Override
public void loadState(PreferenceManager preferenceManager) {
XmlSerializerUtil.copyBean(preferenceManager, this);
}
Please sign in to leave a comment.
I suggest to use separate state class instead of reusing current instance. In this case you also don't need to use XmlSerializerUtil.copyBean
when I restart ide, Persistent data get missing