Source:
private void prepareCursor(int maxBatchSize, String offsetField, String lastSourceOffset) { String stringOffset = ""; ObjectId objectIdOffset = null; Date dateOffset = null; if (null == cursor) { if (null == lastSourceOffset || lastSourceOffset.isEmpty()) { objectIdOffset = initialObjectId; stringOffset = initialId; dateOffset = initialDate; } else { if (configBean.offsetType == OffsetFieldType.STRING) stringOffset = lastSourceOffset; else if (configBean.offsetType == OffsetFieldType.OBJECTID) objectIdOffset = new ObjectId(lastSourceOffset); else if (configBean.offsetType == OffsetFieldType.DATE) { try { dateOffset = dateFormatter.parse(lastSourceOffset); } catch (ParseException ex) { LOG.error("Could not parse lastSourceOffset to date: {}", lastSourceOffset); } } } LOG.debug("Getting new cursor with params: {}", maxBatchSize, offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset); if (configBean.isCapped) { cursor = mongoCollection .find() .filter(Filters.gt( offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset )) .cursorType(CursorType.TailableAwait) .batchSize(maxBatchSize) .iterator(); } else { cursor = mongoCollection .find() .filter(Filters.gt( offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset )) .sort(Sorts.ascending(offsetField)) .cursorType(CursorType.NonTailable) .batchSize(maxBatchSize) .iterator(); } } }

Target:
private void prepareCursor(int maxBatchSize, String offsetField, String lastSourceOffset) throws StageException { String stringOffset = ""; ObjectId objectIdOffset = null; Date dateOffset = null; if (null == cursor) { if (null == lastSourceOffset || lastSourceOffset.isEmpty()) { objectIdOffset = initialObjectId; stringOffset = initialId; dateOffset = initialDate; } else { if (configBean.offsetType == OffsetFieldType.STRING) stringOffset = lastSourceOffset; else if (configBean.offsetType == OffsetFieldType.OBJECTID) objectIdOffset = new ObjectId(lastSourceOffset); else if (configBean.offsetType == OffsetFieldType.DATE) { try { dateOffset = dateFormatter.parse(lastSourceOffset); } catch (ParseException ex) { throw new StageException(Errors.MONGODB_21, lastSourceOffset); } } } LOG.debug("Getting new cursor with params: {}", maxBatchSize, offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset); if (configBean.isCapped) { cursor = mongoCollection .find() .filter(Filters.gt( offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset )) .cursorType(CursorType.TailableAwait) .batchSize(maxBatchSize) .iterator(); } else { cursor = mongoCollection .find() .filter(Filters.gt( offsetField, configBean.offsetType == OffsetFieldType.STRING ? stringOffset : configBean.offsetType == OffsetFieldType.OBJECTID ? objectIdOffset : dateOffset )) .sort(Sorts.ascending(offsetField)) .cursorType(CursorType.NonTailable) .batchSize(maxBatchSize) .iterator(); } } }