最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AsyncHttpClient exception異常源碼流程解析

 更新時(shí)間:2023年12月11日 08:36:16   作者:codecraft  
這篇文章主要為大家介紹了AsyncHttpClient的exception源碼流程解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

本文主要研究一下AsyncHttpClient的exception

ChannelClosedException

org/asynchttpclient/exception/ChannelClosedException.java

public final class ChannelClosedException extends IOException {
  public static final ChannelClosedException INSTANCE = unknownStackTrace(new ChannelClosedException(), ChannelClosedException.class, "INSTANCE");
  private ChannelClosedException() {
    super("Channel closed");
  }
}
ChannelClosedException用于表示Channel closed的異常

handleUnexpectedClosedChannel

org/asynchttpclient/netty/request/NettyRequestSender.java

public void handleUnexpectedClosedChannel(Channel channel, NettyResponseFuture<?> future) {
    if (Channels.isActiveTokenSet(channel)) {
      if (future.isDone()) {
        channelManager.closeChannel(channel);
      } else if (future.incrementRetryAndCheck() && retry(future)) {
        future.pendingException = null;
      } else {
        abort(channel, future,
                future.pendingException != null ? future.pendingException : RemotelyClosedException.INSTANCE);
      }
    }
  }
NettyRequestSender定義了handleUnexpectedClosedChannel方法,它會(huì)關(guān)閉或abort當(dāng)前的channel

PoolAlreadyClosedException

org/asynchttpclient/exception/PoolAlreadyClosedException.java

public class PoolAlreadyClosedException extends IOException {
  public static final PoolAlreadyClosedException INSTANCE = unknownStackTrace(new PoolAlreadyClosedException(), PoolAlreadyClosedException.class, "INSTANCE");
  private PoolAlreadyClosedException() {
    super("Pool is already closed");
  }
}
PoolAlreadyClosedException用于表示連接池已經(jīng)關(guān)閉的異常

sendRequestWithNewChannel

org/asynchttpclient/netty/request/NettyRequestSender.java

private <T> ListenableFuture<T> sendRequestWithNewChannel(Request request,
                                                            ProxyServer proxy,
                                                            NettyResponseFuture<T> future,
                                                            AsyncHandler<T> asyncHandler) {
    // some headers are only set when performing the first request
    HttpHeaders headers = future.getNettyRequest().getHttpRequest().headers();
    Realm realm = future.getRealm();
    Realm proxyRealm = future.getProxyRealm();
    requestFactory.addAuthorizationHeader(headers, perConnectionAuthorizationHeader(request, proxy, realm));
    requestFactory.setProxyAuthorizationHeader(headers, perConnectionProxyAuthorizationHeader(request, proxyRealm));
    future.setInAuth(realm != null && realm.isUsePreemptiveAuth() && realm.getScheme() != AuthScheme.NTLM);
    future.setInProxyAuth(
            proxyRealm != null && proxyRealm.isUsePreemptiveAuth() && proxyRealm.getScheme() != AuthScheme.NTLM);
    try {
      if (!channelManager.isOpen()) {
        throw PoolAlreadyClosedException.INSTANCE;
      }
      // Do not throw an exception when we need an extra connection for a
      // redirect.
      future.acquirePartitionLockLazily();
    } catch (Throwable t) {
      abort(null, future, getCause(t));
      // exit and don't try to resolve address
      return future;
    }
    //......
}
sendRequestWithNewChannel在channelManager非open的時(shí)候會(huì)拋出PoolAlreadyClosedException

RemotelyClosedException

org/asynchttpclient/exception/RemotelyClosedException.java

public final class RemotelyClosedException extends IOException {
  public static final RemotelyClosedException INSTANCE = unknownStackTrace(new RemotelyClosedException(), RemotelyClosedException.class, "INSTANCE");
  RemotelyClosedException() {
    super("Remotely closed");
  }
}
RemotelyClosedException用于表示Remotely closed的異常

handleUnexpectedClosedChannel

org/asynchttpclient/netty/request/NettyRequestSender.java

public void handleUnexpectedClosedChannel(Channel channel, NettyResponseFuture&lt;?&gt; future) {
    if (Channels.isActiveTokenSet(channel)) {
      if (future.isDone()) {
        channelManager.closeChannel(channel);
      } else if (future.incrementRetryAndCheck() &amp;&amp; retry(future)) {
        future.pendingException = null;
      } else {
        abort(channel, future,
                future.pendingException != null ? future.pendingException : RemotelyClosedException.INSTANCE);
      }
    }
  }
NettyRequestSender的handleUnexpectedClosedChannel的時(shí)候,對(duì)于future未完成也沒(méi)有重試的時(shí)候會(huì)執(zhí)行abort,并拋出RemotelyClosedException

TooManyConnectionsException

org/asynchttpclient/exception/TooManyConnectionsException.java

public class TooManyConnectionsException extends IOException {
  public TooManyConnectionsException(int max) {
    super("Too many connections: " + max);
  }
}
TooManyConnectionsException用于表示全局連接超過(guò)限制的異常

TooManyConnectionsPerHostException

org/asynchttpclient/exception/TooManyConnectionsPerHostException.java

public class TooManyConnectionsPerHostException extends IOException {
  public TooManyConnectionsPerHostException(int max) {
    super("Too many connections: " + max);
  }
}
TooManyConnectionsPerHostException用于表示連接超出單host限制的異常

acquireChannelLock

org/asynchttpclient/netty/channel/ConnectionSemaphore.java

public void acquireChannelLock(Object partitionKey) throws IOException {
    if (!tryAcquireGlobal())
      throw tooManyConnections;
    if (!tryAcquirePerHost(partitionKey)) {
      freeChannels.release();
      throw tooManyConnectionsPerHost;
    }
  }
acquireChannelLock方法在全局連接超出限制時(shí)拋出tooManyConnections,在單host連接超出限制時(shí)拋出tooManyConnectionsPerHost

小結(jié)

AsyncHttpClient一共定義了五個(gè)異常,它們都繼承了IOException,分別是ChannelClosedException、PoolAlreadyClosedException、RemotelyClosedException、TooManyConnectionsException、TooManyConnectionsPerHostException。

以上就是AsyncHttpClient的exception的詳細(xì)內(nèi)容,更多關(guān)于AsyncHttpClient的exception的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 在controller中如何設(shè)置接收參數(shù)的默認(rèn)值

    在controller中如何設(shè)置接收參數(shù)的默認(rèn)值

    這篇文章主要介紹了在controller中如何設(shè)置接收參數(shù)的默認(rèn)值,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • http basic authentication通過(guò)post方式訪問(wèn)api示例分享 basic認(rèn)證示例

    http basic authentication通過(guò)post方式訪問(wèn)api示例分享 basic認(rèn)證示例

    在HTTP中,基本認(rèn)證是一種用來(lái)允許Web瀏覽器或其他客戶端程序在請(qǐng)求時(shí)提供以用戶名和口令形式的憑證,這篇文章主要介紹了http basic authentication通過(guò)post方式訪問(wèn)api示例,大家參考使用吧
    2014-01-01
  • java運(yùn)行windows的cmd命令簡(jiǎn)單代碼

    java運(yùn)行windows的cmd命令簡(jiǎn)單代碼

    這篇文章主要介紹了java運(yùn)行windows的cmd命令簡(jiǎn)單代碼,有需要的朋友可以參考一下
    2013-12-12
  • Java 使用Socket正確讀取數(shù)據(jù)姿勢(shì)

    Java 使用Socket正確讀取數(shù)據(jù)姿勢(shì)

    這篇文章主要介紹了Java 使用Socket正確讀取數(shù)據(jù)姿勢(shì),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • Java中的15種鎖

    Java中的15種鎖

    在讀很多并發(fā)文章中,會(huì)提及各種各樣鎖如公平鎖,樂(lè)觀鎖等等,這篇文章小編將向大家介紹是各種鎖的分類,感興趣的小伙伴可以參考下面文章的具體內(nèi)容
    2021-09-09
  • SpringBoot 集成 ShedLock 分布式鎖的示例詳解

    SpringBoot 集成 ShedLock 分布式鎖的示例詳解

    ShedLock是一個(gè)在分布式環(huán)境中使用的定時(shí)任務(wù)框架,用于解決在分布式環(huán)境中的多個(gè)實(shí)例的相同定時(shí)任務(wù)在同一時(shí)間點(diǎn)重復(fù)執(zhí)行的問(wèn)題,本文重點(diǎn)給大家介紹SpringBoot 分布式鎖ShedLock的相關(guān)知識(shí),感興趣的朋友一起看看吧
    2021-08-08
  • SpringBoot返回前端Long型丟失精度后兩位變成00的解決

    SpringBoot返回前端Long型丟失精度后兩位變成00的解決

    在后端開發(fā)中,當(dāng)Long類型的ID超過(guò)19位時(shí),前端JavaScript可能會(huì)出現(xiàn)精度問(wèn)題,導(dǎo)致最后兩位變成00,本文提出了三種解決方案:將ID轉(zhuǎn)換為字符串、使用@JsonSerialize注解和使用@JsonFormat注解,通過(guò)這些方法,可以確保ID在前后端傳輸過(guò)程中不會(huì)發(fā)生精度丟失
    2026-01-01
  • Java實(shí)現(xiàn)一行一行讀取文本的多種方法詳解

    Java實(shí)現(xiàn)一行一行讀取文本的多種方法詳解

    這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)一行一行讀取文本的多種方法,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,有需要的小伙伴可以了解下
    2025-10-10
  • Java Apache POI實(shí)現(xiàn)導(dǎo)出Excel的實(shí)戰(zhàn)指南

    Java Apache POI實(shí)現(xiàn)導(dǎo)出Excel的實(shí)戰(zhàn)指南

    在企業(yè)級(jí)開發(fā)中,Excel 數(shù)據(jù)導(dǎo)出是高頻需求,本文基于 Apache POI 實(shí)現(xiàn)災(zāi)情速報(bào)員數(shù)據(jù) Excel 導(dǎo)出功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2026-04-04
  • mybatis連接MySQL8出現(xiàn)的問(wèn)題解決方法

    mybatis連接MySQL8出現(xiàn)的問(wèn)題解決方法

    這篇文章主要介紹了mybatis連接MySQL8出現(xiàn)的問(wèn)題解決方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-10-10

最新評(píng)論

永新县| 廊坊市| 营口市| 峨山| 黔南| 金沙县| 进贤县| 葫芦岛市| 新晃| 郑州市| 东阳市| 八宿县| 渝中区| 开化县| 泸州市| 辛集市| 中山市| 当雄县| 安国市| 临洮县| 交口县| 香港| 梁河县| 天柱县| 峨山| 江北区| 涞水县| 高清| 山阴县| 五峰| 阜城县| 双流县| 蛟河市| 南漳县| 淮安市| 晴隆县| 柳林县| 思南县| 巴楚县| 土默特右旗| 湄潭县|