Relative Content

Tag Archive for javaspring-bootasynchronousfile-iocompletable-future

CompletableFuture Byte Array Handling Issue in Java Spring Application

I’m working on a Java code where I need to asynchronously fetch a byte array representing a zip file from a service and then write this into a file. While I have structured my code using CompletableFuture to handle these operations, I’m encountering an issue where the byte array, although correctly fetched and logged with the expected length, seems to be incomplete when written to the file. That inturn is creating a corrupted/incomplete zip file on the disk.
What I have observed is, the issue only arises when the operations are performed asynchronously; synchronous execution works fine.