This is an automated email from the ASF dual-hosted git repository. rgoers pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/flume.git
The following commit(s) were added to refs/heads/trunk by this push: new 2386e39 Disconnect the connection 2386e39 is described below commit 2386e39cf8dc4c126909a4e9b53f19cec166e63d Author: Ralph Goers <rgo...@apache.org> AuthorDate: Sun Jan 30 17:16:40 2022 -0700 Disconnect the connection --- .../apache/flume/node/HttpConfigurationSource.java | 61 ++++++++++++---------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java b/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java index 2fd9f0e..a877d85 100644 --- a/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java +++ b/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java @@ -97,39 +97,42 @@ public class HttpConfigurationSource implements ConfigurationSource { HttpURLConnection connection = UrlConnectionFactory.createConnection(uri.toURL(), authorizationProvider, lastModified, verifyHost); connection.connect(); - - int code = connection.getResponseCode(); - switch (code) { - case NOT_MODIFIED: { - LOGGER.debug("Configuration Not Modified"); - return false; - } - case OK: { - try (InputStream is = connection.getInputStream()) { - lastModified = connection.getLastModified(); - LOGGER.debug("Content was modified for {}. lastModified: {}", uri.toString(), lastModified); - data = IOUtils.toByteArray(is); - return true; - } catch (final IOException e) { - try (InputStream es = connection.getErrorStream()) { - LOGGER.info("Error accessing configuration at {}: {}", uri, readStream(es)); - } catch (final IOException ioe) { - LOGGER.error("Error accessing configuration at {}: {}", uri, e.getMessage()); + try { + int code = connection.getResponseCode(); + switch (code) { + case NOT_MODIFIED: { + LOGGER.debug("Configuration Not Modified"); + return false; + } + case OK: { + try (InputStream is = connection.getInputStream()) { + lastModified = connection.getLastModified(); + LOGGER.debug("Content was modified for {}. lastModified: {}", uri.toString(), lastModified); + data = IOUtils.toByteArray(is); + return true; + } catch (final IOException e) { + try (InputStream es = connection.getErrorStream()) { + LOGGER.info("Error accessing configuration at {}: {}", uri, readStream(es)); + } catch (final IOException ioe) { + LOGGER.error("Error accessing configuration at {}: {}", uri, e.getMessage()); + } + throw new ConfigurationException("Unable to access " + uri.toString(), e); } - throw new ConfigurationException("Unable to access " + uri.toString(), e); } - } - case NOT_AUTHORIZED: { - throw new ConfigurationException("Authorization failed"); - } - default: { - if (code < 0) { - LOGGER.info("Invalid response code returned"); - } else { - LOGGER.info("Unexpected response code returned {}", code); + case NOT_AUTHORIZED: { + throw new ConfigurationException("Authorization failed"); + } + default: { + if (code < 0) { + LOGGER.info("Invalid response code returned"); + } else { + LOGGER.info("Unexpected response code returned {}", code); + } + return false; } - return false; } + } finally { + connection.disconnect(); } } catch (IOException e) { LOGGER.warn("Error accessing {}: {}", uri.toString(), e.getMessage());