You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michael Gannon (JIRA)" <ji...@apache.org> on 2008/12/03 05:08:44 UTC

[jira] Created: (JCI-58) EclipseJavaCompiler fails to close inputstream

EclipseJavaCompiler fails to close inputstream
----------------------------------------------

                 Key: JCI-58
                 URL: https://issues.apache.org/jira/browse/JCI-58
             Project: Commons JCI
          Issue Type: Bug
          Components: compiler eclipse
    Affects Versions: 1.1
         Environment: Java 1.5, WinXP
            Reporter: Michael Gannon


The method isPackage(final String pClaszzName) calls classLoader.getResourceAsStream() but fails to close the stream if it is opened successfully. On Windows this means all other file access to this file is not permitted. The inputstream should be closed. Here is a replacement method:

            private boolean isPackage( final String pClazzName ) {

                final InputStream is = pClassLoader.getResourceAsStream(ConversionUtils.convertClassToResourcePath(pClazzName));
                if (is != null) {
                    log.debug("found the class for " + pClazzName + "- no package");
                    try {
                        is.close();
                    } catch (final IOException ie) {
                        log.error("could not close input stream", ie);
                    } 
                    return false;
                }


                // FIXME: this should not be tied to the extension
                final String source = pClazzName.replace('.', '/') + ".java";
                if (pReader.isAvailable(source)) {
                    log.debug("found the source " + source + " for " + pClazzName + " - no package ");
                    return false;
                }

                return true;
            }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JCI-58) EclipseJavaCompiler fails to close inputstream

Posted by "Laszlo Sas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCI-58?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12689149#action_12689149 ] 

Laszlo Sas commented on JCI-58:
-------------------------------

On Windows it's a critical bug. The memory leaks.
Thanks for the fix.

> EclipseJavaCompiler fails to close inputstream
> ----------------------------------------------
>
>                 Key: JCI-58
>                 URL: https://issues.apache.org/jira/browse/JCI-58
>             Project: Commons JCI
>          Issue Type: Bug
>          Components: compiler eclipse
>    Affects Versions: 1.1
>         Environment: Java 1.5, WinXP
>            Reporter: Michael Gannon
>
> The method isPackage(final String pClaszzName) calls classLoader.getResourceAsStream() but fails to close the stream if it is opened successfully. On Windows this means all other file access to this file is not permitted. The inputstream should be closed. Here is a replacement method:
>             private boolean isPackage( final String pClazzName ) {
>                 final InputStream is = pClassLoader.getResourceAsStream(ConversionUtils.convertClassToResourcePath(pClazzName));
>                 if (is != null) {
>                     log.debug("found the class for " + pClazzName + "- no package");
>                     try {
>                         is.close();
>                     } catch (final IOException ie) {
>                         log.error("could not close input stream", ie);
>                     } 
>                     return false;
>                 }
>                 // FIXME: this should not be tied to the extension
>                 final String source = pClazzName.replace('.', '/') + ".java";
>                 if (pReader.isAvailable(source)) {
>                     log.debug("found the source " + source + " for " + pClazzName + " - no package ");
>                     return false;
>                 }
>                 return true;
>             }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.