You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2014/09/30 14:08:10 UTC
svn commit: r1628409 - in /commons/proper/bcel/trunk/src: changes/changes.xml
main/java/org/apache/bcel/util/ClassLoaderRepository.java
Author: ggregory
Date: Tue Sep 30 12:08:10 2014
New Revision: 1628409
URL: http://svn.apache.org/r1628409
Log:
[BCEL-181] org.apache.bcel.util.ClassLoaderRepository.loadClass(String) leaks input streams.
Modified:
commons/proper/bcel/trunk/src/changes/changes.xml
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
Modified: commons/proper/bcel/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/changes/changes.xml?rev=1628409&r1=1628408&r2=1628409&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/changes/changes.xml (original)
+++ commons/proper/bcel/trunk/src/changes/changes.xml Tue Sep 30 12:08:10 2014
@@ -63,6 +63,9 @@ The <action> type attribute can be add,u
<body>
<release version="6.0" date="TBA" description="Major release with Java 7 and 8 support">
+ <action issue="BCEL-181" type="fix" dev="ggregory">
+ org.apache.bcel.util.ClassLoaderRepository.loadClass(String) leaks input streams.
+ </action>
<action issue="BCEL-76" type="update">
Add parent type processing for ClassPath class.
</action>
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java?rev=1628409&r1=1628408&r2=1628409&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java Tue Sep 30 12:08:10 2014
@@ -88,10 +88,14 @@ public class ClassLoaderRepository imple
if (is == null) {
throw new ClassNotFoundException(className + " not found.");
}
- ClassParser parser = new ClassParser(is, className);
- RC = parser.parse();
- storeClass(RC);
- return RC;
+ try {
+ ClassParser parser = new ClassParser(is, className);
+ RC = parser.parse();
+ storeClass(RC);
+ return RC;
+ } finally {
+ is.close();
+ }
} catch (IOException e) {
throw new ClassNotFoundException(className + " not found: " + e, e);
}
Re: svn commit: r1628409 - in /commons/proper/bcel/trunk/src: changes/changes.xml
main/java/org/apache/bcel/util/ClassLoaderRepository.java
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 30/09/2014 15:06, Mark Thomas a écrit :
> I agree with Gary on this point. The file isn't closed because the
> "fileOwned" flag is false.
>
> Gary's patch looks correct to me.
Thank you for double checking, I looked quickly and picked the wrong
constructor.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1628409 - in /commons/proper/bcel/trunk/src: changes/changes.xml
main/java/org/apache/bcel/util/ClassLoaderRepository.java
Posted by Mark Thomas <ma...@apache.org>.
On 30/09/2014 14:02, Gary Gregory wrote:
> On Tue, Sep 30, 2014 at 8:10 AM, Emmanuel Bourg <eb...@apache.org> wrote:
>
>> Le 30/09/2014 14:08, ggregory@apache.org a écrit :
>>
>>> Modified:
>> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
>>> URL:
>> http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java?rev=1628409&r1=1628408&r2=1628409&view=diff
>>>
>> ==============================================================================
>>> ---
>> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
>> (original)
>>> +++
>> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
>> Tue Sep 30 12:08:10 2014
>>> @@ -88,10 +88,14 @@ public class ClassLoaderRepository imple
>>> if (is == null) {
>>> throw new ClassNotFoundException(className + " not
>> found.");
>>> }
>>> - ClassParser parser = new ClassParser(is, className);
>>> - RC = parser.parse();
>>> - storeClass(RC);
>>> - return RC;
>>> + try {
>>> + ClassParser parser = new ClassParser(is, className);
>>> + RC = parser.parse();
>>> + storeClass(RC);
>>> + return RC;
>>> + } finally {
>>> + is.close();
>>> + }
>>> } catch (IOException e) {
>>> throw new ClassNotFoundException(className + " not found: "
>> + e, e);
>>> }
>>>
>>>
>>
>> This is not necessary, the stream is already closed at the end of the
>> parse() method.
>>
>
> No it is not.
I agree with Gary on this point. The file isn't closed because the
"fileOwned" flag is false.
Gary's patch looks correct to me.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1628409 - in /commons/proper/bcel/trunk/src:
changes/changes.xml main/java/org/apache/bcel/util/ClassLoaderRepository.java
Posted by Gary Gregory <ga...@gmail.com>.
On Tue, Sep 30, 2014 at 8:10 AM, Emmanuel Bourg <eb...@apache.org> wrote:
> Le 30/09/2014 14:08, ggregory@apache.org a écrit :
>
> > Modified:
> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java?rev=1628409&r1=1628408&r2=1628409&view=diff
> >
> ==============================================================================
> > ---
> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
> (original)
> > +++
> commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
> Tue Sep 30 12:08:10 2014
> > @@ -88,10 +88,14 @@ public class ClassLoaderRepository imple
> > if (is == null) {
> > throw new ClassNotFoundException(className + " not
> found.");
> > }
> > - ClassParser parser = new ClassParser(is, className);
> > - RC = parser.parse();
> > - storeClass(RC);
> > - return RC;
> > + try {
> > + ClassParser parser = new ClassParser(is, className);
> > + RC = parser.parse();
> > + storeClass(RC);
> > + return RC;
> > + } finally {
> > + is.close();
> > + }
> > } catch (IOException e) {
> > throw new ClassNotFoundException(className + " not found: "
> + e, e);
> > }
> >
> >
>
> This is not necessary, the stream is already closed at the end of the
> parse() method.
>
No it is not.
Gary
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: svn commit: r1628409 - in /commons/proper/bcel/trunk/src: changes/changes.xml
main/java/org/apache/bcel/util/ClassLoaderRepository.java
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 30/09/2014 14:08, ggregory@apache.org a écrit :
> Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java
> URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java?rev=1628409&r1=1628408&r2=1628409&view=diff
> ==============================================================================
> --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java (original)
> +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassLoaderRepository.java Tue Sep 30 12:08:10 2014
> @@ -88,10 +88,14 @@ public class ClassLoaderRepository imple
> if (is == null) {
> throw new ClassNotFoundException(className + " not found.");
> }
> - ClassParser parser = new ClassParser(is, className);
> - RC = parser.parse();
> - storeClass(RC);
> - return RC;
> + try {
> + ClassParser parser = new ClassParser(is, className);
> + RC = parser.parse();
> + storeClass(RC);
> + return RC;
> + } finally {
> + is.close();
> + }
> } catch (IOException e) {
> throw new ClassNotFoundException(className + " not found: " + e, e);
> }
>
>
This is not necessary, the stream is already closed at the end of the
parse() method.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org