Repository navigation
Use OkHttpGitHubConnector so OkHttp interceptors see GitHub API calls - #1576
Merged
Merged
Conversation
The deprecated OkHttpConnector sends each request through github-api's ObsoleteUrlFactory, which clears the client's interceptors and network interceptors on every call. OkHttp instrumentation, such as the OpenTelemetry Java agent, never sees the plugin's GitHub API requests. github-api deprecated OkHttpConnector in favor of OkHttpGitHubConnector (hub4j/github-api#1262) and removes it in 2.0. ConnectorTest checks that client interceptors run, that a cached response is revalidated with its ETag, and that the rate limit handler still reads the X-RateLimit headers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
6 tasks done
JenkinsRule turns URLConnection caches off on Windows. ObsoleteUrlFactory followed that and dropped the OkHttp cache, so on Windows statWhenRoot404andThenIncorrectCached never used it. OkHttpGitHubConnector uses the cache, and its open journal keeps JenkinsRule from deleting JENKINS_HOME. Enable the cache only off Windows, where the default cache size is not 0, expect no Cache-Control header when there is no cache, and restore the cache size after each test so that it no longer leaks into later tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jtnord
approved these changes
Nov 19, 2026
Contributor
Author
|
@jtnord thanks for reviewing the PR. Would you also be able to review jenkinsci/github-plugin#800 as well? |
Member
Whilst the PR looks OK, I am not a maintainer of the github-plugin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1575.
Connectornow gives github-api anOkHttpGitHubConnectorinstead of the deprecatedOkHttpConnector. The old connector sends each request throughObsoleteUrlFactory, which clears the OkHttp client's interceptors and network interceptors on every call, so OkHttp instrumentation (the OpenTelemetry Java agent, for example) never saw the plugin's GitHub API calls. github-api recommends this switch (hub4j/github-api#1262) and removesOkHttpConnectorin 2.0.The new package-private
createGitHubBuilder(apiUrl, cache, client)lets the test pass a client with interceptors. Production code still passesbaseClient.Same as before (github-api 1.330, both connectors):
cacheMaxAge0, TLS connection specs,Cache-Control: max-age=0when there is a cache, ETag revalidation from the disk cacheCUSTOMIZEDstill reads theX-RateLimit-*headers. github-api now hands it aGitHubConnectorResponseHttpUrlConnectionAdapterinstead of theObsoleteUrlFactoryconnection.Changes:
User-Agentheader changes fromObsoleteUrlFactoryto OkHttp's default (okhttp/4.12.0), because github-api doesn't set one. Related: JENKINS-59318.GitHub.getConnector()throwsUnsupportedOperationExceptionwith this connector, as the github-api 1.300 release notes say. The plugin doesn't call it, and a code search of jenkinsci finds no caller.RuntimeExceptionthrown inside OkHttp is no longer wrapped in anIOException.Testing done
ConnectorTestis new. For the "before" column, only the connector line was put back toOkHttpConnector:OkHttpConnector(before)OkHttpGitHubConnector(after)requestsGoThroughTheClientInterceptorscachedResponseIsRevalidatedWithETagrateLimitExceededReportsTheRateLimitHeadersThe last two show that the disk cache and
CUSTOMIZEDbehave as before. No existing test coveredCUSTOMIZED.mvn verify:master: 576 tests, 0 failures, 15 skipped.Cache, so Windows can delete the temporary directory.End to end with the OpenTelemetry Java agent 2.33.1 (OkHttp instrumentation only, logging exporter). A
JenkinsRuletest ranConnector.connect("https://api.github.com", null)and twogetRepositorycalls, unauthenticated:Manual test: start Jenkins with the agent flags from #1575 and run its script console snippet. The agent's metric output then shows
http.client.request.durationforapi.github.com.Submitter checklist
Reviewer checklist
Documentation changes
Users/aliases to notify