Source:
<code>public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) { HttpParam httpParam = getHttpParam(jobConfig.getProps()); HttpURLConnection connection = null; <START> BufferedReader bufferedReader = null; <END> try { URL realUrl = new URL(httpParam.getUrl()); connection = (HttpURLConnection) realUrl.openConnection(); connection.setRequestMethod(httpParam.getMethod()); connection.setDoOutput(httpParam.isPostMethod()); connection.setConnectTimeout(httpParam.getConnectTimeout()); connection.setReadTimeout(httpParam.getReadTimeout()); if (!Strings.isNullOrEmpty(httpParam.getContentType())) { connection.setRequestProperty("Content-Type", httpParam.getContentType()); } connection.connect(); String data = httpParam.getData(); if (httpParam.isPostMethod() && !Strings.isNullOrEmpty(data)) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); if (httpParam.isEnableTransparentShardingContext()) { StringBuilder builder = new StringBuilder(data); builder.append("&").append(HttpJobProperties.TRANSPARENT_SHARDING_CONTEXT_KEY); builder.append("=").append(GsonFactory.getGson().toJson(shardingContext)); data = builder.toString(); } dataOutputStream.write(data.getBytes(StandardCharsets.UTF_8)); dataOutputStream.flush(); dataOutputStream.close(); } int code = connection.getResponseCode(); if (code != 200) { throw new JobExecutionException("Http job %s executed with response code %d", jobConfig.getJobName(), code); } bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); StringBuilder result = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { result.append(line); } log.debug("http job execute result : {}", result.toString()); } catch (IOException ex) { throw new JobExecutionException(ex); } finally { try { if (bufferedReader != null) { bufferedReader.close(); } if (connection != null) { connection.disconnect(); } } catch (IOException ignore) { } } }</code><technical_language>try resource handle close</technical_language>

Target:
public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) { HttpParam httpParam = getHttpParam(jobConfig.getProps()); HttpURLConnection connection = null; BufferedReader bufferedReader = null; try { URL url = new URL(httpParam.getUrl()); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod(httpParam.getMethod()); connection.setDoOutput(true); connection.setConnectTimeout(httpParam.getConnectTimeout()); connection.setReadTimeout(httpParam.getReadTimeout()); if (!Strings.isNullOrEmpty(httpParam.getContentType())) { connection.setRequestProperty("Content-Type", httpParam.getContentType()); } connection.connect(); String data = httpParam.getData(); if (!Strings.isNullOrEmpty(data)) { StringBuilder builder = new StringBuilder(data); builder.append("&").append(HttpJobProperties.TRANSPARENT_SHARDING_CONTEXT_KEY); builder.append("=").append(GsonFactory.getGson().toJson(shardingContext)); data = builder.toString(); DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes(StandardCharsets.UTF_8)); dataOutputStream.flush(); dataOutputStream.close(); } int code = connection.getResponseCode(); if (code != 200) { throw new JobExecutionException("Http job %s executed with response code %d", jobConfig.getJobName(), code); } bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); StringBuilder result = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { result.append(line); } log.debug("http job execute result : {}", result.toString()); } catch (final IOException ex) { throw new JobExecutionException(ex); } finally { try { if (null != bufferedReader) { bufferedReader.close(); } if (null != connection) { connection.disconnect(); } } catch (final IOException ignore) { } } }