cancel pending price request on select new provider

This commit is contained in:
woodser 2024-01-17 20:28:28 -05:00
parent 75e85179b4
commit 7beae49dd2
3 changed files with 29 additions and 7 deletions

View file

@ -39,5 +39,7 @@ public interface HttpClient {
boolean hasPendingRequest();
void cancelPendingRequest();
void shutDown();
}

View file

@ -135,6 +135,24 @@ public class HttpClientImpl implements HttpClient {
}
}
public void cancelPendingRequest() {
if (!hasPendingRequest) return;
try {
if (connection != null) {
connection.getInputStream().close();
connection.disconnect();
connection = null;
}
if (closeableHttpClient != null) {
closeableHttpClient.close();
closeableHttpClient = null;
}
} catch (IOException err) {
// igbnore
}
hasPendingRequest = false;
}
private String requestWithoutProxy(String baseUrl,
String param,
HttpMethod httpMethod,