Fixes cache bug and null emission issue
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
index 5430759..186aafa 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
@@ -100,7 +100,7 @@
return Observable.just( entity );
}
- return Observable.empty();
+ return targetEntityCollectionManager.load( entityId ).doOnNext( cacheAdd );
}
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index 8c754c1..7c467c6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -230,21 +230,24 @@
Preconditions.checkNotNull( entityId.getUuid(), "Entity id uuid required in load stage" );
Preconditions.checkNotNull( entityId.getType(), "Entity id type required in load stage" );
- return load( Collections.singleton( entityId ) ).map( new Func1<EntitySet, Entity>() {
+ return load( Collections.singleton( entityId ) ).flatMap( new Func1<EntitySet, Observable<Entity>>() {
@Override
- public Entity call( final EntitySet entitySet ) {
+ public Observable<Entity> call( final EntitySet entitySet ) {
final MvccEntity entity = entitySet.getEntity( entityId );
- if ( entity == null ) {
- return null;
+ if ( entity == null || !entity.getEntity().isPresent() ) {
+ return Observable.empty();
}
- return entity.getEntity().orNull();
+ return Observable.from( entity.getEntity().get() );
}
} );
}
+
+
+
@Override
public Observable<EntitySet> load( final Collection<Id> entityIds ) {
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index acce2d8..7b391a1 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -142,7 +142,7 @@
emf.rebuildApplicationIndexes( appId, po );
}
catch ( Exception e ) {
- logger.error( "Unable to re-index application" );
+ logger.error( "Unable to re-index application", e );
}
}
};