Skip to content

Commit a60b508

Browse files
IdentitySet fix
1 parent 0378316 commit a60b508

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/IdentitySet.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import java.util.Objects;
2323
import java.util.Set;
2424

25+
import jakarta.annotation.Nonnull;
26+
2527
import org.eclipse.serializer.meta.NotImplementedYetError;
2628
import org.springframework.lang.NonNull;
2729

28-
import jakarta.annotation.Nonnull;
29-
3030

3131
/**
3232
* A hash map implementation depending on object identity (==) rather than equality (.equals) to identify elements.
@@ -113,7 +113,8 @@ public boolean retainAll(@Nonnull final Collection<?> c)
113113
@Override
114114
public boolean removeAll(final Collection<?> c)
115115
{
116-
return c.stream().map(this.internalMap::remove).anyMatch(Objects::nonNull);
116+
// "Why toList?" - So that if you input your own reference (this) into this funciton, it does not break.
117+
return c.stream().toList().stream().map(this.internalMap::remove).anyMatch(Objects::nonNull);
117118
}
118119

119120
@Override

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public synchronized <T> void deleteAll(final Class<T> clazz)
225225
this.entitySetCollector.getRelatedIdentitySets(clazz);
226226
entityLists.forEach(entityList ->
227227
{
228-
entityList.removeAll(entities);
228+
entityList.removeAll(entityList);
229229
this.storageManager.store(entityList.getInternalMap());
230230
});
231231
if(LOG.isDebugEnabled())

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/repositories/real/life/example/Invoice.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020

2121
public class Invoice
2222
{
23-
private final List<Position> positions;
23+
private List<Position> positions;
2424

2525
public Invoice(final List<Position> positions)
2626
{
2727
this.positions = positions;
2828
}
2929

30+
public void setPositions(final List<Position> positions)
31+
{
32+
this.positions = positions;
33+
}
34+
3035
public List<Position> getPositions()
3136
{
3237
return this.positions;

0 commit comments

Comments
 (0)