Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3984

Overriding of processResponseBody, and using getResponseBodyAsDocument(), causes a NullPointerException

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.12.1
    • None
    • jackrabbit-webdav
    • None
    • Oracle_JVM 1.8.0_91, jackrabbit-webdav-2.12.1

    Description

      So, since, WebDAV-Sync Report Method RFC 6578 hasn't been included yet. I decided to go along and make a method, which extends ReportMethod. I had to override processResponseBody in DavMethodBase because RFC 6578 overrides the MultiStatus element to include other than MultiStatusResponses but also a sync token. For Example:

      <D:multistatus>
      <D:response>...</D:response>
      <D:response>...</D:response>
      <D:sync-token> ... </D:sync-token>
      </D:multistatus>

      To parse I need to getResponseBodyasDocument. But problem lies in the fact that it can't be used more than once, by definition. Thus, I have to override the Sync Method class to also include a private multistatus variable, where as, if this wasn't done and DavMethodBase.processResponseBody was used, then it would yield a NullPointerException.

      The solution to this, I found is that in the function DavMethodBase.getResponseBodyasDocument has a check for responseDocument, but responseDocument is never set after reading

      DavMethodBase.java

      getResponseBodyasDocument(){
      if (responseDocument != null)

      Unknown macro: { return responseDocument; // response has already been read }

      ....
      ....
      InputStream in = getResponseBodyAsStream();
      if (in != null) {
      // read response and try to build a xml document
      try {
      return DomUtil.parseDocument(in);

      which simply put returns the document without setting it. A minor update to this solution would be:

      DavMethodBase.java

      getResponseBodyasDocument(){
      if (responseDocument != null)

      Unknown macro: { return responseDocument; // response has already been read }

      ....
      ....
      InputStream in = getResponseBodyAsStream();
      if (in != null) {
      // read response and try to build a xml document
      try {
      responseDocument = DomUtil.parseDocument(in);
      return responseDocument;

      Hopefully, this makes sense and is updated. in DavMethodBase#getResponseBodyasDocument

      Attachments

        Activity

          People

            Unassigned Unassigned
            ankushmishra Ankush Mishra
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: