Uploaded image for project: 'Commons JCI'
  1. Commons JCI
  2. JCI-58

EclipseJavaCompiler fails to close inputstream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1
    • 1.1
    • compiler eclipse
    • None
    • Java 1.5, WinXP

    Description

      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;
          }
      

      Attachments

        Activity

          People

            tcurdt Torsten Curdt
            mgannon Michael Gannon
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: