BAEL-3188 How to compress requests using the Spring RestTemplate. Updated GzipUtils code following editor review. (#7746)
This commit is contained in:
parent
f53e9e55eb
commit
4cf99eb77c
@ -30,15 +30,11 @@ public class GzipUtils {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] compress(byte[] body) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
try {
|
||||
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(output)) {
|
||||
gzipOutputStream.write(body);
|
||||
}
|
||||
} finally {
|
||||
output.close();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(baos)) {
|
||||
gzipOutputStream.write(body);
|
||||
}
|
||||
return output.toByteArray();
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user