Provide support for adding to the mime types that are compressed by jdsalasca · Pull Request #48930 · spring-projects/spring-boot
Summary
- add
server.compression.additional-mime-typesso users can append types without replacing defaults - merge base and additional MIME types in
Compression#getMimeTypes - add binding test coverage for the new property
Motivation
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"
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've left some comments for your consideration.
| */ | ||
| public String[] getMimeTypes() { | ||
| return this.mimeTypes; | ||
| if (this.additionalMimeTypes.length == 0) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the symmetric with setMimeTypes and move the the combined logic to a new method. Perhaps getAllMimeTypes()
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use StringUtils.concatenateStringArrays(String[], String[]) (from org.springframework.util) to do this.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call — now using StringUtils.concatenateStringArrays(...) with a null guard to satisfy NullAway
wilkinsona
changed the title
Add additional compression mime types property
Provide support for adding to the mime types that are compressed
wilkinsona pushed a commit that referenced this pull request
Jan 23, 2026Signed-off-by: jdsalasca <jdsalasc@unal.edu.co> See gh-48930
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters