Skip to content

Commit

Permalink
DataSourceUrlResolver.resolve(String, boolean) leaks InputStreams
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 16, 2023
1 parent 6406075 commit d251d20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<action dev="ggregory" type="fix" due-to="Loki-Afro, Gary Gregory">Migrate to JUnit 5 #186.</action>
<action issue="EMAIL-174" type="fix" due-to="Vegard Stuen">Bump javax.mail dependency to 1.6.1, so that i18n is supported for email addresses.</action>
<action dev="ggregory" type="fix" due-to="Loki-Afro, Gary Gregory">Add missing getters and setters in EMail and subclasses; deprecate access to protected instance variables.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">DataSourceUrlResolver.resolve(String, boolean) leaks InputStreams.</action>
<!-- ADD -->
<action type="add" due-to="Dependabot" dev="ggregory">Add github/codeql-action #75.</action>
<action type="add" due-to="Gary Gregory" dev="ggregory">Add Maven plugin JapiCmp and remove Clirr.</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.commons.mail.resolver;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

Expand Down Expand Up @@ -99,7 +100,10 @@ public DataSource resolve(final String resourceLocation, final boolean isLenient
try {
if (!isCid(resourceLocation)) {
result = new URLDataSource(createUrl(resourceLocation));
result.getInputStream();
// validate we can read.
try (InputStream inputStream = result.getInputStream()) {
inputStream.read();
}
}
return result;
} catch (final IOException e) {
Expand Down

0 comments on commit d251d20

Please sign in to comment.