我有一个通过RestTemplate.exchange()获取对象的函数...

private MatchList getRankedHistoryFromAccountId(long accountId) {

    String url = HTTPS + Region.valueOf(region.toUpperCase()).getServerURL() + URL_PREFIX + RiotAPIEndpoint.values()[6].getServiceURL(accountId) + API_KEY;
    RestTemplate template = new RestTemplate();
    try {
        System.out.println("Exchanging!");
        MatchList matchList = template.exchange(url, HttpMethod.GET, null, MatchList.class).getBody();
        return matchList;
    }
    catch (HttpClientErrorException hcee) {
        switch (hcee.getRawStatusCode()) {
            case 404:
                return null;
            default:
                try {
                    hcee.printStackTrace();
                    Thread.sleep(1000);
                    return getRankedHistoryFromAccountId(accountId);
                }
                catch (InterruptedException e) {
                    e.printStackTrace();
                }
        }
    }
    return null;
}

大约有99%的时间有效。 我想说大约有1/100次调用此函数会导致“交换!” 被打印出来,然后程序挂起。 我已经在这个问题上停留了一个星期,无法在网上找到任何东西来帮助我解决问题。

编辑:这是最近 2个GET请求的调试消息:

(162/200) Found challenger player RB KaSing's ranked stats.
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Executing request GET /lol/league/v3/positions/by-summoner/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Target auth state: UNCHALLENGED
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> GET /lol/league/v3/positions/by-summoner/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Accept: application/json, application/*+json
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Host: EUW1.api.riotgames.com
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Connection: Keep-Alive
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Accept-Encoding: gzip,deflate
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "GET /lol/league/v3/positions/by-summoner/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1[\r][\n]"
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Accept: application/json, application/*+json[\r][\n]"
2017-08-16 00:01:30.251 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Host: EUW1.api.riotgames.com[\r][\n]"
2017-08-16 00:01:30.254 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2017-08-16 00:01:30.254 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)[\r][\n]"
2017-08-16 00:01:30.254 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2017-08-16 00:01:30.254 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Access-Control-Allow-Headers: Content-Type[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Access-Control-Allow-Methods: GET, POST, DELETE, PUT[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Content-Encoding: gzip[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Content-Type: application/json;charset=utf-8[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Date: Wed, 16 Aug 2017 04:01:36 GMT[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Vary: Accept-Encoding[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "X-App-Rate-Limit: 100:120,20:1[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "X-App-Rate-Limit-Count: 54:120,1:1[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "X-Method-Rate-Limit: 20000:10,1200000:600[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "X-Method-Rate-Limit-Count: 2:10,43:600[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "X-NewRelic-App-Data: PxQFWFFSDwQTUlBSDgkOVEYdFGQHBDcQUQxLA1tMXV1dORYzVBJHNQFUZAQUFVFQVThOA0dYa0kIXlpvTR0RB1cLVwxFZBtEAUsMPR4NVgMDQ1I9SQFBHkMRDA9YX1IUOB5NQBcLDg1eB0orXEsOGmhVFFhsShtKSEoSUyVKYwMdXTxJHhseGzgeU10WFBpCGCV9NhEaGAIdVRVRH1EDW1MHA1NRUBQeAUhDUg5TAlJSUA4BAwNQBAFRD0AUXlVeQABk[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "transfer-encoding: chunked[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Connection: keep-alive[\r][\n]"
2017-08-16 00:01:30.414 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "[\r][\n]"
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "a[\r][\n]"
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][\r][\n]"
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << HTTP/1.1 200 OK
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Access-Control-Allow-Headers: Content-Type
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Access-Control-Allow-Methods: GET, POST, DELETE, PUT
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Access-Control-Allow-Origin: *
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Content-Encoding: gzip
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Content-Type: application/json;charset=utf-8
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Date: Wed, 16 Aug 2017 04:01:36 GMT
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Vary: Accept-Encoding
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << X-App-Rate-Limit: 100:120,20:1
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << X-App-Rate-Limit-Count: 54:120,1:1
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << X-Method-Rate-Limit: 20000:10,1200000:600
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << X-Method-Rate-Limit-Count: 2:10,43:600
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << X-NewRelic-App-Data: PxQFWFFSDwQTUlBSDgkOVEYdFGQHBDcQUQxLA1tMXV1dORYzVBJHNQFUZAQUFVFQVThOA0dYa0kIXlpvTR0RB1cLVwxFZBtEAUsMPR4NVgMDQ1I9SQFBHkMRDA9YX1IUOB5NQBcLDg1eB0orXEsOGmhVFFhsShtKSEoSUyVKYwMdXTxJHhseGzgeU10WFBpCGCV9NhEaGAIdVRVRH1EDW1MHA1NRUBQeAUhDUg5TAlJSUA4BAwNQBAFRD0AUXlVeQABk
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << transfer-encoding: chunked
2017-08-16 00:01:30.416 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Connection: keep-alive
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "d3[\r][\n]"
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "][0x8e][0xb1]N[0xc3]@[0xc][0x86]_[0x5]ya[0xc9][0x90][0xb]-[0x95][0xb2][0x15][0x88] "J[0xaa][0xb6]S[0x11][0xaa],[0xe2][0xd0]S/w[0xad][0xcf])D[0x88]w[0xc7][0xa8][0x15][0x3][0x9b][0xfd]}[0xfa][0xed][0xff][0xe5][0xb][0x1c][0xe1][0xfb]@5[0xf6][0x4]9lF[0xc6][0xeb]xU[0xfa][0xce]:a[0x94][0xc0][0x11][0x12][0x10]K[0xac][0xf2][0xfe]i^UE[0xfd]X,[0x95][0x1d][0x7][0x1a]h=[0x1e]~S[0xcb]y[0xfd]\<lWM[0xd5]l[0xa7][0x9f]S[0xb5][0x8c]~[0xaf][0xa2][0xd4][0xf1][0xe0]p$nxM[0xd8][0x97][0xad][0xc2][0xcc][0xa4][0xa9]17[0xe9]?wi[0xd0][0xb4][0x1]{O*[0xcf][0xc5][0x16][0xc1]z[0x89][0x90][0xcf]f[0x93][0x4]>[0xac][0xd7]13[0x99][0xda][0x10]#[0xe9]b&[0xb7][0x9][0x9c]HH_B.<P[0x2][0xd6][0xe3][0x9b][0xd8][0x93][0x9e][0xeb][0xd0]E[0x5][0x1d]S[0xdc][0xdd][0xb9][0x10][0xda]?[0xb4][0xb][0xb2][0x12]&[0xdc][0x9f]C[0xdf][0xaf]?nv}[0xfa][0xb][0x1][0x0][0x0][\r][\n]"
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "0[\r][\n]"
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "[\r][\n]"
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 0][route: {s}->https://EUW1.api.riotgames.com:443] can be kept alive indefinitely
2017-08-16 00:01:30.417 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Executing request GET /lol/summoner/v3/summoners/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Target auth state: UNCHALLENGED
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> GET /lol/summoner/v3/summoners/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Accept: application/json, application/*+json
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Host: EUW1.api.riotgames.com
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Connection: Keep-Alive
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 >> Accept-Encoding: gzip,deflate
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "GET /lol/summoner/v3/summoners/21001130?api_key=RGAPI-1a878616-c46b-4945-bd22-5d626d7686b2 HTTP/1.1[\r][\n]"
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Accept: application/json, application/*+json[\r][\n]"
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Host: EUW1.api.riotgames.com[\r][\n]"
2017-08-16 00:01:31.917 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2017-08-16 00:01:31.919 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)[\r][\n]"
2017-08-16 00:01:31.919 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2017-08-16 00:01:31.919 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 >> "[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "HTTP/1.1 500 Server Error[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Content-Type: application/json;charset=utf-8[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Date: Wed, 16 Aug 2017  04:01:38 GMT[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Content-Length: 64[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "Connection: keep-alive[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "[\r][\n]"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.wire                     : http-outgoing-0 << "{"status":{"message":"Internal server error","status_code":500}}"
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << HTTP/1.1 500 Server Error
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Content-Type: application/json;charset=utf-8
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Date: Wed, 16 Aug 2017  04:01:38 GMT
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Content-Length: 64
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] org.apache.http.headers                  : http-outgoing-0 << Connection: keep-alive
2017-08-16 00:01:32.102 DEBUG 10988 --- [cTaskExecutor-1] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely
2017-08-16 00:01:32.105 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 0][route: {s}->https://EUW1.api.riotgames.com:443] can be kept alive indefinitely
2017-08-16 00:01:32.105 DEBUG 10988 --- [cTaskExecutor-1] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {s}->https://EUW1.api.riotgames.com:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]

#1楼 票数:0 已采纳

我想通了,感谢@AbhijitSarkar的帮助。

调试状态码后,我发现我时不时返回5xx状态码。 正如您在OP中看到的那样,仅捕获了客户端异常。 5xx状态代码未在此处捕获,因为它们是服务器异常。

    catch (HttpServerErrorException hsee) {
        switch(hsee.getRawStatusCode()) {
            default:
                try {
                    hsee.printStackTrace();
                    Thread.sleep(1000);
                    return getSummonerInformationFromAccountId(accountId);
                }
                catch (InterruptedException e) {
                    e.printStackTrace();
                }
        }
    }

另一个带有HttpServerErrorException的catch块可以解决此问题。 显然,您将需要向交换机添加更多的案例,并且有一个很好的策略来处理至少最常见的案例(500、503等)

  ask by Nuradin translate from so

未解决问题?本站智能推荐:

1回复

无法使用 spring-boot 应用程序从 Jaeger UI 跟踪服务

无法在 Jaeger UI (localhost:16686/search) 上跟踪 springboot 应用程序的服务。 在这里,我能够成功运行应用程序,但无法在 jaeger ui 中获取服务(除了默认的 jaeger-query)。 我用docker cmd来启动jaeger服务, 在
1回复

RestTemplate 中的交换方法的目的是什么?

我目前正在向客户端发送资源,我正在使用已经完成的代码并且我正在修改它,此代码中有一行我不明白。 好吧,我知道我正在发送或发布资源,我知道此方法采用客户端的 url,例如在这种情况下它采用 HTTP 请求的类型 POST,但我不明白为什么此方法采用 nService.getStringHttpEnti
2回复

如何从RestTemplate交换方法获取特定对象?

我有一个端点可以返回以下响应: 我的问题是,如何制作一个只能用json响应的一部分填充的模型。 例如,与此: 或这个:
4回复

Spring启动REST应用程序测试方法

我有一个Spring启动+ REST应用程序。 当我需要编写单元测试时,我应该直接调用服务bean还是调用其余的控制器? 如果我直接调用其余的控制器,我必须使用RestTemplate并调用其余的api作为客户端,对吧? 什么是最好的和必要的练习? 如果我直接调用服务bean,它
2回复

Spring启动应用程序Post方法调用,405:方法不允许

我正在用Spring启动编写Rest Application。 将我的服务代码公开为REST服务。 当我使用下面的Controller和Pojo类代码编写Post方法时,我能够在GET方法中公开我的服务。我得到405:Method Not Allowed错误。 不明白为什么? 我
2回复

Spring保护Web应用程序和Rest应用程序

我读了很多关于如何配置spring安全性的手册,但是仍然对配置有所保留。 所以我想配置rest呼叫和其他http呼叫。 据我了解,我可以为Web应用程序创建/ server / **之类的URL,为rest应用程序创建/ rest / **之类的URL。 对于Web应用程序URL的任何调用
2回复

Spring应用程序中的NoSuchBeanDefinitionException

我正在使用REST创建一个应用程序。 目前,我的Controller正在使用ServiceMockImplementation实现,但我打算使用数据库(而不是对Contacts的值进行硬编码)。 当由模拟实现使用时,宁静的客户端可以正常运行(并在服务器上运行),但是当我添加我的DAO实现时,
1回复

在Spring应用程序中将产品链接到订单的最佳方法是什么?

我正在开发一个提供REST服务的简单Spring Boot应用程序,以允许客户登录和订购某些产品。 在我的MySQL数据库中,我有以下表格: 客户卖家商店产品订单 用户可以选择多个产品,将它们添加到购物车,然后点击“继续结帐”。 在此部分之前,一切都很完美,但现在我不知道如何