Skip to content

[Breaking change]: DeflateStream and GZipStream encode empty payload into nonempty encoded payload. #49393

@rzikm

Description

@rzikm

Description

Deflate and GZip compression formats include delimiters for start and end of compressed data. The right way to compress empty payload with these formats includes only those delimiters.

Version

.NET 11 Preview 1

Previous behavior

DeflateStream and GZipStream would not produce any output if no data was written.

New behavior

DeflateStream and GZipStream always write headers and footers to the output.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Some tools do not correctly react to empty content and always expect the compressed content to contain at least the appropriate header and footer.

Recommended action

If previous behavior is desired, we recommend special casing empty content to not try to compress it via DeflateStream or GZipStream

Feature area

Core .NET libraries

Affected APIs

DeflateStream
GZipStream


Associated WorkItem - 543462

Metadata

Metadata

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions