Skip to content

Conversation

@strangelookingnerd
Copy link
Contributor

Follow-up for #69 that fixes https://issues.jenkins.io/browse/JENKINS-75556

@MarkEWaite this makes #77 obsolete

Testing done

Manually verified Test connection in System Configuration works as expected.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@MarkEWaite
Copy link
Contributor

Thanks very much!

.proxyBuilder(apiProxyClass)
.build().target(url);

// workaround for https://github.com/orgs/resteasy/discussions/4538 when using ResteasyWebTarget#proxyBuilder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had run into this bug with my testing of the plugin as well. Did you take a look into this solution on the jenkins docs for class loading issues? https://www.jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/#context-class-loaders

I was able to get this builder to work using the code below. Your implementation has the upside of being much simpler to follow, but I wasn't sure if it came with any other considerations to consider.

Thread t = Thread.currentThread();
ClassLoader orig = t.getContextClassLoader();
t.setContextClassLoader(apiProxyClass.getClassLoader());
try {
         GiteeApiProxy apiProxy = ((ResteasyWebTarget) builder
                    // ... builder functions
                    .build().target(url))
                    .proxyBuilder(apiProxyClass)
                    .classloader(t.getContextClassLoader())
                    .build();

          return new ResteasyGiteeClient(url, apiProxy, pullRequestIdProvider);
       } finally {
            t.setContextClassLoader(orig);
       }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Puffy1215 have you tested the implementation in this pull request? I'm more interested in delivering a fix that works than in changing implementation from one form to another

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Puffy1215 Yeah, I tried a similar approach as you describe at first but did not really like fiddeling with the classloader.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I was interested in the thought process. I am perfectly comfortable with your solution as it is easier to understand.

I have tried your fixes and have found no issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried your fixes and have found no issues.

That is great news. I will merge and release this pull request.


private GiteeClient buildClient(String url, String apiToken, ProxyConfiguration httpProxyConfig, boolean ignoreCertificateErrors, int connectionTimeout, int readTimeout) {
ResteasyClientBuilder builder = (ResteasyClientBuilder) ClientBuilder.newBuilder();
ResteasyClientBuilder builder = new ResteasyClientBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this class? I cant find any reference to getHttpEngine being used in the codebase, and it is marked as deprecated. In either case it is confusing here that our private static class shares the name with the abstract class ResteasyClientBuilder.

I think it would be better if we renamed this class (ResteasyClientBuilderWithHttpCreds?), or moved the functionality to a private function. Open to thoughts. Perhaps this could be a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can just assume that it had its justification before #69. There was a large upgrade to resteasy and the justification could just have vanished by migrating the codebase to a newver version.

I'd recommend following that up in a separate PR in order to deliver a fix as #78 (comment) already points out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I can open an issue with this. I'll need to investigate some older commits but I believe the deprecated function has not been used, even previously, for a long time.

@MarkEWaite MarkEWaite added the bug Incorrect or flawed behavior label Apr 24, 2025
@MarkEWaite MarkEWaite merged commit 317d91b into jenkinsci:master Apr 24, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Incorrect or flawed behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants