Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1562

modeshape-web-jcr-webdav: DefaultContentMapper.getResourceLength does not close InputStream

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 2.8.3.Final, 3.0.0.Beta2
    • 2.8.2.Final
    • Server
    • None

      This causing jvm to keep handlers and may cause issues.

      Correct implementation may be:

          public long getResourceLength(Node node) 
                 throws RepositoryException, IOException {
              InputStream is = null;
              long size = 0;
              int bytesRead;
              byte[] buff = new byte[255];
              try {
                  is = getResourceContent(node);
                  while (-1 != (bytesRead = is.read(buff, 0, 255))) {
                      size += bytesRead;
                  }
              } finally {
                  if (is != null) {
                      try {
                          is.close();
                      } catch (IOException e) {
                          e.printStackTrace();
                      }
                  }
              }
              return size;
          }
      

            tfromm_jira Thomas Fromm (Inactive)
            vasilievip_jira Ivan Vasyliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: