Hi Dear maintainers of the Apache Ant library. We were using this lib in an older version and found 2 improvements that would be nice to consider also for the next versions of the library since the code did not change in these parts as I've reviewed this week in 1.10.13
1) org.apache.tools.tar.TarEntry The method public TarEntry[] getDirectoryEntries() could be improved to make a null check for final String[] list = this.file.list(); because the result of this statement could be null and in this case the next statement would fail with NPE TarEntry[] result = new TarEntry[list.length]; Possible/proposed solution: public TarEntry[] getDirectoryEntries() { if (this.file == null || !this.file.isDirectory()) { return new TarEntry[0]; } final TarEntry[] result; final String[] list = this.file.list(); if (null != list) { result = new TarEntry[list.length]; for (int i = 0; i < list.length; ++i) { result[i] = new TarEntry(new File(this.file, list[i])); } } else { result = new TarEntry[0]; } return result; } or public TarEntry[] getDirectoryEntries() { if (file == null || !file.isDirectory() || file.list() == null) { return new TarEntry[0]; } String[] list = file.list(); TarEntry[] result = new TarEntry[list.length]; for (int i = 0; i < list.length; ++i) { result[i] = new TarEntry(new File(file, list[i])); } return result; } 2) org.apache.tools.tar.TarBuffer The method writeBlock() has this statement this.outStream.write(this.blockBuffer, 0, this.blockSize); we think, that this statement this.outStream.write(this.blockBuffer, 0, this.currRecIdx * this.recordSize); would be a better solution Reason: with original code, after the EOF-blocks, the remaining data (garbage) from the last block was also put to the outstream Since this is my first mail to this mailing list, I hope it was in correct form, understandable and does not violate any form of etiquette! If not, please tell me for future mails. br Michael --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org For additional commands, e-mail: dev-h...@ant.apache.org