-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
[Dubbo-6567] fix consumer warning "safe guard client , should not be called ,must have a bug." #6959
Closed
wikiwikiwiki
wants to merge
4
commits into
apache:master
from
wikiwikiwiki:fix-safe_guard_client_warn
Closed
[Dubbo-6567] fix consumer warning "safe guard client , should not be called ,must have a bug." #6959
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ef26026
fix bug: consumer warning "safe guard client , should not be called ,…
wikiwikiwiki 92761d9
the return value of isClosed() of the lazy client for defensive opera…
wikiwikiwiki 367bbba
Merge branch 'remote-master' into fix-safe_guard_client_warn
wikiwikiwiki 361a9d4
fix bug: consumer warning "safe guard client, should not be called, m…
wikiwikiwiki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
import static org.apache.dubbo.remoting.Constants.SEND_RECONNECT_KEY; | ||
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE; | ||
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.LAZY_CONNECT_INITIAL_STATE_KEY; | ||
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.LAZY_CLOSE_STATE_KEY; | ||
|
||
/** | ||
* dubbo protocol support class. | ||
|
@@ -57,15 +58,21 @@ final class LazyConnectExchangeClient implements ExchangeClient { | |
/** | ||
* lazy connect, initial state for connection | ||
*/ | ||
private final boolean initialState; | ||
private final boolean initialConnectState; | ||
private final Boolean closeState; | ||
private volatile ExchangeClient client; | ||
private AtomicLong warningcount = new AtomicLong(0); | ||
|
||
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) { | ||
// lazy connect, need set send.reconnect = true, to avoid channel bad status. | ||
this.url = url.addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString()); | ||
this.requestHandler = requestHandler; | ||
this.initialState = url.getParameter(LAZY_CONNECT_INITIAL_STATE_KEY, DEFAULT_LAZY_CONNECT_INITIAL_STATE); | ||
this.initialConnectState = url.getParameter(LAZY_CONNECT_INITIAL_STATE_KEY, DEFAULT_LAZY_CONNECT_INITIAL_STATE); | ||
if (url.hasParameter(LAZY_CLOSE_STATE_KEY)) { | ||
this.closeState = Boolean.parseBoolean(url.getParameter(LAZY_CLOSE_STATE_KEY)); | ||
} else { | ||
this.closeState = null; | ||
} | ||
this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false); | ||
} | ||
|
||
|
@@ -150,7 +157,7 @@ public ChannelHandler getChannelHandler() { | |
@Override | ||
public boolean isConnected() { | ||
if (client == null) { | ||
return initialState; | ||
return initialConnectState; | ||
} else { | ||
return client.isConnected(); | ||
} | ||
|
@@ -184,10 +191,14 @@ public void send(Object message, boolean sent) throws RemotingException { | |
|
||
@Override | ||
public boolean isClosed() { | ||
if (client != null) { | ||
return client.isClosed(); | ||
} else { | ||
if (closeState != null) { | ||
return closeState; | ||
} | ||
|
||
if (client == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
} else { | ||
return client.isClosed(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.closeState = null; if (url.hasParameter(LAZY_CLOSE_STATE_KEY)) { this.closeState = Boolean.parseBoolean(url.getParameter(LAZY_CLOSE_STATE_KEY)); }