Skip to content

Commit b2a3901

Browse files
committed
- improves defensive programing on base collection set raw data
1 parent 35cbd1e commit b2a3901

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/com/microsoft/graph/http/BaseCollectionResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public String nextLink() {
5959
public final AdditionalDataManager additionalDataManager() {
6060
return additionalDataManager;
6161
}
62-
62+
private final static String valueJsonKey = "value";
6363
/**
6464
* Sets the raw JSON object
6565
*
@@ -69,9 +69,9 @@ public final AdditionalDataManager additionalDataManager() {
6969
public void setRawObject(@Nonnull final ISerializer serializer, @Nonnull final JsonObject json) {
7070
Objects.requireNonNull(serializer, "parameter serializer cannot be null");
7171
Objects.requireNonNull(json, "parameter json cannot be null");
72-
if (json.has("value")) {
73-
final JsonArray array = json.getAsJsonArray("value");
74-
for (int i = 0; i < array.size(); i++) {
72+
if (json.has(valueJsonKey) && value != null && value.size() > 0) {
73+
final JsonArray array = json.getAsJsonArray(valueJsonKey);
74+
for (int i = 0; i < array.size() && i < value.size(); i++) {
7575
final Object targetObject = value.get(i);
7676
if(targetObject instanceof IJsonBackedObject && array.get(i).isJsonObject()) {
7777
((IJsonBackedObject)targetObject).setRawObject(serializer, array.get(i).getAsJsonObject());

0 commit comments

Comments
 (0)