From c1638b74cf38693c25b188253278f2e4fe8cbbda Mon Sep 17 00:00:00 2001 From: gwendal Date: Mon, 16 Jan 2017 20:25:54 +0100 Subject: [PATCH] fix #53 by adding sanity check on eObject(Id) --- .../data/hbase/store/DirectWriteHBaseStore.java | 11 +++++++---- .../berkeleydb/store/DirectWriteBerkeleyDbStore.java | 11 +++++++---- .../data/mapdb/store/DirectWriteMapDbStore.java | 11 +++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/neoemf-data/hbase/src/main/java/fr/inria/atlanmod/neoemf/data/hbase/store/DirectWriteHBaseStore.java b/neoemf-data/hbase/src/main/java/fr/inria/atlanmod/neoemf/data/hbase/store/DirectWriteHBaseStore.java index f3d67402bd..5fb6d696db 100644 --- a/neoemf-data/hbase/src/main/java/fr/inria/atlanmod/neoemf/data/hbase/store/DirectWriteHBaseStore.java +++ b/neoemf-data/hbase/src/main/java/fr/inria/atlanmod/neoemf/data/hbase/store/DirectWriteHBaseStore.java @@ -262,10 +262,13 @@ public EStructuralFeature getContainingFeature(InternalEObject internalObject) { @Override public EObject eObject(Id id) { - EClass eClass = resolveInstanceOf(id); - PersistentEObject object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); - if (object.resource() != resource()) { - object.resource(resource()); + PersistentEObject object = null; + if(id != null) { + EClass eClass = resolveInstanceOf(id); + object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); + if (object.resource() != resource()) { + object.resource(resource()); + } } return object; } diff --git a/neoemf-data/map/berkeleydb/src/main/java/fr/inria/atlanmod/neoemf/data/berkeleydb/store/DirectWriteBerkeleyDbStore.java b/neoemf-data/map/berkeleydb/src/main/java/fr/inria/atlanmod/neoemf/data/berkeleydb/store/DirectWriteBerkeleyDbStore.java index 58b4a83ffe..e1e496fe41 100644 --- a/neoemf-data/map/berkeleydb/src/main/java/fr/inria/atlanmod/neoemf/data/berkeleydb/store/DirectWriteBerkeleyDbStore.java +++ b/neoemf-data/map/berkeleydb/src/main/java/fr/inria/atlanmod/neoemf/data/berkeleydb/store/DirectWriteBerkeleyDbStore.java @@ -298,10 +298,13 @@ public EStructuralFeature getContainingFeature(InternalEObject internalObject) { @Override public EObject eObject(Id id) { - EClass eClass = resolveInstanceOf(id); - PersistentEObject object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); - if (object.resource() != resource()) { - object.resource(resource()); + PersistentEObject object = null; + if(id != null) { + EClass eClass = resolveInstanceOf(id); + object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); + if (object.resource() != resource()) { + object.resource(resource()); + } } return object; } diff --git a/neoemf-data/map/mapdb/src/main/java/fr/inria/atlanmod/neoemf/data/mapdb/store/DirectWriteMapDbStore.java b/neoemf-data/map/mapdb/src/main/java/fr/inria/atlanmod/neoemf/data/mapdb/store/DirectWriteMapDbStore.java index 4a8aca08f6..8436468a20 100644 --- a/neoemf-data/map/mapdb/src/main/java/fr/inria/atlanmod/neoemf/data/mapdb/store/DirectWriteMapDbStore.java +++ b/neoemf-data/map/mapdb/src/main/java/fr/inria/atlanmod/neoemf/data/mapdb/store/DirectWriteMapDbStore.java @@ -311,10 +311,13 @@ public EStructuralFeature getContainingFeature(InternalEObject internalObject) { @Override public EObject eObject(Id id) { - EClass eClass = resolveInstanceOf(id); - PersistentEObject object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); - if (object.resource() != resource()) { - object.resource(resource()); + PersistentEObject object = null; + if(id != null) { + EClass eClass = resolveInstanceOf(id); + object = persistentObjectsCache.get(id, new PersistentEObjectCacheLoader(eClass)); + if (object.resource() != resource()) { + object.resource(resource()); + } } return object; }