Skip to content

Evaluate the preconditions of a conditional write to a resource that cannot be read (#1753) - #1759

Merged
thboileau-git merged 1 commit into
2.6from
fix/1753-write-only-conditional-put-2.6
Nov 29, 2026
Merged

thboileau-git merged 1 commit into
2.6from
fix/1753-write-only-conditional-put-2.6

Conversation

@thboileau-git

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

Copy link
Copy Markdown
Collaborator

Fixes #1753

A resource that supports PUT but not GET (an annotated @Put only) answered 405 to a conditional PUT. The validators are retrieved through the GET handling, whose 405 was kept, so the PUT that the resource supports was never attempted. Without the conditional header the same PUT worked.

  • When retrieving the validators gives nothing, the status is 405, the method is not GET or HEAD, and the resource declares that it does not support GET (updateAllowedMethods(), the annotated methods by default), the 405 of the missing GET is discarded (with its Allow header) and the preconditions are evaluated as for a resource with no known representation: If-Match fails with 412, If-None-Match passes (so "create only" is not enforced on a resource that cannot be read, said in the Javadoc).
  • A resource that declares nothing (for example one that overrides put() without annotating it) is not changed: the framework does not guess at overridden methods. It can declare them with updateAllowedMethods().
  • An error set by the resource's own get() / getInfo() is still kept (Precondition Checks should honor set status #129), and a resource that overrides getInfo() to provide its validators gets real conditional writes (Javadoc of doConditionalHandle).
  • No new API. Fix on by default in the three trees (the old answer was a refusal in every case).
  • Tests: ServerResourceWriteOnlyTestCase (unit, with guards) and three cases in the wire-level MethodNotAllowedWireTestCase. Red before the fix on each tree.

Same fix on the other maintained versions: PR #1757 (3.0) and #1758 (2.7)

🤖 Generated with Claude Code

…cannot be read (#1753)

A resource that supports PUT but not GET (an annotated @put only) answered 405
to a conditional PUT: the validators are retrieved through the GET handling,
whose 405 was kept, so the PUT supported by the resource was never attempted.

When the resource declares that it does not support GET (the annotated methods,
or ServerResource.updateAllowedMethods()), the 405 of the missing GET is now
discarded and the preconditions are evaluated as for a resource with no known
representation: If-Match fails with 412, If-None-Match passes. A resource that
declares nothing, and an error set by the resource itself, are not changed. The
resource can override getInfo() to provide its validators.

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

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@thboileau-git
thboileau-git merged commit b86843d into 2.6 Nov 29, 2026
2 of 3 checks passed
@thboileau-git
thboileau-git deleted the fix/1753-write-only-conditional-put-2.6 branch November 29, 2026 16:41
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