2 Replies Latest reply on Jun 19, 2008 5:28 AM by andrei_exadel

    FileUpload 100% CPU, infinite loop

      Hello,

      FileUpload (3.2.1 GA) has infinite loop in the following code:

      org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:355)

      InputStream input = request.getInputStream();
       if (!shouldStop) {
      
       int read = input.read(buffer);
       int pos = 0;
      
       Param p = null;
      
       while (read != -1) {
       for (int i = 0; i < read; i++) {
      


      I found this problem in production, dumping threads when CPU was 100% note that one thread working for a long time

      org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:355)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:330)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)

      Couldn't reproduce.

      Best regards,
      Ian

        • 1. Re: FileUpload 100% CPU, infinite loop

          I think this is serious problem, because it happened again and i'm 100% sure that this is because of the code above, Tomcat loads CPU 100% and Richfaces team should open JIRA if it is still not open.

          Probably InputStream in Linux not always return -1 on read() in case of stream is closed, but this should be a very strange Java bug.

          Please verify this code and as a strut you can include a increment counter to return from the cycle.

          Thanks and awating an answer from Richfaces team.

          Ian

          • 2. Re: FileUpload 100% CPU, infinite loop

            I posted the issue in JIRA: http://jira.jboss.com/jira/browse/RF-3746.

            I think this is very hard to reproduce.
            But I plan to make some changes in MultipartRequest code to avoid infinitive loop in any possible case.