Skip to content

Lock refresh crashes #13

@lscorcia

Description

@lscorcia

In WebDavSqlStoreItemLock, line 256, requestDocument gets instantiated as a new XmlDocument.
Later in WebDavLockMethodHandler, this empty document is used to retrieve some data and obviously fails.

From this comment, it seems that a valid XmlDocument is to be filled in by RefreshLock method:

//Refresh lock will ref us back the original XML document which was used to request this lock, from
//this we will grab the data we need to build the response to the lock refresh request.

So to fix this error I added the following lines after line 256 of file WebDavSqlStoreItemLock.cs:

var lockinfoNode = requestDocument.CreateElement("D", "lockinfo", "DAV:");

var lockscopeNode = requestDocument.CreateElement("D", "lockscope", "DAV:");
if (inst.LockScope == WebDavLockScope.Exclusive)
	lockscopeNode.AppendChild(requestDocument.CreateElement("D", "exclusive", "DAV:"));
else
	lockscopeNode.AppendChild(requestDocument.CreateElement("D", "shared", "DAV:"));

lockinfoNode.AppendChild(lockscopeNode);

var locktypeNode = requestDocument.CreateElement("D", "locktype", "DAV:");
if (inst.LockType == WebDavLockType.Write)
	locktypeNode.AppendChild(requestDocument.CreateElement("D", "write", "DAV:"));

lockinfoNode.AppendChild(locktypeNode);

var lockownerNode = requestDocument.CreateElement("D", "owner", "DAV:");
lockownerNode.InnerText = info.OwnerId.ToString();

lockinfoNode.AppendChild(lockownerNode);

requestDocument.AppendChild(lockinfoNode);

It is pretty crude but does the job and fixes litmus test locks#8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions