Buggy code:
private static final String cprForm = "Participant" ; private static final String dateFormat = CommonServiceLocator . getInstance ( ) . getDatePattern ( ) ; private static final String timeFormat = CommonServiceLocator . getInstance ( ) . getTimePattern ( ) ; private static final int EXPORT_THREAD_POOL_SIZE = QueryServiceImpl . getThreadPoolSize ( ) ; private static final int ONLINE_EXPORT_TIMEOUT_SECS = 30 ; private static final String EXPORT_DATA_DIR = QueryServiceImpl . getExportDataDir ( ) ; private static ExecutorService exportThreadPool = Executors . newFixedThreadPool ( QueryServiceImpl . EXPORT_THREAD_POOL_SIZE ) ; private DaoFactory daoFactory ; private UserDao userDao ; private QueryFolderFactory queryFolderFactory ; public DaoFactory getDaoFactory ( ) { } public void setDaoFactory ( DaoFactory daoFactory ) { } public UserDao getUserDao ( ) { } public void setUserDao ( UserDao userDao ) { } public QueryFolderFactory getQueryFolderFactory ( ) { } public void setQueryFolderFactory ( QueryFolderFactory queryFolderFactory ) { } @ Override @ PlusTransactional public ResponseEvent < SavedQueriesList > getSavedQueries ( RequestEvent < ListSavedQueriesCriteria > req ) { } @ Override @ PlusTransactional public ResponseEvent < SavedQueryDetail > getSavedQuery ( RequestEvent < Long > req ) { } @ Override @ PlusTransactional public ResponseEvent < SavedQueryDetail > saveQuery ( RequestEvent < SavedQueryDetail > req ) { } @ Override @ PlusTransactional public ResponseEvent < SavedQueryDetail > updateQuery ( RequestEvent < SavedQueryDetail > req ) { } @ Override @ PlusTransactional public ResponseEvent < Long > deleteQuery ( RequestEvent < Long > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryExecResult > executeQuery ( RequestEvent < ExecuteQueryEventOp > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryDataExportResult > exportQueryData ( RequestEvent < ExecuteQueryEventOp > req ) { } @ Override public ResponseEvent < File > getExportDataFile ( RequestEvent < String > req ) { } @ Override @ PlusTransactional public ResponseEvent < List < QueryFolderSummary > > getUserFolders ( RequestEvent < ? > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryFolderDetails > getFolder ( RequestEvent < Long > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryFolderDetails > createFolder ( RequestEvent < QueryFolderDetails > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryFolderDetails > updateFolder ( RequestEvent < QueryFolderDetails > req ) { } @ Override @ PlusTransactional public ResponseEvent < Long > deleteFolder ( RequestEvent < Long > req ) { } @ Override @ PlusTransactional public ResponseEvent < SavedQueriesList > getFolderQueries ( RequestEvent < ListFolderQueriesCriteria > req ) { } @ Override @ PlusTransactional public ResponseEvent < List < SavedQuerySummary > > updateFolderQueries ( RequestEvent < UpdateFolderQueriesOp > req ) { try { UpdateFolderQueriesOp opDetail = req . getPayload ( ) ; Long folderId = opDetail . getFolderId ( ) ; QueryFolder queryFolder = daoFactory . getQueryFolderDao ( ) . getQueryFolder ( folderId ) ; if ( queryFolder == null ) { return ResponseEvent . userError ( FOLDER_NOT_FOUND ) ; } Long userId = req . getSessionDataBean ( ) . getUserId ( ) ; if ( ( ! ( req . getSessionDataBean ( ) . isAdmin ( ) ) ) && ( ! ( queryFolder . getOwner ( ) . getId ( ) . equals ( userId ) ) ) ) { return ResponseEvent . userError ( OP_NOT_ALLOWED ) ; } List < SavedQuery > savedQueries = null ; List < Long > queryIds = opDetail . getQueries ( ) ; if ( ( queryIds == null ) || ( queryIds . isEmpty ( ) ) ) { savedQueries = new ArrayList < SavedQuery > ( ) ; } else { savedQueries = daoFactory . getSavedQueryDao ( ) . getQueriesByIds ( queryIds ) ; } switch ( opDetail . getOp ( ) ) { case ADD : queryFolder . addQueries ( savedQueries ) ; break ; case UPDATE : queryFolder . updateQueries ( savedQueries ) ; break ; case REMOVE : queryFolder . removeQueries ( savedQueries ) ; break ; } daoFactory . getQueryFolderDao ( ) . saveOrUpdate ( queryFolder ) ; List < SavedQuerySummary > result = new ArrayList < SavedQuerySummary > ( ) ; <START_BUG> for ( SavedQuery query : savedQueries ) { <END_BUG> result . add ( SavedQuerySummary . fromSavedQuery ( query ) ) ; } return ResponseEvent . response ( result ) ; } catch ( Exception e ) { return ResponseEvent . serverError ( e ) ; } } @ Override @ PlusTransactional public ResponseEvent < List < UserSummary > > shareFolder ( RequestEvent < ShareQueryFolderOp > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryAuditLogsList > getAuditLogs ( RequestEvent < ListQueryAuditLogsCriteria > req ) { } @ Override @ PlusTransactional public ResponseEvent < QueryAuditLogDetail > getAuditLog ( RequestEvent < Long > req ) { } @ Override @ PlusTransactional public ResponseEvent < String > getQueryDef ( RequestEvent < Long > req ) { } private SavedQuery getSavedQuery ( SessionDataBean sdb , SavedQueryDetail detail ) { } private String getAql ( SavedQueryDetail queryDetail ) { } private boolean exportData ( final String filename , final Query query , final RequestEvent < ExecuteQueryEventOp > req ) throws InterruptedException , CancellationException , ExecutionException { } private String getRestriction ( SessionDataBean sdb , Long cpId ) { } private String getCpIdRestriction ( List < Long > cpIds ) { } private String getAqlWithCpIdInSelect ( SessionDataBean sdb , boolean isCount , String aql ) { } private static int getThreadPoolSize ( ) { } private static String getExportDataDir ( ) { } private void insertAuditLog ( RequestEvent < ExecuteQueryEventOp > req , QueryResponse resp ) { } private Transaction startTxn ( ) { } private class QueryResultScreenerImpl implements QueryResultScreener { private SessionDataBean sdb ; private boolean countQuery ; private Map < Long , Boolean > phiAccessMap = new HashMap < Long , Boolean > ( ) ; private static final String mask = "##########" ; public QueryResultScreenerImpl ( SessionDataBean sdb , boolean countQuery ) { } @ Override public List < ResultColumn > getScreenedResultColumns ( List < ResultColumn > preScreenedResultCols ) { }

Fix:
for ( SavedQuery query : queryFolder . getSavedQueries ( ) ) {