Repository navigation
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. GitHubLoginFunctionTest checks that client interceptors run, that a cached response is revalidated with its ETag, and that a rate limit response still fails the request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Also checked with OkHttp 5. This repository's bom resolves okhttp-api 4.12.0-195 (OkHttp 4.12.0), but okhttp-api 5.x is released, and controllers that update it run OkHttp 5. For a local run I pinned okhttp-api 5.3.2-200.vedb_720a_cf1f8 and the jars from its hpi (OkHttp 5.3.2, okio 3.16.4, Kotlin 2.2.21) in
These are the same results as with OkHttp 4.12.0 in the description. |
JenkinsRule turns URLConnection caches off on Windows. ObsoleteUrlFactory followed that and dropped the OkHttp cache, so on Windows the tests that use GitHubMockExtension.serverConfig() never opened it. OkHttpGitHubConnector uses the cache, and its open journal keeps JenkinsRule from deleting JENKINS_HOME, as in GitHubClientCacheCleanupTest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The Windows build failed in the 3 tests that use Cause On Windows, Fix
Checked on macOS with a temporary probe that lists cache journals in
Production behavior is unchanged: Jenkins core doesn't turn the default URL caches off (checked in jenkins-core 2.504.3, 2.541.1 and 2.555.3), so outside tests the old connector used the cache as well. |
Fixes #799.
GitHubLoginFunctionnow 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. GitHub Branch Source gets the same change in jenkinsci/github-branch-source-plugin#1576.The new package-private constructor
GitHubLoginFunction(OkHttpClient)lets the test pass a client with interceptors. The public constructor still usesBASECLIENT.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 cacheRateLimitHandler.FAILstill fails the requestChanges:
User-Agentheader changes fromObsoleteUrlFactoryto OkHttp's default (okhttp/4.12.0), because github-api doesn't set one.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
GitHubLoginFunctionTestis new. For the "before" column, only the connector type was put back toOkHttpConnector:OkHttpConnector(before)OkHttpGitHubConnector(after)requestsGoThroughTheClientInterceptorscachedResponseIsRevalidatedWithETagrateLimitExceededFailsThe last two show that the disk cache and the rate limit handling behave as before. The cache test is skipped on Windows, like
GitHubClientCacheCleanupTest, because the open disk cache keepsJENKINS_HOMEfrom being deleted there.mvn verify, checkstyle included:master: 317 tests, 0 failures, 1 skipped.End to end with the OpenTelemetry Java agent 2.33.1 (OkHttp instrumentation only, logging exporter). A
JenkinsRuletest rannew GitHubLoginFunction().apply(config)againsthttps://api.git.xywcc.comand calledgetRepository. It had no stored credentials, so the plugin sent its placeholder token and GitHub answered 401:Manual test: start Jenkins with the agent flags from #799 and click Test connection on a GitHub server in Manage Jenkins > System. The agent's metric output then shows
http.client.request.durationfor the server's host.Submitter checklist
This change is