diff --git a/appserver/extras/payara-micro/payara-micro-boot/src/main/java/fish/payara/micro/boot/loader/data/RandomAccessDataFile.java b/appserver/extras/payara-micro/payara-micro-boot/src/main/java/fish/payara/micro/boot/loader/data/RandomAccessDataFile.java index 570007fa05b..2e13b9463ed 100644 --- a/appserver/extras/payara-micro/payara-micro-boot/src/main/java/fish/payara/micro/boot/loader/data/RandomAccessDataFile.java +++ b/appserver/extras/payara-micro/payara-micro-boot/src/main/java/fish/payara/micro/boot/loader/data/RandomAccessDataFile.java @@ -154,6 +154,22 @@ public int read(byte[] b, int off, int len) throws IOException { return doRead(b, off, len); } + @Override + public int available() throws IOException { + RandomAccessFile file = this.file; + if (file == null) { + file = RandomAccessDataFile.this.filePool.acquire(); + file.seek(RandomAccessDataFile.this.offset + this.position); + } + try { + return (int) (file.length() - this.position); + } finally { + if (this.file == null) { + RandomAccessDataFile.this.filePool.release(file); + } + } + } + /** * Perform the actual read. * @param b the bytes to read or {@code null} when reading a single byte