You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Ankush Mishra (JIRA)" <ji...@apache.org> on 2016/06/05 02:21:59 UTC
[jira] [Updated] (JCR-3984) Overriding of processResponseBody, and
using getResponseBodyAsDocument(), causes a NullPointerException
[ https://issues.apache.org/jira/browse/JCR-3984?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ankush Mishra updated JCR-3984:
-------------------------------
Priority: Minor (was: Trivial)
> Overriding of processResponseBody, and using getResponseBodyAsDocument(), causes a NullPointerException
> -------------------------------------------------------------------------------------------------------
>
> Key: JCR-3984
> URL: https://issues.apache.org/jira/browse/JCR-3984
> Project: Jackrabbit Content Repository
> Issue Type: Improvement
> Components: jackrabbit-webdav
> Affects Versions: 2.12.1
> Environment: Oracle_JVM 1.8.0_91, jackrabbit-webdav-2.12.1
> Reporter: Ankush Mishra
> Priority: Minor
>
> 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:
> {quote}
> <D:multistatus>
> <D:response>...</D:response>
> <D:response>...</D:response>
> <D:sync-token> ... </D:sync-token>
> </D:multistatus>
> {quote}
> 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
> {quote}
> DavMethodBase.java
> getResponseBodyasDocument(){
> if (responseDocument != null) {
> 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);
> {quote}
> which simply put returns the document without setting it. A minor update to this solution would be:
> {quote}
> DavMethodBase.java
> getResponseBodyasDocument(){
> if (responseDocument != null) {
> 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;
> {quote}
> Hopefully, this makes sense and is updated. in DavMethodBase#getResponseBodyasDocument
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)