Permalink
Browse files

restclient: fix NPE in error handling for no content header.

  • Loading branch information...
1 parent 14eafc7 commit 85ee7b22ef62e07b6ea0046303a60522122479fa @kgilmer kgilmer committed Oct 25, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 org.touge.restclient/src/org/touge/restclient/ReSTClient.java
@@ -666,8 +666,12 @@ public T getContent() throws IOException {
if (isError()) {
String serverMessage = connection.getResponseMessage();
byte[] errorMessage = readStream(connection.getErrorStream());
- if (errorMessage != null && errorMessage.length > 0)
- serverMessage = new String(errorMessage, connection.getContentEncoding());
+ if (errorMessage != null && errorMessage.length > 0) {
+ if (connection.getContentEncoding() != null)
+ serverMessage = new String(errorMessage, connection.getContentEncoding());
+ else
+ serverMessage = new String(errorMessage, "UTF-8");
+ }
if (responseBuffer != null) {
debugMid(responseBuffer, serverMessage);

0 comments on commit 85ee7b2

Please sign in to comment.