Description
We have a scenario with a "slow" InputStream and are facing IOExceptions with TarArchiveEntry#getNextTarEntry().
If the InputStream does not deliver fast enough, TarArchiveEntry#parsePaxHeaders(InputStream i) fails at this location:
TarArchiveInputStream.java
// Get rest of entry byte[] rest = new byte[len - read]; int got = i.read(rest); if (got != len - read){ throw new IOException("Failed to read " + "Paxheader. Expected " + (len - read) + " bytes, read " + got); }
We would suggest to change the code to something like this:
TarArchiveInputStream.java
// Get rest of entry byte[] rest = new byte[len - read]; int got = 0; while((ch = i.read()) != -1) { rest[got] = (byte) ch; got++; if(got == len - read) { break; } } if (got != len - read){ throw new IOException("Failed to read " + "Paxheader. Expected " + (len - read) + " bytes, read " + got); }
This would make sure, that it gets all bytes of the PAX header value.