Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

fix: handle case where Future.cause() is null in FutureGroup #52

Merged
merged 6 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions carrot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里SNAPSHOT为什么要放在后面?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nexus 只把末尾是 snapshot 的当做 snapshot 包。
1.12.SNAPSHOT 是 snapshot,但是 1.12.SNAPSHOT-thrift-0.11.0-inlined 会被认作是 release。1.12-thrift-0.11.0-inlined-SNAPSHOT 就是正确的 snapshot。亲测。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那么pom.xml里面现在也要改为 1.12-thrift-0.11.0-inlined-SNAPSHOT 吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改

else
echo ${versions[0]}.${versions[1]}.${versions[2]}-$staging_branch
fi
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ void waitAllCompleteOrOneFail(List<Result> results, int timeoutMillis) throws PE
}
} else {
Throwable cause = fu.cause();
if (cause == null) {
throw new PException(
String.format(
"async task #[" + i + "] failed: timeout expired (%dms)", timeoutMillis));
}
throw new PException("async task #[" + i + "] failed: " + cause.getMessage(), cause);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand All @@ -64,4 +68,22 @@ public void testBlockingOperationException() throws Exception {

Assert.assertFalse(success.get());
}

@Test
public void testFutureWaitTimeout() throws Exception {
TestEventExecutor executor = new TestEventExecutor();
Promise<Void> promise = executor.newPromise();

FutureGroup<Void> 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();
}
}