Program: 113488
Project: 113488
Buggy source:
@Override public void startRequest(MRCRequest rq) throws Throwable {
  if (master.getReplMasterUUID() != null && !master.getReplMasterUUID().equals(master.getConfig().getUUID().toString()))   throw new DatabaseException(ExceptionType.REDIRECT);
  final XCap xcap=(XCap)rq.getRequestArgs();
  Capability writeCap=new Capability(xcap,master.getConfig().getCapabilitySecret());
  if (!writeCap.hasValidSignature())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,writeCap + "String_Node_Str");
  if (writeCap.hasExpired())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,writeCap + "String_Node_Str");
  if ((writeCap.getAccessMode() & (FileAccessManager.O_WRONLY | FileAccessManager.O_RDWR | FileAccessManager.O_TRUNC)) == 0)   throw new UserException(POSIXErrno.POSIX_ERROR_EACCES,writeCap + "String_Node_Str");
  GlobalFileIdResolver idRes=new GlobalFileIdResolver(writeCap.getFileId());
  StorageManager sMan=master.getVolumeManager().getStorageManager(idRes.getVolumeId());
  FileMetadata file=sMan.getMetadata(idRes.getLocalFileId());
  if (file == null)   throw new UserException(POSIXErrno.POSIX_ERROR_ENOENT,"String_Node_Str" + writeCap.getFileId() + "String_Node_Str");
  AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
  int newEpoch=file.getIssuedEpoch() + 1;
  file.setIssuedEpoch(newEpoch);
  sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
  Capability truncCap=new Capability(writeCap.getFileId(),writeCap.getAccessMode() | FileAccessManager.O_TRUNC,master.getConfig().getCapabilityTimeout(),TimeSync.getGlobalTime() / 1000 + master.getConfig().getCapabilityTimeout(),((InetSocketAddress)rq.getRPCRequest().getSenderAddress()).getAddress().getHostAddress(),newEpoch,false,!sMan.getVolumeInfo().isSnapshotsEnabled() ? SnapConfig.SNAP_CONFIG_SNAPS_DISABLED : sMan.getVolumeInfo().isSnapVolume() ? SnapConfig.SNAP_CONFIG_ACCESS_SNAP : SnapConfig.SNAP_CONFIG_ACCESS_CURRENT,sMan.getVolumeInfo().getCreationTime(),master.getConfig().getCapabilitySecret());
  rq.setResponse(truncCap.getXCap());
  update.execute();
}

Fixed version (ground truth):
@Override public void startRequest(MRCRequest rq) throws Throwable {
  if (master.getReplMasterUUID() != null && !master.getReplMasterUUID().equals(master.getConfig().getUUID().toString()))   throw new DatabaseException(ExceptionType.REDIRECT);
  final XCap xcap=(XCap)rq.getRequestArgs();
  Capability writeCap=new Capability(xcap,master.getConfig().getCapabilitySecret());
  if (!writeCap.hasValidSignature())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,writeCap + "String_Node_Str");
  if (writeCap.hasExpired())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,writeCap + "String_Node_Str");
  if ((writeCap.getAccessMode() & (FileAccessManager.O_WRONLY | FileAccessManager.O_RDWR | FileAccessManager.O_TRUNC)) == 0)   throw new UserException(POSIXErrno.POSIX_ERROR_EACCES,writeCap + "String_Node_Str");
  GlobalFileIdResolver idRes=new GlobalFileIdResolver(writeCap.getFileId());
  StorageManager sMan=master.getVolumeManager().getStorageManager(idRes.getVolumeId());
  FileMetadata file=sMan.getMetadata(idRes.getLocalFileId());
  if (file == null)   throw new UserException(POSIXErrno.POSIX_ERROR_ENOENT,"String_Node_Str" + writeCap.getFileId() + "String_Node_Str");
  AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
  int newEpoch=file.getIssuedEpoch() + 1;
  file.setIssuedEpoch(newEpoch);
  sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
  Capability truncCap=new Capability(writeCap.getFileId(),writeCap.getAccessMode() | FileAccessManager.O_TRUNC,master.getConfig().getCapabilityTimeout(),TimeSync.getGlobalTime() / 1000 + master.getConfig().getCapabilityTimeout(),((InetSocketAddress)rq.getRPCRequest().getSenderAddress()).getAddress().getHostAddress(),newEpoch,writeCap.isReplicateOnClose(),!sMan.getVolumeInfo().isSnapshotsEnabled() ? SnapConfig.SNAP_CONFIG_SNAPS_DISABLED : sMan.getVolumeInfo().isSnapVolume() ? SnapConfig.SNAP_CONFIG_ACCESS_SNAP : SnapConfig.SNAP_CONFIG_ACCESS_CURRENT,sMan.getVolumeInfo().getCreationTime(),master.getConfig().getCapabilitySecret());
  rq.setResponse(truncCap.getXCap());
  update.execute();
}