Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-17647 Clean up code via static code review sweep for 2.7
  3. SAK-17655

Assignments - Potential NPE's found by static code review sweep

    Details

    • Type: Sub-task
    • Status: CLOSED
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.7.0
    • Fix Version/s: 2.7.0
    • Component/s: Assignments
    • Labels:
      None
    • Environment:
      Static code review

      Description

      0]https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      This [line 4919] will always generate an NPE if ac==null
      if (ac == null && ac.getTypeOfSubmission() == Assignment.NON_ELECTRONIC_ASSIGNMENT_SUBMISSION)

      [1] org.sakaiproject.assignment.impl.AssignmentSupplementItemServiceImpl
      releaseDate can still be null and generate an NPE [line 594]
      rv = now.getTime() > releaseDate.getTime() && now.getTime() < retractDate.getTime();

      [2] org.sakaiproject.assignment.impl.BaseAssignmentService
      retVal can still be null and generate an NPE [line 898]
      M_log.debug(this + " ADD DUPLICATE ASSIGNMENT : LEAVING ADD DUPLICATE ASSIGNMENT WITH ID : "
      + retVal.getId());

      [3] org.sakaiproject.assignment.impl.BaseAssignmentServic
      retVal can still be null and generate an NPE [line 1785]
      M_log.debug(this + " LEAVING ADD DUPLICATE CONTENT WITH ID : " + retVal.getId());

      [4] org.sakaiproject.assignment.impl.BaseAssignmentServic
      Possible java.lang.NumberFormatException on [line 1757]

      if (maxGradePoint != null)

      { maxGradePoint = maxGradePoint + "0"; }

      }
      m_maxGradePoint = Integer.parseInt(maxGradePoint); <-- here if maxGradePoint == null

      [5] Same again on [line 7334]

      if (maxGradePoint != null)

      { maxGradePoint = maxGradePoint + "0"; }

      }
      m_maxGradePoint = Integer.parseInt(maxGradePoint);

      [6] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/DbAssignmentService.java
      You have a null check on [line 475 ] for site, but would be NPE earlier on [line 468]

      Member member = site.getMember(userId); <-- If site null then NPE
      if(member != null && member.isActive())
      {
      if (asgGroups != null)
      {
      // for group based assignment: check whether member is in any group if the assignment is for groups
      boolean inGroup = false;
      for (Iterator iAsgGroups=asgGroups.iterator(); site!=null && !inGroup && iAsgGroups.hasNext() <-- Checks site for Null

      [7,8] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java
      Please verify, Findbugs complains about
      Creates an empty zip file entry [line 4364,4387]
      The code calls putNextEntry(), immediately followed by a call to closeEntry(). This results in an empty ZipFile entry. The contents of the entry should be written to the ZipFile between the calls to putNextEntry() and closeEntry().

      String sSubAttachmentFolder = submittersName + rb.getString("download.submission.attachment") + "/";
      ZipEntry sSubAttachmentFolderEntry = new ZipEntry(sSubAttachmentFolder);
      out.putNextEntry(sSubAttachmentFolderEntry);
      out.closeEntry();
      // add all submission attachment into the submission attachment folder
      zipAttachments(out, submittersName, sSubAttachmentFolder, s.getSubmittedAttachments());

      [9] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/conversion/impl/AssignmentSubmissionAccess.java
      Please review method [line 474]

      public void check(SerializableSubmissionAccess sax2) throws Exception

      { StringBuilder sb = new StringBuilder(); }

      [10] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      [line 10953]
      If lines == Null then NPE
      for (int i = 3; i<lines.length; i++)

      [11] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      Message is checked for null later, but is null on [line 5541] will cause an NPE
      AnnouncementMessageHeaderEdit header = message.getAnnouncementHeaderEdit();

      [12] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      [line 8843] is NPE if t1==null
      if (t1 == null)

      { result = -1; }
      else if (t2 == null)
      { result = 1; }
      if (t1.before(t2)) <-- NPE if t1 == null
      { result = -1; }

      [13] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      Generating a hashtable for no purpose line 1417
      Hashtable assignments_submissions = new Hashtable();

      [14] https://source.sakaiproject.org/svn/assignment/tags/sakai-2.7.0-M2/assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
      Create a registry that is not used [line 11922]
      ResourceTypeRegistry registry = (ResourceTypeRegistry) ComponentManager.get("org.sakaiproject.content.api.ResourceTypeRegistry");

      [15] org.sakaiproject.assignment.tool.edirectingAssignmentEntityServlet
      Refeneces can still be null on [line 152] causing an NPE
      if (mine.m_references == null && m_references != null) return false;
      if (mine.m_references.isEmpty() && !m_references.isEmpty()) return false;

        Gliffy Diagrams

          Zeplin

            Attachments

              Activity

                People

                Assignee:
                zqian Zhen Qian
                Reporter:
                a.m.berg@uva.nl Alan Berg
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Git Integration