NullPointer touching file in webdav mounted folder 6.1.2

K Boyce, modified 12 Years ago. New Member Posts: 17 Join Date: 6/3/07 Recent Posts
In liferay 6.1.2 GA3 I'm getting following error when touching a non existent file in a mounted webdav folder

Caused by: java.lang.NullPointerException
at com.liferay.compat.hook.webdav.CompatDLWebDAVStorageImpl.isInstanceOfDLFileEntryResourceImpl(CompatDLWebDAVStorageImpl.java:299)
at com.liferay.compat.hook.webdav.CompatDLWebDAVStorageImpl.getResource(CompatDLWebDAVStorageImpl.java:77)
at com.liferay.compat.hook.webdav.CompatDLWebDAVStorageImpl.lockResource(CompatDLWebDAVStorageImpl.java:112)
at com.liferay.portal.webdav.methods.LockMethodImpl.doProcess(LockMethodImpl.java:127)
at com.liferay.portal.webdav.methods.LockMethodImpl.process(LockMethodImpl.java:51)
... 73 more


Seems to be in some kind of compatibility hook.

Debugging from webdav servlet it seems when I do a touch it calls

Folder folder = DLAppServiceUtil.getFolder(
webDavRequest.getGroupId(), parentFolderId, name);

in DLWebDAVStorageImpl
and it throws a NoSuchFolderException() since it's a new file...

in the exception it calls:
FileEntry fileEntry = DLAppServiceUtil.getFileEntry(
webDavRequest.getGroupId(), parentFolderId,
titleWithExtension);
which also throws NoSuchFileEntryException and returns null causing the above NullPointerException

but it's a new file so the resource doesn't exist so null seems correct to me and getResource should IMHO return null if that exception is thrown

As it is now exception is thrown and not caught in
Resource resource = getResource(webDAVRequest); in lockResource


I modified function as follows adding if (resource == null) check:
@Override
public Resource getResource(WebDAVRequest webDAVRequest)
throws WebDAVException {


Resource resource = super.getResource(webDAVRequest);

if (resource == null) {
return null;
}
if (isInstanceOfDLFileEntryResourceImpl(resource)) {
return toCompatResource(resource);
}

return resource;

}


That appears to fix issue