1
0
mirror of synced 2025-12-20 23:58:05 +08:00

修复接口请求重试代码,避免无效等待

This commit is contained in:
Binary Wang
2016-12-15 15:23:29 +08:00
parent c0a325901a
commit b8a9795cf5
4 changed files with 34 additions and 23 deletions

View File

@@ -1,17 +1,16 @@
package me.chanjar.weixin.mp.api;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@Test
public class WxMpBusyRetryTest {
@@ -24,6 +23,7 @@ public class WxMpBusyRetryTest {
protected synchronized <T, E> T executeInternal(
RequestExecutor<T, E> executor, String uri, E data)
throws WxErrorException {
this.log.info("Executed");
WxError error = new WxError();
error.setErrorCode(-1);
throw new WxErrorException(error);
@@ -32,9 +32,7 @@ public class WxMpBusyRetryTest {
service.setMaxRetryTimes(3);
service.setRetrySleepMillis(500);
return new Object[][] {
new Object[] { service }
};
return new Object[][] { { service } };
}
@Test(dataProvider = "getService", expectedExceptions = RuntimeException.class)