Skip to content

Commit 76488cc

Browse files
committed
+ Reverting and Adding changes for NPE
1 parent 64eecab commit 76488cc

File tree

5 files changed

+12
-32
lines changed

5 files changed

+12
-32
lines changed

generator/cybersource-java-template/libraries/okhttp-gson/ApiClient.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ public class ApiClient {
12171217
}
12181218
catch (NullPointerException e) {
12191219
logger.error("ApiException : " + e.getMessage());
1220-
return null;
1220+
throw new ApiException(e);
12211221
}
12221222
}
12231223

generator/cybersource-java-template/libraries/okhttp-gson/api.mustache

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,7 @@ public class {{classname}} {
183183
this.apiClient.setComputationStartTime(System.nanoTime());
184184
{{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
185185
logger.info("CALL TO METHOD '{{operationId}}' ENDED");
186-
if(resp != null)
187-
{
188-
return {{localVariablePrefix}}resp.getData();{{/returnType}}
189-
}
190-
else
191-
{
192-
logger.error("CALL TO METHOD '{{operationId}}' FAILED DUE TO AN EXCEPTION");
193-
return null;
194-
}
186+
return {{localVariablePrefix}}resp.getData();{{/returnType}}
195187
}
196188

197189
/**

src/main/java/Api/OAuthApi.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,7 @@ private okhttp3.Call postAccessTokenFromAuthCodeValidateBeforeCall(CreateAccessT
115115
public AccessTokenResponse postAccessTokenFromAuthCode(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException {
116116
this.apiClient.setComputationStartTime(System.nanoTime());
117117
ApiResponse<AccessTokenResponse> resp = postAccessTokenFromAuthCodeWithHttpInfo(createAccessTokenRequest);
118-
if(resp != null)
119-
{
120-
return resp.getData();
121-
}
122-
else
123-
{
124-
logger.error("CALL TO METHOD 'postAccessTokenFromAuthCode' FAILED DUE TO AN EXCEPTION");
125-
return null;
126-
}
118+
return resp.getData();
127119
}
128120

129121

@@ -247,15 +239,7 @@ private okhttp3.Call postAccessTokenFromRefreshTokenValidateBeforeCall(CreateAcc
247239
public AccessTokenResponse postAccessTokenFromRefreshToken(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException {
248240
this.apiClient.setComputationStartTime(System.nanoTime());
249241
ApiResponse<AccessTokenResponse> resp = postAccessTokenFromRefreshTokenWithHttpInfo(createAccessTokenRequest);
250-
if(resp != null)
251-
{
252-
return resp.getData();
253-
}
254-
else
255-
{
256-
logger.error("CALL TO METHOD 'postAccessTokenFromRefreshToken' FAILED DUE TO AN EXCEPTION");
257-
return null;
258-
}
242+
return resp.getData();
259243
}
260244

261245

src/main/java/Invokers/ApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiExceptio
12171217
}
12181218
catch (NullPointerException e) {
12191219
logger.error("ApiException : " + e.getMessage());
1220-
return null;
1220+
throw new ApiException(e);
12211221
}
12221222
}
12231223

src/main/java/utilities/interceptors/RetryInterceptor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ public Response intercept(Chain chain) throws IOException {
3737
return response;
3838
}
3939

40-
private Response doRequest(Chain chain, Request request){
40+
private Response doRequest(Chain chain, Request request) throws IOException {
4141
Response response = null;
4242
try{
4343
response = chain.proceed(request);
44-
}catch (Exception e){
45-
44+
}
45+
catch (NullPointerException e){
46+
throw e;
47+
}
48+
catch (Exception e){
49+
throw e;
4650
}
4751

4852
return response;

0 commit comments

Comments
 (0)