{"action":"closed","issue":{"url":"https://api.github.com/repos/Wechat-Group/weixin-java-tools/issues/725","repository_url":"https://api.github.com/repos/Wechat-Group/weixin-java-tools","labels_url":"https://api.github.com/repos/Wechat-Group/weixin-java-tools/issues/725/labels{/name}","comments_url":"https://api.github.com/repos/Wechat-Group/weixin-java-tools/issues/725/comments","events_url":"https://api.github.com/repos/Wechat-Group/weixin-java-tools/issues/725/events","html_url":"https://github.com/Wechat-Group/weixin-java-tools/issues/725","id":353191366,"node_id":"MDU6SXNzdWUzNTMxOTEzNjY=","number":725,"title":"mp模块中的WxMpServiceHttpClientImpl的getAccessToken集群并发情况是否会多次获取token","user":{"login":"wudi19920329","id":17818445,"node_id":"MDQ6VXNlcjE3ODE4NDQ1","avatar_url":"https://avatars3.githubusercontent.com/u/17818445?v=4","gravatar_id":"","url":"https://api.github.com/users/wudi19920329","html_url":"https://github.com/wudi19920329","followers_url":"https://api.github.com/users/wudi19920329/followers","following_url":"https://api.github.com/users/wudi19920329/following{/other_user}","gists_url":"https://api.github.com/users/wudi19920329/gists{/gist_id}","starred_url":"https://api.github.com/users/wudi19920329/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wudi19920329/subscriptions","organizations_url":"https://api.github.com/users/wudi19920329/orgs","repos_url":"https://api.github.com/users/wudi19920329/repos","events_url":"https://api.github.com/users/wudi19920329/events{/privacy}","received_events_url":"https://api.github.com/users/wudi19920329/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-23T02:00:25Z","updated_at":"2018-08-23T13:17:01Z","closed_at":"2018-08-23T13:17:01Z","author_association":"NONE","body":"public String getAccessToken(boolean forceRefresh) throws WxErrorException {\r\n    Lock lock = this.getWxMpConfigStorage().getAccessTokenLock();\r\n    try {\r\n      lock.lock();\r\n      if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) {\r\n        String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL,\r\n          this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret());\r\n        try {\r\n          HttpGet httpGet = new HttpGet(url);\r\n          if (this.getRequestHttpProxy() != null) {\r\n            RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();\r\n            httpGet.setConfig(config);\r\n          }\r\n          try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) {\r\n            String resultContent = new BasicResponseHandler().handleResponse(response);\r\n            WxError error = WxError.fromJson(resultContent, WxType.MP);\r\n            if (error.getErrorCode() != 0) {\r\n              throw new WxErrorException(error);\r\n            }\r\n            WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);\r\n            this.getWxMpConfigStorage().updateAccessToken(accessToken.getAccessToken(),\r\n              accessToken.getExpiresIn());\r\n          } finally {\r\n            httpGet.releaseConnection();\r\n          }\r\n        } catch (IOException e) {\r\n          throw new RuntimeException(e);\r\n        }\r\n      }\r\n    } finally {\r\n      lock.unlock();\r\n    }\r\n    return this.getWxMpConfigStorage().getAccessToken();\r\n  }"}}
{"actor":{"display_login":"binarywang"}}