removed redundant null checks.

Fixed bug in Streams.copy where it was not honoring the closeInput and closeOutput parameters. 
Suppressed spurious unused warnings
This commit is contained in:
Inderjeet Singh 2010-09-28 15:04:02 +00:00
parent 2b1f3eec15
commit 1a4bea7334
4 changed files with 10 additions and 12 deletions

View File

@ -69,9 +69,7 @@ public final class RequestSender {
String contentLength = String.valueOf(requestBodyContents.length()); String contentLength = String.valueOf(requestBodyContents.length());
setHeader(conn, "Content-Length", contentLength, true); setHeader(conn, "Content-Length", contentLength, true);
addRequestParams(conn, request.getHeaders()); addRequestParams(conn, request.getHeaders());
if (requestBodyContents != null) { Streams.copy(requestBodyContents, conn.getOutputStream(), false);
Streams.copy(requestBodyContents, conn.getOutputStream(), false);
}
// Initiate the sending of the request. // Initiate the sending of the request.
conn.connect(); conn.connect();

View File

@ -61,17 +61,15 @@ public final class RestRequestSender {
R requestBody = request.getBody(); R requestBody = request.getBody();
String requestBodyContents = ""; String requestBodyContents = "";
// Android Java VM ignore Content-Length if setDoOutput is not set // Android Java VM ignore Content-Length if setDoOutput is not set
conn.setDoOutput(true); conn.setDoOutput(true);
if (requestBody != null) { if (requestBody != null) {
requestBodyContents = gson.toJson(requestBody); requestBodyContents = gson.toJson(requestBody);
} }
String contentLength = String.valueOf(requestBodyContents.length()); String contentLength = String.valueOf(requestBodyContents.length());
setHeader(conn, "Content-Length", contentLength, true); setHeader(conn, "Content-Length", contentLength, true);
addRequestParams(conn, request.getHeaders()); addRequestParams(conn, request.getHeaders());
if (requestBodyContents != null) { Streams.copy(requestBodyContents, conn.getOutputStream(), false);
Streams.copy(requestBodyContents, conn.getOutputStream(), false);
}
// Initiate the sending of the request. // Initiate the sending of the request.
conn.connect(); conn.connect();
} catch (IOException e) { } catch (IOException e) {

View File

@ -37,8 +37,8 @@ final class Streams {
dst.write(buf, 0, count); dst.write(buf, 0, count);
} }
} finally { } finally {
src.close(); if (closeInput) src.close();
dst.close(); if (closeOutput) dst.close();
} }
} }
} }

View File

@ -21,7 +21,9 @@ import com.google.gson.webservice.definition.WebServiceResponse.Builder;
public class WebServiceCallServerBuilder { public class WebServiceCallServerBuilder {
public WebServiceCallServerBuilder(WebServiceCallSpec callSpec, public WebServiceCallServerBuilder(
WebServiceRequest wsRequest, Builder responseBuilder) { @SuppressWarnings("unused") WebServiceCallSpec callSpec,
@SuppressWarnings("unused") WebServiceRequest wsRequest,
@SuppressWarnings("unused") Builder responseBuilder) {
} }
} }