本文整理了Java中feign.Response.close
方法的一些代码示例,展示了Response.close
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.close
方法的具体详情如下:
包路径:feign.Response
类名称:Response
方法名:close
暂无
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.business.rules.core
private void closeResponse(Response response) {
if (response != null) {
response.close();
}
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.sp.jobmanager.core
/**
* Get list of deployed Siddhi app names in a given resource node.
*
* @param node resource node.
* @return list of deployed Siddhi app names.
*/
public static List<String> getDeployedApps(ResourceNode node) {
feign.Response resourceResponse = null;
String[] apps = new String[0];
try {
resourceResponse = ResourceServiceFactory.getResourceHttpsClient(Constants.PROTOCOL +
HTTPSClientUtil.generateURLHostPort(node.getHttpsInterface().getHost(),
String.valueOf(node.getHttpsInterface().getPort())),
node.getHttpsInterface().getUsername(), node.getHttpsInterface().getPassword())
.getSiddhiApps();
if (resourceResponse.status() == 200) {
apps = new Gson().fromJson(resourceResponse.body().toString(), String[].class);
}
} catch (feign.FeignException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error occurred while retrieving deployed Siddhi apps from " + node, e);
}
} finally {
if (resourceResponse != null) {
resourceResponse.close();
}
}
return Arrays.asList(apps);
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.sp.jobmanager.core
/**
* Un-deploy Siddhi app and return whether it successfully un-deployed or not.
*
* @param node node to be deployed.
* @param siddhiAppName name of the Siddhi app.
* @return a boolean stating whether the app get un-deployed or not.
*/
public static boolean unDeploy(ResourceNode node, String siddhiAppName) {
feign.Response resourceResponse = null;
try {
resourceResponse = ResourceServiceFactory.getResourceHttpsClient(Constants.PROTOCOL +
HTTPSClientUtil.generateURLHostPort(node.getHttpsInterface().getHost(),
String.valueOf(node.getHttpsInterface().getPort())),
node.getHttpsInterface().getUsername(), node.getHttpsInterface().getPassword())
.deleteSiddhiApp(siddhiAppName);
return resourceResponse.status() == 200;
} catch (feign.FeignException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error occurred while up-deploying Siddhi app from " + node, e);
}
return false;
} finally {
if (resourceResponse != null) {
resourceResponse.close();
}
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.sp.jobmanager.core
? locationHeader.substring(locationHeader.lastIndexOf('/') + 1) : null;
} else if (resourceResponse.status() == 409) {
resourceResponse.close();
resourceResponse = ResourceServiceFactory.getResourceHttpsClient(Constants.PROTOCOL +
HTTPSClientUtil.generateURLHostPort(node.getHttpsInterface().getHost(),
} finally {
if (resourceResponse != null) {
resourceResponse.close();
代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core
@Override
public RibbonResponse doWithRetry(RetryContext retryContext) throws IOException {
Request feignRequest = null;
//on retries the policy will choose the server and set it in the context
//extract the server and update the request being made
if (retryContext instanceof LoadBalancedRetryContext) {
ServiceInstance service = ((LoadBalancedRetryContext) retryContext).getServiceInstance();
if (service != null) {
feignRequest = ((RibbonRequest) request.replaceUri(reconstructURIWithServer(new Server(service.getHost(), service.getPort()), request.getUri()))).toRequest();
}
}
if (feignRequest == null) {
feignRequest = request.toRequest();
}
Response response = request.client().execute(feignRequest, options);
if (retryPolicy != null && retryPolicy.retryableStatusCode(response.status())) {
byte[] byteArray = response.body() == null ? new byte[]{} : StreamUtils.copyToByteArray(response.body().asInputStream());
response.close();
throw new RibbonResponseStatusCodeException(RetryableFeignLoadBalancer.this.clientName, response,
byteArray, request.getUri());
}
return new RibbonResponse(request.getUri(), response);
}
}, new LoadBalancedRecoveryCallback<RibbonResponse, Response>() {
代码示例来源:origin: spring-cloud/spring-cloud-openfeign
@Override
public RibbonResponse doWithRetry(RetryContext retryContext) throws IOException {
Request feignRequest = null;
//on retries the policy will choose the server and set it in the context
//extract the server and update the request being made
if (retryContext instanceof LoadBalancedRetryContext) {
ServiceInstance service = ((LoadBalancedRetryContext) retryContext).getServiceInstance();
if (service != null) {
feignRequest = ((RibbonRequest) request.replaceUri(reconstructURIWithServer(new Server(service.getHost(), service.getPort()), request.getUri()))).toRequest();
}
}
if (feignRequest == null) {
feignRequest = request.toRequest();
}
Response response = request.client().execute(feignRequest, options);
if (retryPolicy != null && retryPolicy.retryableStatusCode(response.status())) {
byte[] byteArray = response.body() == null ? new byte[]{} : StreamUtils.copyToByteArray(response.body().asInputStream());
response.close();
throw new RibbonResponseStatusCodeException(RetryableFeignLoadBalancer.this.clientName, response,
byteArray, request.getUri());
}
return new RibbonResponse(request.getUri(), response);
}
}, new LoadBalancedRecoveryCallback<RibbonResponse, Response>() {
内容来源于网络,如有侵权,请联系作者删除!