Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-364

Unnecessary cast to byte while scanning for first MIME boundary

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.2.11
    • 1.2.12
    • API
    • None

    Description

      In the class org.apache.axiom.attachments.Attachments line 237
      --->
      while (true) {
      int value;
      try {
      value = pushbackInStream.read();
      if ((byte) value == boundary[0]) {
      int boundaryIndex = 0;
      while ((boundaryIndex < boundary.length)
      && ((byte) value == boundary[boundaryIndex])) {
      value = pushbackInStream.read();
      if (value == -1)

      { throw new OMException( "Unexpected End of Stream while searching for first Mime Boundary"); }

      boundaryIndex++;
      }
      if (boundaryIndex == boundary.length)

      { // boundary found pushbackInStream.read(); break; }

      } else if ((byte) value == -1)

      { <--- this byte case is unnecessary, e.g. if the value is 255, after the cast from int to byte, then from byte to int, it will be finally equal to -1 throw new OMException( "Mime parts not found. Stream ended while searching for the boundary"); }

      } catch (IOException e1)

      { throw new OMException("Stream Error" + e1.toString(), e1); }

      }
      <---

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            veithen Andreas Veithen
            xuhaihong Haihong Xu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment