Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62652

A connection to https://api.github.com/ was leaked. Did you forget to close a response body?

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      github-branch-source 2.9.1
      jenkins 2.261
      github-api 1.116.0
    • Similar Issues:

      Description

      Our logs are getting spammed with:
      "A connection to https://api.github.com/ was leaked. Did you forget to close a response body?"

      If I enable fine detail logging I get these stacktraces:

      Jun 10, 2020 8:03:39 AM WARNING okhttp3.internal.platform.Platform log
      A connection to https://api.github.com/ was leaked. Did you forget to close a response body?
      java.lang.Throwable: response.body().close()
      	at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:148)
      	at okhttp3.RealCall.captureCallStackTrace(RealCall.java:116)
      	at okhttp3.RealCall.execute(RealCall.java:88)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:666)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:697)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1058)
      	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
      	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:348)
      	at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145)
      	at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:279)
      	at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1088)
      	at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1082)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902)
      	at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221)
      	at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1103)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229)
      	at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505)
      	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      
      Jun 10, 2020 8:03:39 AM WARNING okhttp3.internal.platform.Platform log
      A connection to https://api.github.com/ was leaked. Did you forget to close a response body?
      java.lang.Throwable: response.body().close()
      	at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:148)
      	at okhttp3.RealCall.captureCallStackTrace(RealCall.java:116)
      	at okhttp3.RealCall.execute(RealCall.java:88)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:666)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:697)
      	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1058)
      	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
      	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:348)
      	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:312)
      	at org.kohsuke.github.GitHubClient.isPrivateModeEnabled(GitHubClient.java:631)
      	at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:281)
      	at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1088)
      	at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1082)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902)
      	at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221)
      	at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1103)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229)
      	at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505)
      	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      

        Attachments

          Activity

          Hide
          bitwiseman Liam Newman added a comment -

          This will be fixed in v1.114 when I can publish it.

          Show
          bitwiseman Liam Newman added a comment - This will be fixed in v1.114 when I can publish it.
          Hide
          timja Tim Jacomb added a comment -

          Liam Newman this seems unfixed, I've updated the environment with what we're currently running

           

          Oct 21, 2020 7:29:53 PM WARNING okhttp3.internal.platform.Platform logA connection to https://api.github.com/ was leaked. Did you forget to close a response body?
          java.lang.Throwable: response.body().close()
          	at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:149)
          	at okhttp3.internal.connection.Transmitter.callStart(Transmitter.java:116)
          	at okhttp3.RealCall.execute(RealCall.java:78)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:667)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:698)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1059)
          	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
          	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:400)
          	at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145)
          	at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:330)
          	at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1103)
          	at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332)
          	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1112)
          	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902)
          	at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221)
          	at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1165)
          	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246)
          	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229)
          	at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505)
          	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
          	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
          	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
          	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          	at java.base/java.lang.Thread.run(Thread.java:834)
          
          Oct 21, 2020 7:29:53 PM WARNING okhttp3.internal.platform.Platform logA connection to https://api.github.com/ was leaked. Did you forget to close a response body?
          java.lang.Throwable: response.body().close()
          	at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:149)
          	at okhttp3.internal.connection.Transmitter.callStart(Transmitter.java:116)
          	at okhttp3.RealCall.execute(RealCall.java:78)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:667)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:698)
          	at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1059)
          	at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
          	at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:400)
          	at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145)
          	at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:330)
          	at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1103)
          	at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332)
          	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1112)
          	at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902)
          	at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221)
          	at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1165)
          	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246)
          	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229)
          	at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505)
          	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
          	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
          	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
          	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          	at java.base/java.lang.Thread.run(Thread.java:834) 
          Show
          timja Tim Jacomb added a comment - Liam Newman this seems unfixed, I've updated the environment with what we're currently running   Oct 21, 2020 7:29:53 PM WARNING okhttp3.internal.platform.Platform logA connection to https: //api.github.com/ was leaked. Did you forget to close a response body? java.lang.Throwable: response.body().close() at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:149) at okhttp3.internal.connection.Transmitter.callStart(Transmitter.java:116) at okhttp3.RealCall.execute(RealCall.java:78) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:667) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:698) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1059) at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69) at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:400) at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145) at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:330) at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1103) at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332) at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1112) at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902) at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221) at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1165) at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246) at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229) at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505) at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang. Thread .run( Thread .java:834) Oct 21, 2020 7:29:53 PM WARNING okhttp3.internal.platform.Platform logA connection to https: //api.github.com/ was leaked. Did you forget to close a response body? java.lang.Throwable: response.body().close() at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.java:149) at okhttp3.internal.connection.Transmitter.callStart(Transmitter.java:116) at okhttp3.RealCall.execute(RealCall.java:78) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponse(ObsoleteUrlFactory.java:667) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getResponseCode(ObsoleteUrlFactory.java:698) at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getResponseCode(ObsoleteUrlFactory.java:1059) at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69) at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:400) at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:145) at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:330) at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1103) at org.jenkinsci.plugins.github_branch_source.Connector.checkApiUrlValidity(Connector.java:332) at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSource(GitHubSCMNavigator.java:1112) at org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.visitSources(GitHubSCMNavigator.java:902) at jenkins.scm.api.SCMNavigator.visitSources(SCMNavigator.java:221) at jenkins.branch.OrganizationFolder$SCMEventListenerImpl.onSCMHeadEvent(OrganizationFolder.java:1165) at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246) at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229) at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505) at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang. Thread .run( Thread .java:834)
          Hide
          atcarmo André Carmo added a comment -

          I also see this issue from time to time.

          Show
          atcarmo André Carmo added a comment - I also see this issue from time to time.
          Hide
          bitwiseman Liam Newman added a comment - - edited

          André Carmo
          Have you updated to the github-api-plugin 1.118 or later? If so, please provide a stack trace and more information. Nailing down all the code paths was harder than I thought.

          Show
          bitwiseman Liam Newman added a comment - - edited André Carmo Have you updated to the github-api-plugin 1.118 or later? If so, please provide a stack trace and more information. Nailing down all the code paths was harder than I thought.
          Hide
          atcarmo André Carmo added a comment -

          Thank you for your reply Liam Newman.

          I'm using:

          • GitHub API Plugin with version 1.123
          • GitHub Branch Source 2.9.7 (I know GitHub branch source 2.10.x has some changes on API calls but we're still in the process of updating to the latest LTS of Jenkins)
          • Jenkins 2.263.4

           

          In the last 24 hours I can see 1660 log entries of this message. We have a pretty large GitHub organization with more than 500 repos, and we execute around 3k builds per day.

          The problem seems to be related to some delays we have between receiving the GitHub webhook request and the time the build actually is triggered. When there is a delay, this issue usually occurs, although I could not find exactly why.

           

          2021-03-17 19:15:49.001+0000 [id=8899820]	WARNING	o.internal.platform.Platform#log: A connection to https://api.github.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
          

           

          I don't have anything else on the error stack trace. Does this help?

          Show
          atcarmo André Carmo added a comment - Thank you for your reply Liam Newman . I'm using: GitHub API Plugin with version 1.123 GitHub Branch Source 2.9.7 (I know GitHub branch source 2.10.x has some changes on API calls but we're still in the process of updating to the latest LTS of Jenkins) Jenkins 2.263.4   In the last 24 hours I can see 1660 log entries of this message. We have a pretty large GitHub organization with more than 500 repos, and we execute around 3k builds per day. The problem seems to be related to some delays we have between receiving the GitHub webhook request and the time the build actually is triggered. When there is a delay, this issue usually occurs, although I could not find exactly why.   2021-03-17 19:15:49.001+0000 [id=8899820] WARNING o.internal.platform.Platform#log: A connection to https: //api.github.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient. class. getName()).setLevel(Level.FINE);   I don't have anything else on the error stack trace. Does this help?

            People

            Assignee:
            bitwiseman Liam Newman
            Reporter:
            timja Tim Jacomb
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: