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

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

    Details

      Description

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

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tfromm Thomas Fromm
                Reporter:
                vasilievip Ivan Vasyliev
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: