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

【bugfix】修复上下文类加载器切换恢复异常问题(develop) #1161

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,14 @@ private HttpRequest rebuildRequest(String uriNew, String method, HttpRequest htt
return httpPost;
} else {
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(HttpClient.class.getClassLoader());
final Optional<Object> result = ReflectUtils
.buildWithConstructor(COMMON_REQUEST_CLASS,
new Class[]{String.class, String.class}, new Object[]{method, uriNew});
Thread.currentThread().setContextClassLoader(contextClassLoader);
final Optional<Object> result;
try {
Thread.currentThread().setContextClassLoader(HttpClient.class.getClassLoader());
result = ReflectUtils.buildWithConstructor(COMMON_REQUEST_CLASS,
new Class[]{String.class, String.class}, new Object[]{method, uriNew});
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
return (HttpRequest) result.orElse(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public Collection<ServiceInstance> getInstances(String serviceId) throws QueryIn
LOGGER.log(Level.WARNING, "Can not query service instances from registry center!", exception);
Thread.currentThread().setContextClassLoader(contextClassLoader);
throw new QueryInstanceException(exception.getMessage());
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}

Expand Down Expand Up @@ -270,7 +272,9 @@ public void close() {
*/
public static class ZkInstanceSerializer<T> implements InstanceSerializer<T> {
private final ObjectMapper mapper;

private final Class<T> payloadClass;

private final JavaType type;

/**
Expand Down