Permalink
Browse files

Merge pull request #601 from jcookems/dev

Dev
  • Loading branch information...
2 parents 76e9a7a + c6ad717 commit 55cb8e3246983a4926898c72d665fffcf7f19e96 @jcookems jcookems committed Jan 9, 2013
View
19 ...pi/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java
@@ -30,15 +30,20 @@
public static StatusLine create(DataSource dataSource) {
try {
LineInputStream stream = new LineInputStream(dataSource.getInputStream());
- String line = stream.readLine();
- StringReader lineReader = new StringReader(line);
+ try {
+ String line = stream.readLine();
+ StringReader lineReader = new StringReader(line);
- expect(lineReader, "HTTP/1.1");
- expect(lineReader, " ");
- String statusString = extractInput(lineReader, ' ');
- String reason = extractInput(lineReader, -1);
+ expect(lineReader, "HTTP/1.1");
+ expect(lineReader, " ");
+ String statusString = extractInput(lineReader, ' ');
+ String reason = extractInput(lineReader, -1);
- return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason);
+ return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason);
+ }
+ finally {
+ stream.close();
+ }
}
catch (IOException e) {
throw new RuntimeException(e);
View
19 .../main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java
@@ -40,15 +40,20 @@ public HttpReaderWriter() {
public StatusLine parseStatusLine(DataSource ds) {
try {
LineInputStream stream = new LineInputStream(ds.getInputStream());
- String line = stream.readLine();
- StringReader lineReader = new StringReader(line);
+ try {
+ String line = stream.readLine();
+ StringReader lineReader = new StringReader(line);
- expect(lineReader, "HTTP/1.1");
- expect(lineReader, " ");
- String statusString = extractInput(lineReader, ' ');
- String reason = extractInput(lineReader, -1);
+ expect(lineReader, "HTTP/1.1");
+ expect(lineReader, " ");
+ String statusString = extractInput(lineReader, ' ');
+ String reason = extractInput(lineReader, -1);
- return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason);
+ return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason);
+ }
+ finally {
+ stream.close();
+ }
}
catch (IOException e) {
throw new RuntimeException(e);

0 comments on commit 55cb8e3

Please sign in to comment.