Zip contents corrupted when trying to zip via ZipOutputStream in RxJava

I am trying to create a zip file and upload that zip file in AWS S3 via a multipart upload route. However, I am facing an issue where the file is successfully getting generated however, the contents inside the files are getting corrupted.

Here is the error that I am getting when I am trying to unarchive the file :

Archive:  test2MB.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test2MB.zip or
        test2MB.zip.zip, and cannot find test2MB.zip.ZIP, period.

Here are the code snippets that I have written for this

private Single<List<CompletedPart>> zipAndUploadZipParts(String uploadId) {
        List<Single<CompletedPart>> uploadPartObservables = new ArrayList<>();
        final int[] partNumber = {Constants.START_PART_NUMBER};

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream);
        return zipMetadata(zipOutputStream)
                .andThen(uploadZipPart(byteArrayOutputStream, uploadPartObservables, partNumber, uploadId)
                        .onErrorResumeNext(error -> {
                            this.contextRx.log().error(String.format("placeholder", partNumber[0], this.logIdentifier, error.getMessage()), error);
                            return Completable.error(new RuntimeException("Placeholder"));
                        }))
                .andThen(finalizeZipUpload(uploadPartObservables, zipOutputStream, byteArrayOutputStream));
    }
    private Completable zipMetadata(ZipOutputStream zipOutputStream) {
        return Completable.create(emitter -> {
            try {
                ZipEntry metadataEntry = new ZipEntry(Constants.METADATA_FILE_NAME);
                zipOutputStream.putNextEntry(metadataEntry);
                zipOutputStream.write(this.catalogObjectsMetadata.getBytes());
                zipOutputStream.closeEntry();
                emitter.onComplete();
            } catch (IOException exception) {
                this.contextRx.log().error(String.format(Constants.LOG_ERROR_ZIPPING_METADATA, this.logIdentifier, exception.getMessage()), exception);
                emitter.onError(new RuntimeException(String.format(Constants.ERROR_ZIPPING_METADATA)));
            }
        });
    }
    private Completable uploadZipPart(ByteArrayOutputStream byteArrayOutputStream, List<Single<CompletedPart>> uploadPartObservables, int[] partNumber, String uploadId) {
        return Completable.create(emitter -> {
            try {
                byte[] zipData = byteArrayOutputStream.toByteArray();
                uploadPartObservables.add(uploadPart(zipData, partNumber[0]++, uploadId));
                byteArrayOutputStream.reset();
                this.contextRx.log().info(String.format("Uploaded part %d for uploadId %s", partNumber[0] - 1, uploadId));
                emitter.onComplete();
            } catch (Exception exception) {
                emitter.onError(exception);
            }
        });
    }
private Single<List<CompletedPart>> finalizeZipUpload(List<Single<CompletedPart>> uploadPartObservables, ZipOutputStream zipOutputStream, ByteArrayOutputStream byteArrayOutputStream) {
        return Single.defer(() -> {
            try {
                zipOutputStream.finish();
            } catch (IOException e) {
                return Single.error(new RuntimeException("Error finishing zip output stream", e));
            } finally {
                try {
                    zipOutputStream.close();
                } catch (IOException e) {
                    return Single.error(new RuntimeException("Error closing zip output stream", e));
                }
                try {
                    byteArrayOutputStream.close();
                } catch (IOException e) {
                    return Single.error(new RuntimeException("Error closing byte array output stream", e));
                }
            }
            return Single.merge(uploadPartObservables)
                    .toList()
                    .doOnSuccess(parts -> this.contextRx.log().info(String.format(Constants.ALL_PARTS_UPLOADED, this.logIdentifier, parts)))
                    .onErrorReturnItem(new ArrayList<>());
        });
    }

Can someone guide what is wrong with my code which is corrupting my zip file?

Contents inside the zip file shouldn’t get corrupted.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật