Fixed Coverity Issues Reported

This commit is contained in:
Santhosh Edukulla 2014-07-31 16:36:05 +05:30
parent bd3d8286d3
commit 6133bda642
2 changed files with 10 additions and 11 deletions

View File

@ -77,7 +77,7 @@ public class MockSink extends BaseElement {
Object actualValue = buf.getMetadata(key); Object actualValue = buf.getMetadata(key);
if (actualValue == null) if (actualValue == null)
throw new AssertionError("[" + this + "] Incoming buffer #" + packetNumber + " is not equal to expected buffer in metadata for key \"" + key throw new AssertionError("[" + this + "] Incoming buffer #" + packetNumber + " is not equal to expected buffer in metadata for key \"" + key
+ "\".\n Actual metadata value: " + actualValue + ",\n expected value: \"" + expectedValue + "\"."); + "\".\n Actual metadata value: " + ",\n expected value: \"" + expectedValue + "\".");
if (!expectedValue.equals(actualValue)) if (!expectedValue.equals(actualValue))
throw new AssertionError("[" + this + "] Incoming buffer #" + packetNumber + " is not equal to expected buffer in metadata for key \"" + key throw new AssertionError("[" + this + "] Incoming buffer #" + packetNumber + " is not equal to expected buffer in metadata for key \"" + key

View File

@ -144,18 +144,17 @@ public class ConsoleProxyResourceHandler implements HttpHandler {
} }
private static void responseFileContent(HttpExchange t, File f) throws Exception { private static void responseFileContent(HttpExchange t, File f) throws Exception {
OutputStream os = t.getResponseBody(); try(OutputStream os = t.getResponseBody();
FileInputStream fis = new FileInputStream(f); FileInputStream fis = new FileInputStream(f);) {
while (true) { while (true) {
byte[] b = new byte[8192]; byte[] b = new byte[8192];
int n = fis.read(b); int n = fis.read(b);
if (n < 0) { if (n < 0) {
break; break;
}
os.write(b, 0, n);
} }
os.write(b, 0, n);
} }
fis.close();
os.close();
} }
private static boolean validatePath(String path) { private static boolean validatePath(String path) {