Use Case: One of the API in Spring boot microservice should return an image(.png file) with contents populated from PDF. Target is to deploy Spring boot microservice in Kubernetes container and test.
Issue: The size of ByteArrayOutputStream in local vs deployed in Kubernetes container is different
Sample Code:
BufferedImage completeImage = <Contains entire image> Its working fine.
ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
if (!ImageIO.write(completeImage, "png", baos)) {
throw new Exception("Failed to write image");
}
LOGGER.info("baos size: " + baos.size());
In Local baos size: 378281 (Working as expected and the image is rendered correctly)
In Kubernetes container where micro-service is deployed: baos size: 10034
Due to this when testing in server it's not rendering correct image. No exceptions or errors are seen in the server.
I tried with no initial size, like this ByteArrayOutputStream baos = new ByteArrayOutputStream();
but still see same behavior.
Does anyone know why baos size is different in server vs local? Any specific changes to be done when deploying in Kubernetes container? Thanks in advance.