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

There is a problem with the retry logic, which may lead to an infinite loop #62

Closed
hxy1991 opened this issue Sep 18, 2018 · 0 comments
Closed
Assignees

Comments

@hxy1991
Copy link
Collaborator

hxy1991 commented Sep 18, 2018

Reporting bugs

If the execution of the request takes longer than "readTimeoutMs" and the request always fails, the (System.currentTimeMillis() > endTime) condition is always true, resulting in an infinite loop.

ServerHttpAgent#httpGet

// ServerHttpAgent.httpGet

public HttpResult httpGet(String path, List<String> headers, List<String> paramValues, String encoding,
	long readTimeoutMs) throws IOException {

	final long endTime = System.currentTimeMillis() + readTimeoutMs;

	……
	
	do {
		
		……

		HttpResult result = HttpSimpleClient.httpGet(
				getUrl(serverListMgr.getCurrentServerAddr(), path, isSSL), newHeaders, paramValues, encoding,
				readTimeoutMs, isSSL);
		if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
				|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
				|| result.code == HttpURLConnection.HTTP_UNAVAILABLE) {
			log.error("NACOS ConnectException", "currentServerAddr:{}. httpCode:",
					new Object[] { serverListMgr.getCurrentServerAddr(), result.code });
		} else {
			return result;
		}

	} while (System.currentTimeMillis() > endTime);

	……
	
}

See Also:

@hxy1991 hxy1991 self-assigned this Sep 18, 2018
hxy1991 added a commit that referenced this issue Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant