Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-49245

Please try to revise the Amazon S3 code to prevent possible deadlocks

    Details

      Description

      According to the following code, both the open and close statements are within the try block. However, input stream closing should always go in the finally block to ensure they are properly closed. Otherwise, if there is a failure to call S3Object.closeDataInputStream(), it will result in the connection never being released.
      @Override
      public void updateFile(
      long companyId, long repositoryId, String fileName,
      String newFileName)
      throws SystemException {
      try

      { ... for (S3Object oldS3Object : s3Objects) { ... FileUtil.write(tempFile, oldS3Object.getDataInputStream()); oldS3Object.closeDataInputStream(); InputStream is = new FileInputStream(tempFile); ... is.close(); FileUtil.delete(tempFile); }

      }
      catch (IOException ioe)

      { throw new SystemException(ioe); }

      catch (ServiceException se)

      { throw new SystemException(se); }

      }
      This issue cannot be reproduced and tested at our end.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lu.liu Lu Liu
              Reporter:
              david.zhang David Zhang (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 11 weeks, 6 days ago

                  Packages

                  Version Package
                  6.2.2 CE GA3
                  6.2.X EE
                  7.0.0 M2