diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3785edbe3..46b8c3b8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+## [1.1.2] - 2024-03-26
+
+### Changed
+
+- Fixes a bug in the InMemoryBackingStore that would not leave out properties in nested IBackedModel properties.
+
## [1.1.1] - 2024-03-20
### Changed
diff --git a/components/abstractions/spotBugsExcludeFilter.xml b/components/abstractions/spotBugsExcludeFilter.xml
index 23f22f549..4db33b49d 100644
--- a/components/abstractions/spotBugsExcludeFilter.xml
+++ b/components/abstractions/spotBugsExcludeFilter.xml
@@ -50,4 +50,12 @@ xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubu
+
+
+
+
+
+
+
+
diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/store/InMemoryBackingStore.java b/components/abstractions/src/main/java/com/microsoft/kiota/store/InMemoryBackingStore.java
index 50e22fae9..e8be53018 100644
--- a/components/abstractions/src/main/java/com/microsoft/kiota/store/InMemoryBackingStore.java
+++ b/components/abstractions/src/main/java/com/microsoft/kiota/store/InMemoryBackingStore.java
@@ -6,6 +6,7 @@
import jakarta.annotation.Nullable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,7 +34,7 @@ public A getValue0() {
}
public Pair setValue0(A value0) {
- return new Pair(value0, value1);
+ return new Pair<>(value0, value1);
}
public B getValue1() {
@@ -41,7 +42,7 @@ public B getValue1() {
}
public Pair setValue1(B value1) {
- return new Pair(value0, value1);
+ return new Pair<>(value0, value1);
}
}
@@ -55,7 +56,15 @@ public void setIsInitializationCompleted(final boolean value) {
this.isInitializationCompleted = value;
for (final Map.Entry> entry : this.store.entrySet()) {
final Pair wrapper = entry.getValue();
- final Pair updatedValue = wrapper.setValue0(Boolean.valueOf(!value));
+ if (wrapper.getValue1() instanceof BackedModel) {
+ BackedModel backedModel = (BackedModel) wrapper.getValue1();
+ backedModel
+ .getBackingStore()
+ .setIsInitializationCompleted(value); // propagate initialization
+ }
+ ensureCollectionPropertyIsConsistent(
+ entry.getKey(), this.store.get(entry.getKey()).getValue1());
+ final Pair updatedValue = wrapper.setValue0(!value);
entry.setValue(updatedValue);
}
}
@@ -80,10 +89,12 @@ public void clear() {
final Map result = new HashMap<>();
for (final Map.Entry> entry : this.store.entrySet()) {
final Pair wrapper = entry.getValue();
- final Object value = this.getValueFromWrapper(wrapper);
+ final Object value = this.getValueFromWrapper(entry.getKey(), wrapper);
if (value != null) {
result.put(entry.getKey(), wrapper.getValue1());
+ } else if (Boolean.TRUE.equals(wrapper.getValue0())) {
+ result.put(entry.getKey(), null);
}
}
return result;
@@ -101,13 +112,15 @@ public void clear() {
return result;
}
- private Object getValueFromWrapper(final Pair wrapper) {
+ private Object getValueFromWrapper(final String entryKey, final Pair wrapper) {
if (wrapper != null) {
final Boolean hasChanged = wrapper.getValue0();
- if (!this.returnOnlyChangedValues
- || (this.returnOnlyChangedValues
- && hasChanged != null
- && hasChanged.booleanValue())) {
+ if (!this.returnOnlyChangedValues || Boolean.TRUE.equals(hasChanged)) {
+ ensureCollectionPropertyIsConsistent(entryKey, wrapper.getValue1());
+ if (wrapper.getValue1() instanceof Pair) {
+ Pair, ?> collectionTuple = (Pair, ?>) wrapper.getValue1();
+ return collectionTuple.getValue0();
+ }
return wrapper.getValue1();
}
}
@@ -118,7 +131,7 @@ private Object getValueFromWrapper(final Pair wrapper) {
@Nullable public T get(@Nonnull final String key) {
Objects.requireNonNull(key);
final Pair wrapper = this.store.get(key);
- final Object value = this.getValueFromWrapper(wrapper);
+ final Object value = this.getValueFromWrapper(key, wrapper);
try {
return (T) value;
} catch (ClassCastException ex) {
@@ -128,11 +141,39 @@ private Object getValueFromWrapper(final Pair wrapper) {
public void set(@Nonnull final String key, @Nullable final T value) {
Objects.requireNonNull(key);
- final Pair valueToAdd =
- new Pair(Boolean.valueOf(this.isInitializationCompleted), value);
+ Pair valueToAdd = new Pair<>(this.isInitializationCompleted, value);
+ if (value instanceof Collection) {
+ valueToAdd = valueToAdd.setValue1(new Pair<>(value, ((Collection>) value).size()));
+ final Collection