diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java index a31c3c7a7d..807b3861a5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ package org.springframework.boot.web.embedded.netty; import java.util.Arrays; +import java.util.List; import java.util.function.BiPredicate; +import java.util.stream.Collectors; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpHeaders; @@ -63,10 +65,12 @@ final class CompressionCustomizer implements NettyServerCustomizer { return server; } - private CompressionPredicate getMimeTypesPredicate(String[] mimeTypes) { - if (ObjectUtils.isEmpty(mimeTypes)) { + private CompressionPredicate getMimeTypesPredicate(String[] mimeTypeIds) { + if (ObjectUtils.isEmpty(mimeTypeIds)) { return ALWAYS_COMPRESS; } + List mimeTypes = Arrays.stream(mimeTypeIds) + .map(MimeTypeUtils::parseMimeType).collect(Collectors.toList()); return (request, response) -> { String contentType = response.responseHeaders() .get(HttpHeaderNames.CONTENT_TYPE); @@ -74,7 +78,7 @@ final class CompressionCustomizer implements NettyServerCustomizer { return false; } MimeType contentMimeType = MimeTypeUtils.parseMimeType(contentType); - return Arrays.stream(mimeTypes).map(MimeTypeUtils::parseMimeType) + return mimeTypes.stream() .anyMatch((candidate) -> candidate.isCompatibleWith(contentMimeType)); }; }