### Question:
FSDataInputStreamTail { public static FSDataInputStreamTail readTail(String path, long paddedFileSize, FSDataInputStream inputStream, int length) throws IOException { checkArgument(length >= 0, "length is negative: %s", length); checkArgument(length <= MAXIMUM_READ_LENGTH, "length (%s) exceeds maximum (%s)", length, MAXIMUM_READ_LENGTH); long readSize = min(paddedFileSize, (length + MAX_SUPPORTED_PADDING_BYTES)); long position = paddedFileSize - readSize; byte[] buffer = new byte[toIntExact(readSize + 1)]; int bytesRead = 0; long startPos = inputStream.getPos(); try { inputStream.seek(position); while (bytesRead < buffer.length) { int n = inputStream.read(buffer, bytesRead, buffer.length - bytesRead); if (n < 0) { break; } bytesRead += n; } } finally { inputStream.seek(startPos); } if (bytesRead > readSize) { throw rejectInvalidFileSize(path, paddedFileSize); } return new FSDataInputStreamTail(position + bytesRead, Slices.wrappedBuffer(buffer, max(0, bytesRead - length), min(bytesRead, length))); } private  FSDataInputStreamTail(long fileSize, Slice tailSlice); static FSDataInputStreamTail readTail(String path, long paddedFileSize, FSDataInputStream inputStream, int length); static long readTailForFileSize(String path, long paddedFileSize, FSDataInputStream inputStream); long getFileSize(); Slice getTailSlice(); static final int MAX_SUPPORTED_PADDING_BYTES; }### Answer:
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = "Incorrect file size \\(.*\\) for file \\(end of stream not reached\\): file:.*") public void testReadTailNoEndOfFileFound() throws Exception { byte[] contents = countingTestFileContentsWithLength(256); try (FSDataOutputStream os = fs.append(tempFile)) { os.write(contents); } assertEquals(fs.getFileLinkStatus(tempFile).getLen(), contents.length); try (FSDataInputStream is = fs.open(tempFile)) { FSDataInputStreamTail.readTail(tempFile.toString(), 128, is, 16); fail("Expected failure to find end of stream"); } catch (PrestoException e) { assertEquals(e.getErrorCode(), HIVE_FILESYSTEM_ERROR.toErrorCode()); throw e; } }