From 5c9b33dfd47908c407191b1680f45454f91410b9 Mon Sep 17 00:00:00 2001 From: yongjun310 Date: Thu, 21 Jan 2021 18:45:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=8B=A6=E6=88=AA=E5=99=A8=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=AC=AC10=E6=AC=A1=E6=97=A0=E6=95=88=20#893=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=BD=93Interceptor=E7=9A=84process?= =?UTF-8?q?=E6=9C=AA=E5=9B=9E=E8=B0=83onContinue=E6=88=96=E8=80=85onInterr?= =?UTF-8?q?upt=E6=97=B6=EF=BC=8C=E6=A1=86=E6=9E=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AE=A9=E6=8B=A6=E6=88=AA=E9=93=BE=E7=BB=A7=E7=BB=AD=E4=B8=8B?= =?UTF-8?q?=E5=8E=BB=E3=80=82=E9=98=B2=E6=AD=A2CountDownLatch=E5=A7=8B?= =?UTF-8?q?=E7=BB=88=E6=9C=AA=E5=88=B00=EF=BC=8C=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E7=AD=89=E5=BE=85300s=E8=B6=85=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=BA=BF=E7=A8=8B=E6=B1=A0=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E9=98=9F=E5=88=97=E6=BB=A1=E6=8E=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arouter/core/InterceptorServiceImpl.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java b/arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java index 3568ee29..c8e745be 100644 --- a/arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java +++ b/arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java @@ -74,12 +74,12 @@ public void run() { private static void _execute(final int index, final CancelableCountDownLatch counter, final Postcard postcard) { if (index < Warehouse.interceptors.size()) { IInterceptor iInterceptor = Warehouse.interceptors.get(index); + long curCount = counter.getCount(); iInterceptor.process(postcard, new InterceptorCallback() { @Override public void onContinue(Postcard postcard) { // Last interceptor excute over with no exception. - counter.countDown(); - _execute(index + 1, counter, postcard); // When counter is down, it will be execute continue ,but index bigger than interceptors size, then U know. + countDownAndContinue(index, counter, postcard); } @Override @@ -96,9 +96,24 @@ public void onInterrupt(Throwable exception) { // } } }); + if (curCount == counter.getCount()) { + countDownAndContinue(index, counter, postcard); + } } } + /** + * continue execute interceptor + * + * @param index current interceptor index + * @param counter interceptor counter + * @param postcard routeMeta + */ + private static void countDownAndContinue(int index, CancelableCountDownLatch counter, Postcard postcard) { + counter.countDown(); + _execute(index + 1, counter, postcard); // When counter is down, it will be execute continue ,but index bigger than interceptors size, then U know. + } + @Override public void init(final Context context) { LogisticsCenter.executor.execute(new Runnable() {