From 3f728218f3b42ed18880d8a7cf5c7008e67bdc3f Mon Sep 17 00:00:00 2001 From: neverchanje Date: Mon, 19 Aug 2019 17:49:17 +0800 Subject: [PATCH 1/6] Bump version to 1.13.SNAPSHOT-thrift-0.11.0-inlined --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 115367c1..b7c62745 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xiaomi.infra pegasus-client jar - 1.12.SNAPSHOT-thrift-0.11.0-inlined + 1.13.SNAPSHOT-thrift-0.11.0-inlined Pegasus Java Client From dd7d6c5f24356188379c534d4d2e46bbffa72c6b Mon Sep 17 00:00:00 2001 From: neverchanje Date: Mon, 19 Aug 2019 19:50:23 +0800 Subject: [PATCH 2/6] fix futuregroup --- .../java/com/xiaomi/infra/pegasus/client/FutureGroup.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java b/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java index 2e0aee34..7bda2af4 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java +++ b/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java @@ -37,6 +37,11 @@ void waitAllCompleteOrOneFail(List results, int timeoutMillis) throws PE } } else { Throwable cause = fu.cause(); + if (cause == null) { + throw new PException( + String.format( + "async task #[" + i + "] failed: timeout expired ({}ms)", timeoutMillis)); + } throw new PException("async task #[" + i + "] failed: " + cause.getMessage(), cause); } } From 4dd32ba097fe7f121bdc0edd0f3fe58a6a8140c6 Mon Sep 17 00:00:00 2001 From: neverchanje Date: Wed, 21 Aug 2019 15:11:42 +0800 Subject: [PATCH 3/6] add unit test --- carrot | 3 +-- pom.xml | 2 +- .../infra/pegasus/client/FutureGroup.java | 2 +- .../infra/pegasus/client/TestFutureGroup.java | 24 ++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/carrot b/carrot index 53438ee2..5c0343b9 100755 --- a/carrot +++ b/carrot @@ -72,7 +72,7 @@ function java_client_get_next_version() esac if [ ${versions[2]} == "SNAPSHOT" ]; then - echo ${versions[0]}.${versions[1]}.SNAPSHOT-$staging_branch + echo ${versions[0]}.${versions[1]}-$staging_branch-SNAPSHOT else echo ${versions[0]}.${versions[1]}.${versions[2]}-$staging_branch fi @@ -282,7 +282,6 @@ function release_minor carrot_execute "mvn versions:set -DnewVersion=$new_version" carrot_execute "mvn versions:commit" carrot_execute "git commit -am \"Bump version to $new_version\"" - carrot_execute "git push -u origin $this_branch" } function usage_carrot diff --git a/pom.xml b/pom.xml index b7c62745..36d4774d 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xiaomi.infra pegasus-client jar - 1.13.SNAPSHOT-thrift-0.11.0-inlined + 1.13-thrift-0.11.0-inlined-SNAPSHOT Pegasus Java Client diff --git a/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java b/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java index 7bda2af4..3724801b 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java +++ b/src/main/java/com/xiaomi/infra/pegasus/client/FutureGroup.java @@ -40,7 +40,7 @@ void waitAllCompleteOrOneFail(List results, int timeoutMillis) throws PE if (cause == null) { throw new PException( String.format( - "async task #[" + i + "] failed: timeout expired ({}ms)", timeoutMillis)); + "async task #[" + i + "] failed: timeout expired (%dms)", timeoutMillis)); } throw new PException("async task #[" + i + "] failed: " + cause.getMessage(), cause); } diff --git a/src/test/java/com/xiaomi/infra/pegasus/client/TestFutureGroup.java b/src/test/java/com/xiaomi/infra/pegasus/client/TestFutureGroup.java index 02a14e99..349ade4d 100644 --- a/src/test/java/com/xiaomi/infra/pegasus/client/TestFutureGroup.java +++ b/src/test/java/com/xiaomi/infra/pegasus/client/TestFutureGroup.java @@ -8,10 +8,14 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; public class TestFutureGroup { + @Rule public TestName name = new TestName(); + private static final class TestEventExecutor extends SingleThreadEventExecutor { TestEventExecutor() { super(null, Executors.defaultThreadFactory(), false); @@ -46,7 +50,7 @@ public void testBlockingOperationException() throws Exception { group.waitAllCompleteOrOneFail(10000); } catch (PException e) { success.set(false); - System.err.println("TestFutureGroup.testInterrupt: " + e.toString()); + System.err.println(name.getMethodName() + ": " + e.toString()); } executed.set(true); }); @@ -64,4 +68,22 @@ public void testBlockingOperationException() throws Exception { Assert.assertFalse(success.get()); } + + @Test + public void testFutureWaitTimeout() throws Exception { + TestEventExecutor executor = new TestEventExecutor(); + Promise promise = executor.newPromise(); + + FutureGroup group = new FutureGroup<>(1); + group.add(promise); + try { + // never wake up promise. + group.waitAllCompleteOrOneFail(10); + } catch (PException e) { + // must throw exception + System.err.println(name.getMethodName() + ": " + e.toString()); + return; + } + Assert.fail(); + } } From 215668d10862569717881fd73d465ebd3828cb9c Mon Sep 17 00:00:00 2001 From: neverchanje Date: Wed, 21 Aug 2019 16:39:34 +0800 Subject: [PATCH 4/6] fix pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 36d4774d..3d9759f5 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xiaomi.infra pegasus-client jar - 1.13-thrift-0.11.0-inlined-SNAPSHOT + 1.12.SNAPSHOT-thrift-0.11.0-inline Pegasus Java Client From fe5f3b45eaf91a0f2fa0839f76959a3e276a3276 Mon Sep 17 00:00:00 2001 From: neverchanje Date: Wed, 21 Aug 2019 16:40:04 +0800 Subject: [PATCH 5/6] fix pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3d9759f5..115367c1 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xiaomi.infra pegasus-client jar - 1.12.SNAPSHOT-thrift-0.11.0-inline + 1.12.SNAPSHOT-thrift-0.11.0-inlined Pegasus Java Client From e61f8ace91a90b9a4990f89c2a5a2c63102d5093 Mon Sep 17 00:00:00 2001 From: neverchanje Date: Thu, 22 Aug 2019 12:19:10 +0800 Subject: [PATCH 6/6] fix pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 115367c1..75f42b43 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xiaomi.infra pegasus-client jar - 1.12.SNAPSHOT-thrift-0.11.0-inlined + 1.12-thrift-0.11.0-inlined-SNAPSHOT Pegasus Java Client