fix(yarn-query): 修复没有关闭的 close

This commit is contained in:
2023-05-04 14:31:17 +08:00
parent 0f6c2fa6e6
commit ec14ca244b

View File

@@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.service.yarn.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -42,8 +43,9 @@ public class JobServiceImpl implements JobService {
@Override
public ImmutableList<YarnApplication> list() throws JsonProcessingException {
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps");
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
return mapper.readValue(body, ApplicationsListResponse.class).getApps().getApp();
try (HttpResponse response = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute()) {
return mapper.readValue(response.body(), ApplicationsListResponse.class).getApps().getApp();
}
}
@Cacheable(value = "job-list", sync = true, key = "#{methodName+name}")
@@ -69,7 +71,8 @@ public class JobServiceImpl implements JobService {
@Override
public YarnApplication detail(String applicationId) throws JsonProcessingException {
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps/" + applicationId);
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
return mapper.readValue(body, ApplicationDetailResponse.class).getApp();
try (HttpResponse response = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute()) {
return mapper.readValue(response.body(), ApplicationDetailResponse.class).getApp();
}
}
}