Provide support for adding to the mime types that are compressed#48930
Provide support for adding to the mime types that are compressed#48930jdsalasca wants to merge 3 commits intospring-projects:mainfrom
Conversation
Signed-off-by: jdsalasca <[email protected]>
c47dd46 to
bd421b5
Compare
philwebb
left a comment
There was a problem hiding this comment.
Thanks! I've left some comments for your consideration.
| */ | ||
| public String[] getMimeTypes() { | ||
| return this.mimeTypes; | ||
| if (this.additionalMimeTypes.length == 0) { |
There was a problem hiding this comment.
I think we should keep the symmetric with setMimeTypes and move the the combined logic to a new method. Perhaps getAllMimeTypes()
There was a problem hiding this comment.
Thanks for the suggestion. I kept getMimeTypes() as the base list and added getAllMimeTypes() to return the combined list. Updated usages to call getAllMimeTypes() so the behavior remains symmetric
| } | ||
| String[] combined = new String[this.mimeTypes.length + this.additionalMimeTypes.length]; | ||
| System.arraycopy(this.mimeTypes, 0, combined, 0, this.mimeTypes.length); | ||
| System.arraycopy(this.additionalMimeTypes, 0, combined, this.mimeTypes.length, this.additionalMimeTypes.length); |
There was a problem hiding this comment.
You can use StringUtils.concatenateStringArrays(String[], String[]) (from org.springframework.util) to do this.
There was a problem hiding this comment.
Good call — now using StringUtils.concatenateStringArrays(...) with a null guard to satisfy NullAway
Signed-off-by: jdsalasca <[email protected]>
Signed-off-by: jdsalasca <[email protected]>
|
Hi! Thanks for the comments. I’ve updated the code to reflect your suggestions. Thanks again |
Signed-off-by: jdsalasca <[email protected]> See gh-48930
|
Thanks very much, @jdsalasca. |
Summary
server.compression.additional-mime-typesso users can append types without replacing defaultsCompression#getMimeTypesMotivation
Fixes #48927. This keeps the default compressible MIME list intact while allowing extra types to be configured.
Testing
./gradlew :module:spring-boot-web-server:test --tests "org.springframework.boot.web.server.autoconfigure.ServerPropertiesTests"