Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

The Java11 HTTP transport lacked retry logic for transient server failures (503 Service Unavailable) and rate limiting (429 Too Many Requests), causing builds to fail unnecessarily when encountering temporary service interruptions.

Changes

Modified: Java11HttpTransportFactory.java

  • Retry logic for 503 and 429: Both performGet() and doHead() now retry up to 3 times (configurable) on these status codes
  • Retry-After header parsing: Supports both integer seconds ("10") and HTTP date formats (RFC 1123/1036/ANSI C)
  • Fallback delay: Uses 5 seconds when Retry-After header is absent or unparsable
  • Resource cleanup: Response streams are properly closed before each retry attempt
  • Logging: Emits info-level messages showing status code, delay, and remaining retries
  • Maven Resolver compatibility: Supports aether.connector.http.retryHandler.count and aether.connector.http.retryHandler.interval properties for configuration

Configuration

Users can configure retry behavior using Maven Resolver standard properties:

<properties>
  <!-- Set retry attempts (default: 3) -->
  <aether.connector.http.retryHandler.count>5</aether.connector.http.retryHandler.count>
  
  <!-- Set retry delay in milliseconds (default: 5000) -->
  <aether.connector.http.retryHandler.interval>10000</aether.connector.http.retryHandler.interval>
</properties>

Or via command line:

mvn clean install -Daether.connector.http.retryHandler.count=5

Implementation

private <T> T performGet(ResponseConsumer<T> consumer, HttpClient httpClient) {
    int retriesLeft = maxRetryAttempts;  // Configurable via Maven properties
    while (retriesLeft > 0) {
        retriesLeft--;
        HttpResponse<InputStream> response = httpClient.send(request, ...);
        
        int statusCode = response.statusCode();
        if (shouldRetry(statusCode) && retriesLeft > 0) {
            long delaySeconds = getRetryDelay(response);
            logger.info("Server returned status " + statusCode + " for " + uri 
                    + ", waiting " + delaySeconds + " seconds before retry. " 
                    + retriesLeft + " retries left.");
            // Clean up and retry
            TimeUnit.SECONDS.sleep(delaySeconds);
            continue;
        }
        return consumer.handleResponse(new ResponseImplementation<>(response));
    }
    throw new IOException("Maximum retry attempts exceeded for " + uri);
}

Aligns with Maven Resolver configuration standards and follows the same pattern as existing retry logic in PGPService.

Original prompt

Add retry support to Tycho Jdk11 transport

We have teh JDk11 Http transport in Tycho and it should support

503 Service Unavailable
429 Too Many Requests

with Retry-After header and if that is not given uses 5 second delay and retry up to 5 times.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add retry support to Tycho Jdk11 transport Add retry support for HTTP 503/429 to Java11HttpTransport Nov 11, 2025
Copilot AI requested a review from laeubi November 11, 2025 07:45
@laeubi
Copy link
Member

laeubi commented Nov 11, 2025

@copilot to align best with maven, we should support the following config properties from resolver where applicable in our implementation:

https://maven.apache.org/resolver/configuration.html

We should use https://github.com/eclipse-tycho/tycho/blob/main/tycho-spi/src/main/java/org/eclipse/tycho/helper/MavenPropertyHelper.java for that and also consider that maven is maybe using slightly different defaults see https://github.com/apache/maven/blob/master/impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java

- Use aether.connector.http.retryHandler.count for retry attempts (default: 3)
- Use aether.connector.http.retryHandler.interval for retry delay
- Add MavenPropertyHelper to read configuration from Maven properties
- Change default retry count from 5 to 3 to match Maven Resolver defaults

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot to align best with maven, we should support the following config properties from resolver where applicable in our implementation:

https://maven.apache.org/resolver/configuration.html
...

Updated in commit af8e2a0:

  • Added support for aether.connector.http.retryHandler.count property (default: 3 retries, matching Maven Resolver)
  • Added support for aether.connector.http.retryHandler.interval property (in milliseconds, default: 5000ms)
  • Integrated MavenPropertyHelper to read configuration from Maven session properties
  • Changed default retry count from 5 to 3 to align with Maven Resolver defaults

Users can now configure retry behavior via Maven properties or command line, e.g.:

mvn clean install -Daether.connector.http.retryHandler.count=5 -Daether.connector.http.retryHandler.interval=10000

Copilot AI changed the title Add retry support for HTTP 503/429 to Java11HttpTransport Add retry support for HTTP 503/429 to Java11HttpTransport with Maven Resolver compatibility Nov 11, 2025
@laeubi laeubi marked this pull request as ready for review November 11, 2025 08:47
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