Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-1397

MTOM attachment Streaming -problem when deal with multiple attachment- got NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • None
    • None
    • om
    • None

    Description

      I have got NPE when iterating multiple attachment using API method isReadyToGetNextStream() and
      getNextStream()
      java.lang.NullPointerException
      at org.apache.axiom.attachments.MultipartAttachmentStreams.getNextStream(MultipartAttachmentStreams.java:63)

      It is seem as even stream comes to end ,the boolean value of isReadyToGetNextStream() is true;

      Java Code

      Attachments attachments = null;

      if (this.opcts != null)

      { attachments = (Attachments) this.opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getProperty(MTOMConstants.ATTACHMENTS); }

      else

      { throw new AxisFault("Message context not set/Attachments not set"); }

      // Get image data
      IncomingAttachmentStreams streams = attachments.getIncomingAttachmentStreams();
      int i = 0;
      while (streams.isReadyToGetNextStream()) {

      OMElement file = fac.createOMElement("file" + (i + 1), null);
      IncomingAttachmentInputStream stream = streams.getNextStream();
      if(stream !=null)

      { byte[] data = IOUtils.getStreamAsByteArray(stream); //setting response OMText omText = fac.createOMText(new DataHandler(new ByteArrayDataSource(data)), true); file.addChild(omText); elem.addChild(file); }

      }

      }

      Attachments

        Activity

          People

            thilina Nanayakkara Kuruppuge Thilina Gunarathne
            indika Indika Kumara
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: