Files
floci/src/main/java/io
Matheus Oliveira 9a7c62b8f1 fix(cloudfront): carry origin connection settings through CloudFormation (#5992)
* fix(cloudfront): honor origin connection timeouts and attempts, answer 504

CloudFront ignored a custom origin's ConnectionTimeout, OriginReadTimeout and
ConnectionAttempts and answered 502 for any origin failure. Apply the origin's
connect and read timeouts to the origin request, retry a timed-out GET/HEAD up
to ConnectionAttempts, and answer 504 with the AWS message when the last
attempt times out. A refused connection or an unknown host still answers 502.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(cloudfront): retry a connect timeout for every origin method

Review follow-ups on the origin timeout work:

- Connection attempts count for every method, not only GET and HEAD: a
  connect timeout or a refused connection is retried up to the configured
  ConnectionAttempts whatever the method is. Apache HttpClient 5's
  ConnectTimeoutException extends SocketTimeoutException, so it is caught
  first to keep the split: a response timeout is still retried only for an
  idempotent method and still answers 504, while a refused connection
  propagates unchanged as a bad gateway.
- The origin read and connection timeout bounds moved into
  CloudFrontOriginTimeouts, shared by CloudFrontController,
  CloudFrontServingController and CloudFrontOriginHttpClient instead of
  being repeated in each.
- The slow-origin tests hold the origin open on a CountDownLatch with
  millisecond client timeouts rather than sleeping out a fixed delay, so an
  attempt ends by the client's own timeout and the suite finishes in
  seconds.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(cloudfront): carry origin connection settings through CloudFormation

Follow-up to #5802: the serving layer now applies Origin.ConnectionAttempts,
Origin.ConnectionTimeout and CustomOriginConfig.OriginReadTimeout, but
cfnOrigins never copied them, so a template that set them was dropped and
every distribution a stack provisioned ran on the AWS defaults.

- cfnOrigins copies ConnectionAttempts and ConnectionTimeout from the origin
  and OriginReadTimeout from CustomOriginConfig. A non-integer origin setting
  in a template is now a ValidationError instead of the server error an
  uncaught NumberFormatException produced.
- CreateDistribution and UpdateDistribution range-check ConnectionAttempts
  (1-3) and ConnectionTimeout (1-10 seconds) the way OriginReadTimeout and
  OriginKeepaliveTimeout already are. AWS publishes no dedicated error code
  for either, so both fail as InvalidArgument, and a non-numeric value is a
  400 instead of being silently ignored.
- The serving clamp reads MIN_CONNECTION_ATTEMPTS from
  CloudFrontOriginTimeouts instead of a literal.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(cloudfront): enforce origin connection setting ranges in the service

Move the ConnectionAttempts, ConnectionTimeout, OriginReadTimeout and
OriginKeepaliveTimeout range checks out of the XML parser into
CloudFrontService.createDistribution/updateDistribution, next to the
custom-header and OAC checks, so the CloudFormation path shares one
copy. A template with an out-of-range value now fails the stack with
the same InvalidArgument/InvalidOriginReadTimeout/
InvalidOriginKeepaliveTimeout error the API path returns, instead of
falling back to the model defaults. The parser keeps rejecting
non-numeric values; the cross-field ResponseCompletionTimeout check
stays where it was.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

---------

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-21 13:21:15 -04:00
..