Skip to content

Commit 7303bae

Browse files
authored
Merge pull request #157 from microsoftgraph/bugfix/collections-nextpage-null
- fixes a bug where next page would always be null because of deserialization regression
2 parents 88e84f3 + 6599f32 commit 7303bae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.net.URL;
2626
import java.lang.reflect.InvocationTargetException;
27+
import java.util.Collections;
2728
import java.util.List;
2829
import javax.annotation.Nullable;
2930
import javax.annotation.Nonnull;
@@ -118,11 +119,10 @@ protected java.util.concurrent.CompletableFuture<T2> sendAsync() throws ClientEx
118119
*/
119120
@Nullable
120121
public T3 buildFromResponse(@Nonnull final T2 response) {
121-
final List<com.microsoft.graph.options.Option> options = new java.util.ArrayList<com.microsoft.graph.options.Option>();
122122
try {
123123
final Object builder = response.nextLink() == null ? null : this.collRequestBuilderClass
124124
.getConstructor(String.class, IBaseClient.class, java.util.List.class)
125-
.newInstance(response.nextLink(), getBaseRequest().getClient(), options);
125+
.newInstance(response.nextLink(), getBaseRequest().getClient(), Collections.emptyList());
126126
final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), this.collRequestBuilderClass).newInstance(response, builder);
127127
return page;
128128
} catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {

src/main/java/com/microsoft/graph/serializer/CollectionResponseSerializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public static <T1> BaseCollectionResponse<T1> deserialize(@Nonnull final JsonEle
9595
}
9696
final BaseCollectionResponse<T1> response = (BaseCollectionResponse<T1>)responseClass.getConstructor().newInstance();
9797
response.value = list;
98+
final JsonElement potentialNextLink = jsonAsObject.get("@odata.nextLink");
99+
if(potentialNextLink != null)
100+
response.nextLink = potentialNextLink.getAsString();
98101
response.setRawObject(serializer, jsonAsObject);
99102
return response;
100103
} catch(NoSuchMethodException | InstantiationException | InvocationTargetException ex) {

0 commit comments

Comments
 (0)