Skip to content

Create strong entity tags by default: new Tag() and new Tag(String) (#1694) - #1761

Merged
thboileau-git merged 1 commit into
3.0from
fix/1694-tag-strong-by-default
Nov 29, 2026
Merged

thboileau-git merged 1 commit into
3.0from
fix/1694-tag-strong-by-default

Conversation

@thboileau-git

@thboileau-git thboileau-git commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1694

Breaking change in 3.0. new Tag() and new Tag(String) created a weak entity tag, whereas RFC 9110 section 8.8.3 says a tag is strong unless it carries the W/ prefix. A server doing representation.setTag(new Tag("v1")) sent ETag: W/"v1", and If-Match / If-Range use the strong comparison (section 13.1), so such a tag never matches: clients got a 412 for ever, or the lost-update protection was silently lost, with nothing telling the developer why.

  • Tag() and Tag(String) now create a strong tag. A weak tag is created with new Tag(value, true) or the new Tag.weak(String); Tag.strong(String) is the explicit counterpart (additive).
  • Tag.parse is unchanged (it was already right).
  • The Conditions Javadoc no longer warns about a weak default. changes.md: Milestone 3, breaking changes.
  • Effect for existing servers: the ETag header loses its W/ prefix, If-Match starts to work, and caches may treat the validator as strong (byte-for-byte). A representation that varies between equivalent encodings should say Tag.weak(...) explicitly.
  • Tests: TagTestCase (defaults, explicit weakness, factories, parse/format round trip), ConditionsTestCase (If-Match with the default tag) and the wire-level StrongTagWireTestCase (ETag header, conditional PUT). Red before the change. The 25 existing usages of new Tag(String) in the tests needed no change.

Same change on the other maintained versions (Javadoc only, behaviour unchanged there): PR #1762 (2.7) and #1763 (2.6)

🤖 Generated with Claude Code

…1694)

RFC 9110 section 8.8.3: an entity tag is strong unless it carries the "W/"
prefix. The constructors created a weak tag, so a server doing
setTag(new Tag("v1")) sent ETag: W/"v1", which can never match an If-Match or
If-Range condition (strong comparison): clients got a 412 for ever, or the
lost-update protection was silently lost.

Breaking in 3.0: the constructors create a strong tag. A weak tag is created
with new Tag(value, true). Adds the factories Tag.strong(String) and
Tag.weak(String) to state the intent. The Javadoc of Conditions no longer warns
about a weak default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@thboileau-git
thboileau-git merged commit c10ebf6 into 3.0 Nov 29, 2026
3 checks passed
@thboileau-git
thboileau-git deleted the fix/1694-tag-strong-by-default branch November 29, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants