state will be null if file deleted

we must create empty (initial) state to reinit component
This commit is contained in:
Vladimir Krivosheev
2015-04-01 14:48:23 +02:00
parent bae9291930
commit 0a85c2709a
2 changed files with 10 additions and 2 deletions
@@ -298,7 +298,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable {
}
Class<T> stateClass = ComponentSerializationUtil.getStateClass(component.getClass());
if (LOG.isDebugEnabled()) {
if (LOG.isDebugEnabled() && getDefaultState(component, name, stateClass) != null) {
LOG.error(name + " has default state, but not marked to load it");
}
@@ -312,9 +312,15 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable {
}
StateStorage stateStorage = getStateStorageManager().getStateStorage(storageSpec);
boolean forcedState = false;
if (stateStorage != null && (stateStorage.hasState(component, name, stateClass, reloadData) ||
(changedStorages != null && changedStorages.contains(stateStorage)))) {
(forcedState = changedStorages != null && changedStorages.contains(stateStorage)))) {
state = stateStorage.getState(component, name, stateClass, state);
if (state == null && forcedState) {
// state will be null if file deleted
// we must create empty (initial) state to reinit component
state = DefaultStateSerializer.deserializeState(new Element("state"), stateClass, null);
}
break;
}
}
@@ -70,11 +70,13 @@ public class FileBasedStorage extends XmlElementStorage {
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
myCachedVirtualFile = null;
listener.storageFileChanged(event, FileBasedStorage.this);
}
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
myCachedVirtualFile = event.getFile();
listener.storageFileChanged(event, FileBasedStorage.this);
}
@Override