Skip to content

GitHubHttpUrlConnectionClient uses forbidden behavior in JDK 16+ #1202

Closed

Description

@spnda

Describe the bug
Using GHReleaseUpdater#update and JDK 16.0.1, following exception is thrown:

Unable to make field private final sun.net.www.protocol.https.DelegateHttpsURLConnection sun.net.www.protocol.https.HttpsURLConnectionImpl.delegate accessible: module java.base does not "opens sun.net.www.protocol.https" to unnamed module @326e57ed
	at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.setRequestMethod(GitHubHttpUrlConnectionClient.java:176)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.setupConnection(GitHubHttpUrlConnectionClient.java:119)
	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:56)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:387)
	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:355)
	at org.kohsuke.github.Requester.fetch(Requester.java:76)
	at org.kohsuke.github.GHReleaseUpdater.update(GHReleaseUpdater.java:116)
	at Build_gradle$2$2.execute(build.gradle.kts:107)

To Reproduce
Steps to reproduce the behavior:
I used this small Kotlin snippet to execute the code, while using JDK 16:

val ghRelease = releaseBuilder.create()
ghRelease.update().name("new fancy name").update()

Expected behavior
The release should be updated.

Additional context
This happens in a GitHub Action environment using the adoptopenjdk:16-jdk container. I assume this is because of some JDK internals being harder to access and JDK 16 removing the functionality of making final fields non-final through reflection.

I'm surprised that the changes that would have fixed this were reverted with c197dc6. Any update on anything that will fix that or will we have to wait on an implementation of #1085?

https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GitHubHttpUrlConnectionClient.java#L175-L181

Activity

  1. gsmet commented on Jul 31, 2021

    @gsmet
    Contributor

    For now, you can use the OkHttp connector:

                <dependency>
                    <groupId>com.squareup.okhttp3</groupId>
                    <artifactId>okhttp</artifactId>
                    <version>4.9.1</version>
                </dependency>
    GitHub gitHub = GitHubBuilder.fromEnvironment()
        .withConnector(new OkHttpConnector(new OkHttpClient()))
        .build();
  2. bitwiseman commented on Aug 2, 2021

    @bitwiseman
    Member

    It is also possible to unblock to this on Java 16 with special settings.

    See #754 and #1164.

    Or some one can provide the resources needed to fix this. I'm more than happy to provide guidance.

  3. changed the title [-]GitHubHttpUrlConnectionClient uses forbidden behavior in JDK 16[/-] [+]GitHubHttpUrlConnectionClient uses forbidden behavior in JDK 16+[/+] on Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions