Skip to content

Commit c1f0c61

Browse files
committed
Fix NPE in empty BitmapIndices
1 parent 15ebbbc commit c1f0c61

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

gigamap/gigamap/src/main/java/org/eclipse/store/gigamap/types/BitmapIndices.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,25 @@ public final void ensureOptimizedPerformance()
701701
@Override
702702
public void internalPrepareIndicesUpdate(final E replacedEntity)
703703
{
704+
if(this.bitmapIndices.isEmpty())
705+
{
706+
// no-op
707+
return;
708+
}
709+
704710
// Derive state handlers for the state of the replaced entity.
705711
this.createChangeHandlers(this.cachedPrevChangeHandlers, replacedEntity);
706712
}
707713

708714
@Override
709715
public void internalFinishIndicesUpdate()
710716
{
717+
if(this.bitmapIndices.isEmpty())
718+
{
719+
// no-op
720+
return;
721+
}
722+
711723
this.clearCachedChangeHandlers();
712724
}
713725

@@ -719,6 +731,12 @@ public final void internalUpdateIndices(
719731
final CustomConstraints<? super E> customConstraints
720732
)
721733
{
734+
if(this.bitmapIndices.isEmpty())
735+
{
736+
// no-op
737+
return;
738+
}
739+
722740
try
723741
{
724742
// Derive state handlers for the new, potentially changed state

gigamap/gigamap/src/test/java/org/eclipse/store/gigamap/indexer/BasicIndexerTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ void update()
287287
assertEquals(0, map.query(indexer).in(1L, 5L).count());
288288
}
289289

290+
@Test
291+
void setWithNoIndex()
292+
{
293+
final GigaMap<String> map = GigaMap.New();
294+
final long id = map.add("foo");
295+
assertEquals("foo", map.set(id, "bar"));
296+
}
297+
290298
@Test
291299
void bulk()
292300
{

0 commit comments

Comments
 (0)