Source:
<code>private void queryDataForBuffer() throws Exception { <START> <END> buffer = new ArrayList<E>(); dataSet = new HashSet<E>(); SessionProvider sessionProvider = queryData_.isSystemSession() ? WCMCoreUtils.getSystemSessionProvider() : WCMCoreUtils.getUserSessionProvider(); Session session = sessionProvider.getSession(queryData_.getWorkSpace(), WCMCoreUtils.getRepository()); QueryManager queryManager = session.getWorkspace().getQueryManager(); Query query = queryManager.createQuery(queryData_.getQueryStatement(), queryData_.getLanguage_()); ((QueryImpl)query).setOffset(offset_); long prevSize = 0; int bufSize = bufferSize_; int offset = 0; int count = 0; int currentIndex=0; buffer.clear(); dataSet.clear(); while (true) { ((QueryImpl)query).setOffset(offset); ((QueryImpl)query).setLimit(bufSize); QueryResult queryResult = query.execute(); NodeIterator iter = queryResult.getNodes(); RowIterator rowIter = queryResult.getRows(); long size = iter.getSize(); while (iter.hasNext() && count < bufferSize_) { currentIndex++; Node newNode = iter.nextNode(); if (filter != null) { newNode = filter.filterNodeToDisplay(newNode); } if (newNode == null) { realOffset_++; } if (currentIndex<=realOffset_) { continue; } if (newNode != null && searchDataCreator != null) { Row newRow = rowIter.nextRow(); E data = searchDataCreator.createData(newNode, newRow); if (data != null && !dataSet.contains(data)) { buffer.add(data); dataSet.add(data); count ++; } } } if (count == bufferSize_) break; if (size == prevSize) break; offset += bufSize; bufSize = 2 * bufSize; prevSize = size; } }</code><technical_language>This case converted unit tests</technical_language>

Target:
private void queryDataForBuffer() throws Exception { buffer = new ArrayList<E>(); dataSet = new HashSet<E>(); SessionProvider sessionProvider = queryData_.isSystemSession() ? WCMCoreUtils.getSystemSessionProvider() : WCMCoreUtils.getUserSessionProvider(); Session session = sessionProvider.getSession(queryData_.getWorkSpace(), WCMCoreUtils.getRepository()); QueryManager queryManager = session.getWorkspace().getQueryManager(); Query query = queryManager.createQuery(queryData_.getQueryStatement(), queryData_.getLanguage_()); ((QueryImpl)query).setOffset(offset_); long prevSize = 0; int bufSize = bufferSize_; int offset = 0; int count = 0; int currentIndex = 0; buffer.clear(); dataSet.clear(); while (true) { ((QueryImpl)query).setOffset(offset); ((QueryImpl)query).setLimit(bufSize); QueryResult queryResult = query.execute(); NodeIterator iter = queryResult.getNodes(); RowIterator rowIter = queryResult.getRows(); long size = iter.getSize(); while (iter.hasNext() && count < bufferSize_) { currentIndex++; Node newNode = iter.nextNode(); Row newRow = rowIter.nextRow(); if (filter != null) { newNode = filter.filterNodeToDisplay(newNode); } if (newNode == null) { realOffset_++; } if (newNode != null && searchDataCreator != null) { E data = searchDataCreator.createData(newNode, newRow); if (data != null && !dataSet.contains(data)) { if (currentIndex > realOffset_) { buffer.add(data); count ++; } dataSet.add(data); } else if (data!=null && dataSet.contains(data)) { realOffset_++; } } } if (count == bufferSize_) break; if (size == prevSize) break; if (size<bufSize) break; offset += bufSize; bufSize = 2 * bufSize; prevSize = size; } if (buffer.size() < this.getPageSize()) { setTotalNodes(buffer.size()); this.setAvailablePage(buffer.size()); } }