Skip to content

Commit

Permalink
code simplification, added further assertions for Coverity issue 72293
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Mar 4, 2016
1 parent 997f841 commit adc20ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Expand Up @@ -167,7 +167,9 @@ protected void setCreationTime(Instant creationTime) {
public ActiveLock lock(LockInfo reqLockInfo) throws DavException {
ActiveLock lock = super.lock(reqLockInfo);
if (!exists()) {
getCollection().addMember(this, new NullInputContext());
DavFolder parentFolder = getCollection();
assert parentFolder != null : "File always has a folder.";
parentFolder.addMember(this, new NullInputContext());
}
return lock;
}
Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
import org.apache.jackrabbit.webdav.property.PropEntry;
import org.cryptomator.filesystem.jackrabbit.FileSystemResourceLocator;
import org.cryptomator.filesystem.jackrabbit.FolderLocator;

abstract class DavNode<T extends FileSystemResourceLocator> implements DavResource {

Expand Down Expand Up @@ -187,18 +188,14 @@ public MultiStatusResponse alterProperties(List<? extends PropEntry> changeList)
}

@Override
public DavResource getCollection() {
public DavFolder getCollection() {
if (node.isRootLocation()) {
return null;
}

assert node.parent().isPresent() : "as my mom always sais: if it's not root, it has a parent";
final FileSystemResourceLocator parentPath = node.parent().get();
try {
return factory.createResource(parentPath, session);
} catch (DavException e) {
throw new IllegalStateException("Unable to get parent resource with path " + parentPath, e);
}
final FolderLocator parentPath = node.parent().get();
return factory.createFolder(parentPath, session);
}

@Override
Expand Down
Expand Up @@ -50,7 +50,7 @@ public DavResource createResource(DavResourceLocator locator, DavServletRequest
}

@Override
public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
public DavResource createResource(DavResourceLocator locator, DavSession session) {
if (locator instanceof FolderLocator) {
FolderLocator folder = (FolderLocator) locator;
return createFolder(folder, session);
Expand Down

0 comments on commit adc20ea

Please sign in to comment.