ZipInputStream Stream Closed error on nextEtnry/closeEntry

I'm trying to upload 1 zip file and extracting it in a AWS S3 bucket. I get Stream Closed error: Stream closed
at java.base/ Source)
at java.base/ Source)

This is my code snippet:

    try {
                ZipInputStream zis = new ZipInputStream(
                        S3ObjectUtils.getS3Object(S3_INBOUND, FILE_PATH + metadata.getObjectKey(), this.amazonS3Client)
                ZipEntry entry;
                while ((entry = zis.getNextEntry()) != null) { //Stream closed Error here when I comment closeEntry()
                    String fileName = entry.getName();
                    String srcKey = metadata.getObjectKey().replace('+', ' ');
                    srcKey = URLDecoder.decode(FILE_PATH + fileMetadata.getObjectKey(), "UTF-8");
                    // Covert to plain text
                    String mimeType = "text/plain";
                    ObjectMetadata meta = new ObjectMetadata();
                    this.amazonS3Client.putObject(S3_IN, FilenameUtils.getFullPath(srcKey) + fileName, zis, meta);
                    zis.closeEntry(); // Stream Closed error here
} catch (IOException e) {

1 answer

  • answered 2020-10-29 23:58 Harry

    Fixed by removing zis.closeEntry and changed while to if