Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/joinable-task #403

Merged
merged 5 commits into from
Mar 25, 2020
Merged

feat/joinable-task #403

merged 5 commits into from
Mar 25, 2020

Conversation

fengjiachun
Copy link
Contributor

@fengjiachun fengjiachun commented Mar 19, 2020

Motivation:

For nacos's advice, add join method for Task(raft),
and fix a NPE bug.

Modification:

Result:

Fixes #404

@sofastack-bot sofastack-bot bot added the size/L label Mar 19, 2020
@@ -199,14 +199,14 @@ public void setErrorMsg(String errMsg) {
* Set error code and error msg.
*/
public void setError(int code, String fmt, Object... args) {
this.state = new State(code, String.format(fmt, args));
this.state = new State(code, String.format(String.valueOf(fmt), args));
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt 已经是字符串了,这里为什么还要 valueOf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fmt 有可能为 Null 导致 NPE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

比如 jraft 有一些这样的调用 setError(-1, e.getMessage()); 其中 e.getMessage() == null

* @since 1.3.1
*/
public Closure join() throws InterruptedException {
final JoinableClosure joinable = toJoinalbe(this.done);
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是可以保存一个 toJoinable 的结果到 field,复用

Copy link
Contributor Author

Choose a reason for hiding this comment

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

应该是 method name 起的不好误导了你,修改为 castToJoinalbe ,这里是一个类型检查和类型转换,不太有必要保存复用

@fengjiachun fengjiachun self-assigned this Mar 23, 2020
@killme2008 killme2008 merged commit 74684dc into master Mar 25, 2020
@killme2008 killme2008 deleted the feat/joinable_task branch March 25, 2020 09:33
@killme2008 killme2008 restored the feat/joinable_task branch March 25, 2020 09:33
@fengjiachun fengjiachun deleted the feat/joinable_task branch April 1, 2020 03:59
@fengjiachun fengjiachun mentioned this pull request Apr 17, 2020
12 tasks
zongtanghu pushed a commit that referenced this pull request Apr 28, 2020
* joinable for raft task

* fix: fix the fmt NPE

* code format

* better name

* typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can node. apply provide synchronization
2 participants