This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git
The following commit(s) were added to refs/heads/master by this push:
new f76f06c Use try-with-resources
f76f06c is described below
commit f76f06cf29c794e90e476c3ea12950b96e56b195
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jun 9 08:35:58 2022 -0400
Use try-with-resources
---
.../org/apache/commons/mail/ImageHtmlEmailTest.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
index 5f52098..cee8378 100644
--- a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
+++ b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
@@ -478,17 +478,18 @@ public class ImageHtmlEmailTest extends HtmlEmailTest {
}
private String loadUrlContent(final URL url) throws IOException {
- final InputStream stream = url.openStream();
- final StringBuilder html = new StringBuilder();
- try {
- final List<String> lines = IOUtils.readLines(stream);
- for (final String line : lines) {
- html.append(line).append("\n");
+ try (final InputStream stream = url.openStream()) {
+ final StringBuilder html = new StringBuilder();
+ try {
+ final List<String> lines = IOUtils.readLines(stream);
+ for (final String line : lines) {
+ html.append(line).append("\n");
+ }
+ } finally {
+ stream.close();
}
- } finally {
- stream.close();
+ return html.toString();
}
- return html.toString();
}
private static final class MockDataSourceClassPathResolver extends
DataSourceClassPathResolver {