Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-33428

java.lang.ArrayIndexOutOfBoundsException in Webservices SakaiScript addNewToolToAllWorkspaces()

    Details

    • Type: Bug
    • Status: RESOLVED
    • Priority: Major
    • Resolution: Incorporated
    • Affects Version/s: 11.4, 12.0, 19.0
    • Fix Version/s: 19.0
    • Component/s: Web Services
    • Labels:
    • 12 status:
      Please Merge
    • Test Plan:
      Hide

      Please add a Test Plan here.

      Show
      Please add a Test Plan here.

      Description

      java.lang.ArrayIndexOutOfBoundsException in Webservices SakaiScript.jws addNewToolToAllWorkspaces() when position == numpages

       Steps to reproduce:

      • SakaiScript.jws?wsdl
      • call addNewToolToAllWorkspaces() with a 'reasonable' paeg position like 10
      • $soap->addNewToolToAllWorkspaces($session,'sakai.iframe.mytool', 'My Tool', 'My Tool', 0, 10, 0);
      • an error occurs:

      java.lang.ArrayIndexOutOfBoundsException : 10 > 9

       

      //KNL-250, SAK-16819 - if position too large, will throw ArrayIndexOutOfBoundsException
      //deal with this here and just set to the number of pages - 1 so its at the bottom.
      int numPages = siteEdit.getPages().size();
      if(position > numPages) {
      position = numPages-1;
      }
      
      int pagePosition = sitePageEdit.getPosition();
      if (pagePosition != position)
      {
      // set the page position
      LOG.debug("Page:" + sitePageEdit + " position=" + sitePageEdit.getPosition() + " position_new=" + position);
      sitePageEdit.setPosition(position);
      siteEdit.setCustomPageOrdered(true);
      siteService.save(siteEdit);
      LOG.debug("Page moved");
      }

       

      I belive it fails because the site's tool position is based on 0-index when you do 

      sitePageEdit.setPosition(position);

      but when it checks

      if(position > numPages) {
        position = numPages-1;
      }

      if the position == numpages, e.g. if (10 == 10) the position isn't decremented and when the position is set to 10, it fails becaue the real index is 9

      So I think changing 

      - if(position > numPages) {
      + if(position >= numPages) {

      ought to fix this problem

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  steve.swinsburg Steve Swinsburg
                  Reporter:
                  austinUH Austin
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Git Source Code