make sure HTTP servers are able to skip the right amount

This should fix the PMD error:
"Check the value returned by the skip() method of an InputStream to see if
the requested number of bytes has been skipped."
This commit is contained in:
Hans-Christoph Steiner 2016-05-11 16:39:40 +02:00
parent a0c20a35c3
commit 103b2265ee
2 changed files with 8 additions and 2 deletions

View File

@ -265,7 +265,10 @@ public class LocalHTTPD extends NanoHTTPD {
return (int) dataLen;
}
};
fis.skip(startFrom);
long skipped = fis.skip(startFrom);
if (skipped != startFrom) {
throw new IOException("unable to skip the required " + startFrom + " bytes.");
}
res = createResponse(Response.Status.PARTIAL_CONTENT, mime, fis);
res.addHeader("Content-Length", String.valueOf(dataLen));

View File

@ -303,7 +303,10 @@ public class BluetoothServer extends Thread {
return (int) dataLen;
}
};
fis.skip(startFrom);
long skipped = fis.skip(startFrom);
if (skipped != startFrom) {
throw new IOException("unable to skip the required " + startFrom + " bytes.");
}
res = createResponse(NanoHTTPD.Response.Status.PARTIAL_CONTENT, mime, fis);
res.addHeader("Content-Length", String.valueOf(dataLen));