You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/04/17 16:56:26 UTC
[tomcat] branch 7.0.x updated: Fix resource leak on exception path
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new fdf8f00 Fix resource leak on exception path
fdf8f00 is described below
commit fdf8f00109e6c5a47dee9f83080a8b55433d57bf
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Apr 17 17:55:16 2019 +0100
Fix resource leak on exception path
Identified by Coverity scan
---
java/org/apache/naming/factory/LookupFactory.java | 8 ++++++++
webapps/docs/changelog.xml | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/java/org/apache/naming/factory/LookupFactory.java b/java/org/apache/naming/factory/LookupFactory.java
index 25094e1..ca5444b 100644
--- a/java/org/apache/naming/factory/LookupFactory.java
+++ b/java/org/apache/naming/factory/LookupFactory.java
@@ -134,6 +134,14 @@ public class LookupFactory implements ObjectFactory {
name, ref.getClassName(), lookupName, result.getClass().getName());
NamingException ne = new NamingException(msg);
log.warn(msg, ne);
+ // Close the resource we no longer need if we know how to do so
+ if (result instanceof AutoCloseable) {
+ try {
+ ((AutoCloseable) result).close();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
throw ne;
}
} finally {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 1f96dbe..367dcde 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -81,6 +81,10 @@
Fix a potential resource leak on an exception path when parsing JSP
files. Identified by Coverity scan. (markt)
</fix>
+ <fix>
+ Fix a potential resource leak when a JNDI lookup returns an object of an
+ in compatible class. Identified by Coverity scan. (markt)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] branch 7.0.x updated: Fix resource leak on exception
path
Posted by Rainer Jung <ra...@kippdata.de>.
Am 19.04.2019 um 00:27 schrieb Mark Thomas:
> On 18/04/2019 21:48, Rainer Jung wrote:
>> This results in a compiler error. See below for details.
>
> Whoops. Should be fixed now.
>
> Sorry about that.
NP.
Confirmed, compiles now.
Thanks and regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] branch 7.0.x updated: Fix resource leak on exception
path
Posted by Mark Thomas <ma...@apache.org>.
On 18/04/2019 21:48, Rainer Jung wrote:
> This results in a compiler error. See below for details.
Whoops. Should be fixed now.
Sorry about that.
Mark
>
> Am 17.04.2019 um 18:56 schrieb markt@apache.org:
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> markt pushed a commit to branch 7.0.x
>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>
>>
>> The following commit(s) were added to refs/heads/7.0.x by this push:
>> new fdf8f00 Fix resource leak on exception path
>> fdf8f00 is described below
>>
>> commit fdf8f00109e6c5a47dee9f83080a8b55433d57bf
>> Author: Mark Thomas <ma...@apache.org>
>> AuthorDate: Wed Apr 17 17:55:16 2019 +0100
>>
>> Fix resource leak on exception path
>> Identified by Coverity scan
>> ---
>> java/org/apache/naming/factory/LookupFactory.java | 8 ++++++++
>> webapps/docs/changelog.xml | 4 ++++
>> 2 files changed, 12 insertions(+)
>>
>> diff --git a/java/org/apache/naming/factory/LookupFactory.java
>> b/java/org/apache/naming/factory/LookupFactory.java
>> index 25094e1..ca5444b 100644
>> --- a/java/org/apache/naming/factory/LookupFactory.java
>> +++ b/java/org/apache/naming/factory/LookupFactory.java
>> @@ -134,6 +134,14 @@ public class LookupFactory implements
>> ObjectFactory {
>> name, ref.getClassName(), lookupName,
>> result.getClass().getName());
>> NamingException ne = new NamingException(msg);
>> log.warn(msg, ne);
>> + // Close the resource we no longer need if we
>> know how to do so
>> + if (result instanceof AutoCloseable) {
>> + try {
>> + ((AutoCloseable) result).close();
>> + } catch (Exception e) {
>> + // Ignore
>> + }
>> + }
>> throw ne;
>> }
>> } finally {
>
> compile-java6:
> ...
> [javac]
> /path/to/java/org/apache/naming/factory/LookupFactory.java:138: cannot
> find symbol
> [javac] symbol : class AutoCloseable
> [javac] location: class org.apache.naming.factory.LookupFactory
> [javac] if (result instanceof AutoCloseable) {
> [javac] ^
> [javac]
> /path/to/java/org/apache/naming/factory/LookupFactory.java:140: cannot
> find symbol
> [javac] symbol : class AutoCloseable
> [javac] location: class org.apache.naming.factory.LookupFactory
> [javac] ((AutoCloseable) result).close();
> [javac] ^
> ...
> [javac] 2 errors
> ...
>
> Regards,
>
> Rainer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] branch 7.0.x updated: Fix resource leak on exception
path
Posted by Rainer Jung <ra...@kippdata.de>.
This results in a compiler error. See below for details.
Am 17.04.2019 um 18:56 schrieb markt@apache.org:
> This is an automated email from the ASF dual-hosted git repository.
>
> markt pushed a commit to branch 7.0.x
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
>
> The following commit(s) were added to refs/heads/7.0.x by this push:
> new fdf8f00 Fix resource leak on exception path
> fdf8f00 is described below
>
> commit fdf8f00109e6c5a47dee9f83080a8b55433d57bf
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Wed Apr 17 17:55:16 2019 +0100
>
> Fix resource leak on exception path
>
> Identified by Coverity scan
> ---
> java/org/apache/naming/factory/LookupFactory.java | 8 ++++++++
> webapps/docs/changelog.xml | 4 ++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/java/org/apache/naming/factory/LookupFactory.java b/java/org/apache/naming/factory/LookupFactory.java
> index 25094e1..ca5444b 100644
> --- a/java/org/apache/naming/factory/LookupFactory.java
> +++ b/java/org/apache/naming/factory/LookupFactory.java
> @@ -134,6 +134,14 @@ public class LookupFactory implements ObjectFactory {
> name, ref.getClassName(), lookupName, result.getClass().getName());
> NamingException ne = new NamingException(msg);
> log.warn(msg, ne);
> + // Close the resource we no longer need if we know how to do so
> + if (result instanceof AutoCloseable) {
> + try {
> + ((AutoCloseable) result).close();
> + } catch (Exception e) {
> + // Ignore
> + }
> + }
> throw ne;
> }
> } finally {
compile-java6:
...
[javac]
/path/to/java/org/apache/naming/factory/LookupFactory.java:138: cannot
find symbol
[javac] symbol : class AutoCloseable
[javac] location: class org.apache.naming.factory.LookupFactory
[javac] if (result instanceof AutoCloseable) {
[javac] ^
[javac]
/path/to/java/org/apache/naming/factory/LookupFactory.java:140: cannot
find symbol
[javac] symbol : class AutoCloseable
[javac] location: class org.apache.naming.factory.LookupFactory
[javac] ((AutoCloseable) result).close();
[javac] ^
...
[javac] 2 errors
...
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org