Merge pull request #649 from iceoss/rest-client-patch

Null access fix for BaseClient exception handlers.
This commit is contained in:
James Agnew 2017-06-07 21:15:22 -04:00 committed by GitHub
commit 7d5fbe7482
1 changed files with 14 additions and 3 deletions

View File

@ -323,13 +323,24 @@ public abstract class BaseClient implements IRestfulClient {
} }
} catch (DataFormatException e) { } catch (DataFormatException e) {
//FIXME potential null access on httpResquest String msg;
String msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString()); 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); throw new FhirClientConnectionException(msg, e);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw new FhirClientConnectionException(e); throw new FhirClientConnectionException(e);
} catch (IOException 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); throw new FhirClientConnectionException(msg, e);
} catch (RuntimeException e) { } catch (RuntimeException e) {
throw e; throw e;