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());
setHeader(conn, "Content-Length", contentLength, true);
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.
conn.connect();

View File

@ -61,17 +61,15 @@ public final class RestRequestSender {
R requestBody = request.getBody();
String requestBodyContents = "";
// Android Java VM ignore Content-Length if setDoOutput is not set
conn.setDoOutput(true);
conn.setDoOutput(true);
if (requestBody != null) {
requestBodyContents = gson.toJson(requestBody);
}
String contentLength = String.valueOf(requestBodyContents.length());
setHeader(conn, "Content-Length", contentLength, true);
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.
conn.connect();
} catch (IOException e) {

View File

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

View File

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