Provide support for adding to the mime types that are compressed by jdsalasca · Pull Request #48930 · spring-projects/spring-boot

@jdsalasca

Summary

  • add server.compression.additional-mime-types so 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"

@jdsalasca

Signed-off-by: jdsalasca <jdsalasc@unal.edu.co>

philwebb

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

Signed-off-by: jdsalasca <jdsalasc@unal.edu.co>
Signed-off-by: jdsalasca <jdsalasc@unal.edu.co>

@jdsalasca

Hi! Thanks for the comments. I’ve updated the code to reflect your suggestions. Thanks again

@wilkinsona wilkinsona changed the title Add additional compression mime types property Provide support for adding to the mime types that are compressed

Jan 23, 2026

wilkinsona pushed a commit that referenced this pull request

Jan 23, 2026
Signed-off-by: jdsalasca <jdsalasc@unal.edu.co>

See gh-48930

wilkinsona added a commit that referenced this pull request

Jan 23, 2026

@wilkinsona