From c7b27a8400f0be068751b4c7c2b1d97a03858868 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 10 Feb 2021 12:24:52 -0500 Subject: [PATCH 1/2] - adds exception in reflection methods to facilitate detection of issues --- .../java/com/microsoft/graph/http/BaseCollectionRequest.java | 2 +- .../microsoft/graph/http/BaseCollectionRequestBuilder.java | 5 +++-- .../http/BaseCollectionWithReferencesRequestBuilder.java | 3 ++- .../microsoft/graph/http/BaseReferenceRequestBuilder.java | 3 ++- .../graph/http/BaseWithReferenceRequestBuilder.java | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java b/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java index 5ff5921af..d34dd3222 100644 --- a/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java @@ -126,7 +126,7 @@ public T3 buildFromResponse(@Nonnull final T2 response) { final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), builder.getClass()).newInstance(response, response.nextLink() == null ? null : builder); return page; } catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { - return null; + throw new ClientException("Could not find the required class", ex); } } diff --git a/src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java b/src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java index 2428cefc7..f2c0f1b02 100644 --- a/src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java +++ b/src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java @@ -1,5 +1,6 @@ package com.microsoft.graph.http; +import com.microsoft.graph.core.ClientException; import com.microsoft.graph.core.IBaseClient; import java.lang.reflect.InvocationTargetException; @@ -61,7 +62,7 @@ public T5 buildRequest(@Nullable final java.util.List Date: Wed, 10 Feb 2021 13:26:15 -0500 Subject: [PATCH 2/2] - avoid instantiating a builder when it's not needed --- .../java/com/microsoft/graph/http/BaseCollectionRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java b/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java index d34dd3222..78d0ed44a 100644 --- a/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java @@ -120,10 +120,10 @@ protected java.util.concurrent.CompletableFuture sendAsync() throws ClientEx public T3 buildFromResponse(@Nonnull final T2 response) { final List options = new java.util.ArrayList(); try { - final Object builder = this.collRequestBuilderClass + final Object builder = response.nextLink() == null ? null : this.collRequestBuilderClass .getConstructor(String.class, IBaseClient.class, java.util.List.class) .newInstance(response.nextLink(), getBaseRequest().getClient(), options); - final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), builder.getClass()).newInstance(response, response.nextLink() == null ? null : builder); + final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), this.collRequestBuilderClass).newInstance(response, builder); return page; } catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { throw new ClientException("Could not find the required class", ex);