Skip to content

Commit 752c656

Browse files
authored
Merge pull request #145 from microsoftgraph/bugfix/collection-response
bugfix/collection response
2 parents 9bfbcbd + 480b521 commit 752c656

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ protected java.util.concurrent.CompletableFuture<T2> sendAsync() throws ClientEx
120120
public T3 buildFromResponse(@Nonnull final T2 response) {
121121
final List<com.microsoft.graph.options.Option> options = new java.util.ArrayList<com.microsoft.graph.options.Option>();
122122
try {
123-
final Object builder = this.collRequestBuilderClass
123+
final Object builder = response.nextLink() == null ? null : this.collRequestBuilderClass
124124
.getConstructor(String.class, IBaseClient.class, java.util.List.class)
125125
.newInstance(response.nextLink(), getBaseRequest().getClient(), options);
126-
final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), builder.getClass()).newInstance(response, response.nextLink() == null ? null : builder);
126+
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) {
129-
return null;
129+
throw new ClientException("Could not find the required class", ex);
130130
}
131131
}
132132

‎src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.microsoft.graph.http;
22

3+
import com.microsoft.graph.core.ClientException;
34
import com.microsoft.graph.core.IBaseClient;
45

56
import java.lang.reflect.InvocationTargetException;
@@ -61,7 +62,7 @@ public T5 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
6162
return collRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
6263
.newInstance(getRequestUrl(), getClient(), requestOptions);
6364
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
64-
return null;
65+
throw new ClientException("Could not find the required class", ex);
6566
}
6667
}
6768

@@ -77,7 +78,7 @@ public T2 byId(@Nonnull final String id) {
7778
return reqBuilderClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7879
.newInstance(getRequestUrlWithAdditionalSegment(id), getClient(), getOptions());
7980
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
80-
return null;
81+
throw new ClientException("Could not find the required class", ex);
8182
}
8283
}
8384
}

‎src/main/java/com/microsoft/graph/http/BaseCollectionWithReferencesRequestBuilder.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -70,7 +71,7 @@ public T8 references() {
7071
.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7172
.newInstance(getRequestUrl() + "/$ref", getClient(), getOptions());
7273
} catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
73-
return null;
74+
throw new ClientException("Could not find the required class", ex);
7475
}
7576
}
7677
}

‎src/main/java/com/microsoft/graph/http/BaseReferenceRequestBuilder.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -72,7 +73,7 @@ public T2 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
7273
return refRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7374
.newInstance(getRequestUrl(), getClient(), requestOptions);
7475
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
75-
return null;
76+
throw new ClientException("Could not find the required class", ex);
7677
}
7778
}
7879
}

‎src/main/java/com/microsoft/graph/http/BaseWithReferenceRequestBuilder.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -78,7 +79,7 @@ public T2 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
7879
return wReferenceRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7980
.newInstance(getRequestUrl(), getClient(), requestOptions);
8081
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
81-
return null;
82+
throw new ClientException("Could not find the required class", ex);
8283
}
8384
}
8485

@@ -93,7 +94,7 @@ public T3 reference(){
9394
return refRequestBuilderClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
9495
.newInstance(getRequestUrl() + "/$ref", getClient(), getOptions());
9596
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
96-
return null;
97+
throw new ClientException("Could not find the required class", ex);
9798
}
9899
}
99100
}

0 commit comments

Comments
 (0)