Skip to content

Commit 2d99421

Browse files
author
Nakul Sabharwal
committed
Moved UnsupportedEncodingException handling and logging to sendRequestInternal of DefaultHttpProvider.
1 parent 49104b8 commit 2d99421

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
347347
final boolean shouldLogVerbosely = logger.getLoggingLevel() == LoggerLevel.DEBUG;
348348
logger.logError("Graph service exception " + ex.getMessage(shouldLogVerbosely), ex);
349349
throw ex;
350+
} catch (final UnsupportedEncodingException ex) {
351+
final ClientException clientException = new ClientException("Unsupported encoding",
352+
ex);
353+
logger.logError("Unsupported encoding exception " + ex.getMessage(), ex);
354+
throw clientException;
350355
} catch (final Exception ex) {
351356
final ClientException clientException = new ClientException("Error during http request",
352357
ex);
@@ -410,15 +415,7 @@ private <Result> Result handleJsonResponse(final InputStream in, Map<String, Lis
410415
private <Result> Result handleEmptyResponse(Map<String, List<String>> responseHeaders, final Class<Result> clazz)
411416
throws UnsupportedEncodingException{
412417
//Create an empty object to attach the response headers to
413-
InputStream in = null;
414-
try{
415-
in = new ByteArrayInputStream("{}".getBytes(ENCODING_TYPE));
416-
}
417-
catch(UnsupportedEncodingException ex) {
418-
logger.logError(ex.getMessage(), ex);
419-
throw ex;
420-
}
421-
418+
InputStream in = new ByteArrayInputStream("{}".getBytes(ENCODING_TYPE));
422419
return handleJsonResponse(in, responseHeaders, clazz);
423420
}
424421

0 commit comments

Comments
 (0)