Update BaseClient.java

Fix for null access on httpRequest in DataFormatException and IOException handlers.
This commit is contained in:
maclema 2017-05-16 15:15:54 -06:00 committed by GitHub
parent b2996d3550
commit 06919f9a20
1 changed files with 14 additions and 3 deletions

View File

@ -323,13 +323,24 @@ public abstract class BaseClient implements IRestfulClient {
}
} catch (DataFormatException e) {
//FIXME potential null access on httpResquest
String msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
String msg;
if ( httpRequest != null ) {
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
}
else {
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", "UNKNOWN", "UNKNOWN", e.toString());
}
throw new FhirClientConnectionException(msg, e);
} catch (IllegalStateException e) {
throw new FhirClientConnectionException(e);
} catch (IOException e) {
String msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "ioExceptionDuringOperation", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
String msg;
if ( httpRequest != null ) {
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
}
else {
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", "UNKNOWN", "UNKNOWN", e.toString());
}
throw new FhirClientConnectionException(msg, e);
} catch (RuntimeException e) {
throw e;