github-api: Illegal Reflective Access Operation to field java.net.HttpURLConnection.method

Describe the bug I attempt to archive a repository using the following code:

GHRepository repo = this.org.getRepository("repo-name-here");
repo.archive();

When checking GitHub itself, the repository is in fact archived, however I receive a warning in the stderr stream consisting of the following:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo (file:/C:/Users/andrew/.m2/repository/org/kohsuke/github-api/1.108/github-api-1.108.jar) to field java.net.HttpURLConnection.method
WARNING: Please consider reporting this to the maintainers of org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

To Reproduce Steps to reproduce the behavior:

  1. Fetch a GHRepository that is not yet archived.
  2. Call archive() on that repository.

Expected behavior I expect that there should not be any illegal reflective access exceptions.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Version 74

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you @bitwiseman 😄 ! I’ll give it a try tomorrow, it’s close to midnight where I am right now. Will report back as soon as I have something conclusive.

Thanks @bitwiseman! These are the relevant kotlin changes I was able to do based on your input:

additional dependency using kotlin dsl (build.gradle.kts)

    implementation("com.squareup.okhttp3:okhttp:4.9.0")

some kt file

import okhttp3.OkHttpClient
import org.kohsuke.github.GitHubBuilder.fromEnvironment
import org.kohsuke.github.extras.okhttp3.OkHttpConnector
...
// within an existing class
    companion object {
        private val baseClient = OkHttpClient()
    }
...
// within an existing fun
                fromEnvironment().
                withConnector(
                    OkHttpConnector(baseClient)
                ).build()

but I could not find a hint that made my code work.

How about something like this:

import okhttp3.OkHttpClient;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.kohsuke.github.extras.okhttp3.OkHttpConnector;

// ... in some class
static OkHttpClient baseClient = new OkHttpClient();

// ... in some method
GitHub gitHub = GitHubBuilder.
    .fromEnvironment()
    .withConnector(new OkHttpConnector(baseClient.newBuilder().build())
    .build();