ZEST-107 Fix JSONEntityState clone logic
The cloneStateIfGlobalStateLoaded() method of JSONEntityState is called
before any change is made to the entity state.
This method starts with the following check:
if( isStateNotCloned() )
{
return;
}
// Do the clone
And the (private) isStateNotCloned() method returns:
status == EntityStatus.LOADED
IOW, the code says that it will clone state if status is loaded,
but does the opposite!
Rewriting the cloneStateIfGlobalStateLoaded() method,
as Tibor suggested, fixes the issue:
if( status != EntityState.LOADED )
{
return;
}
// Do the clone
I removed the isStateNotCloned() method BTW as it was not used elsewhere
and the code is simpler without it.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/14cbf30d
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/14cbf30d
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/14cbf30d
Branch: refs/heads/develop
Commit: 14cbf30dcc28af1573f3779c685a595e9aa41a0e
Parents: 965c769
Author: Paul Merlin <[email protected]>
Authored: Mon Jul 27 16:22:07 2015 +0200
Committer: Paul Merlin <[email protected]>
Committed: Mon Jul 27 17:09:02 2015 +0200
----------------------------------------------------------------------
.../org/qi4j/spi/entitystore/helpers/JSONEntityState.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/14cbf30d/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/JSONEntityState.java
----------------------------------------------------------------------
diff --git
a/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/JSONEntityState.java
b/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/JSONEntityState.java
index 435acde..ae60809 100644
---
a/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/JSONEntityState.java
+++
b/core/spi/src/main/java/org/qi4j/spi/entitystore/helpers/JSONEntityState.java
@@ -308,14 +308,9 @@ public final class JSONEntityState
}
}
- boolean isStateNotCloned()
- {
- return status == EntityStatus.LOADED;
- }
-
void cloneStateIfGlobalStateLoaded()
{
- if( isStateNotCloned() )
+ if( status != EntityStatus.LOADED )
{
return;
}