auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static com.azure.search.documents.indexes.implementation.models.LimitTokenFilter map(LimitTokenFilter obj) { if (obj == null) { return null; } com.azure.search.documents.indexes.implementation.models.LimitTokenFilter limitTokenFilter = new com.azure.search.documents.indexes.implementation.models.LimitTokenFilter(); String name = obj.getName(); limitTokenFilter.setName(name); Integer maxTokenCount = obj.getMaxTokenCount(); limitTokenFilter.setMaxTokenCount(maxTokenCount); Boolean consumeAllTokens = obj.isAllTokensConsumed(); limitTokenFilter.setConsumeAllTokens(consumeAllTokens); return limitTokenFilter; }

Target:
public static com.azure.search.documents.indexes.implementation.models.LimitTokenFilter map(LimitTokenFilter obj) { if (obj == null) { return null; } com.azure.search.documents.indexes.implementation.models.LimitTokenFilter limitTokenFilter = new com.azure.search.documents.indexes.implementation.models.LimitTokenFilter(); String name = obj.getName(); limitTokenFilter.setName(name); Integer maxTokenCount = obj.getMaxTokenCount(); limitTokenFilter.setMaxTokenCount(maxTokenCount); Boolean consumeAllTokens = obj.areAllTokensConsumed(); limitTokenFilter.setConsumeAllTokens(consumeAllTokens); return limitTokenFilter; }
Source:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); HttpSession session = request.getSession(false); UserBean user = (session != null) ? (UserBean) session.getAttribute("user") : null; if (user == null) { response.sendError(403); } else { String mainDir = "files"; String saveDir = "uploadLecturesFiles"; String appPath = request.getServletContext().getRealPath(""); String savePath = appPath + File.separator + mainDir + File.separator + saveDir; String fileName = null, filePath = ""; for (Part part : request.getParts()) { String name = part.getName(); if (name.equals("upload")) { fileName = extractFileName(part); if (!fileName.isEmpty()) { filePath = saveDir + File.separator + fileName; part.write(savePath + File.separator + fileName); } } } String subject = request.getParameter("subject").trim(); String title = request.getParameter("title").trim(); String body = request.getParameter("body").trim(); LecturesBean bean = new LecturesBean(user.getId(), subject, title, body, filePath); if (LecturesDAO.insert(bean)) { session.setAttribute("status", "success"); session.setAttribute("message", "Lecture has been added"); } else { session.setAttribute("status", "danger"); session.setAttribute("message", "Some troubles were occurred during creating a lecture"); } response.sendRedirect(request.getContextPath() + "/lectures"); } }

Target:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); UserBean user = (session != null) ? (UserBean) session.getAttribute("user") : null; if (user == null) { response.sendError(403); } else { String mainDir = "files"; String saveDir = "uploadLecturesFiles"; String appPath = request.getServletContext().getRealPath(""); String savePath = appPath + File.separator + mainDir + File.separator + saveDir; String fileName = null, filePath = ""; for (Part part : request.getParts()) { String name = part.getName(); if (name.equals("upload")) { fileName = extractFileName(part); if (!fileName.isEmpty()) { filePath = saveDir + File.separator + fileName; part.write(savePath + File.separator + fileName); } } } String subject = request.getParameter("subject").trim(); String title = request.getParameter("title").trim(); String body = request.getParameter("body").trim(); LecturesBean bean = new LecturesBean(user.getId(), subject, title, body, filePath); if (LecturesDAO.insert(bean)) { session.setAttribute("status", "success"); session.setAttribute("message", "Lecture has been added"); } else { session.setAttribute("status", "danger"); session.setAttribute("message", "Some troubles were occurred during creating a lecture"); } response.sendRedirect(request.getContextPath() + "/lectures"); } }
Source:
public List<String> validatePassthroughVnics(Guid vmId, Guid hostId, List<VmNetworkInterface> vnics) { List<VmNetworkInterface> pluggedPassthroughVnics = getPluggedPassthroughVnics(vnics); if (pluggedPassthroughVnics.isEmpty()) { return Collections.emptyList(); } Map<Guid, Map<Guid, String>> hostToVnicToVfMap = vmToHostToVnicToVfMap.get(vmId); if (hostToVnicToVfMap == null) { hostToVnicToVfMap = new HashMap<>(); vmToHostToVnicToVfMap.put(vmId, hostToVnicToVfMap); } Map<Guid, List<String>> nicToUsedVfs = new HashMap<>(); Map<Guid, VdsNetworkInterface> fetchedNics = new HashMap<>(); List<String> problematicVnics = new ArrayList<>(); List<HostNicVfsConfig> vfsConfigs = vfsConfigHelper.getHostNicVfsConfigsWithNumVfsDataByHostId(hostId); Map<Guid, String> vnicToVfMap = new HashMap<>(); hostToVnicToVfMap.put(hostId, vnicToVfMap); for (final VmNetworkInterface vnic : pluggedPassthroughVnics) { String freeVf = null; freeVf = findFreeVfForVnic(vfsConfigs, nicToUsedVfs, fetchedNics, vnic.getNetworkName() == null ? null : networkDao.getByName(vnic.getNetworkName()), vnic.getVmId(), true); if (freeVf == null || shouldBeDirectlyAttached(freeVf, vmId)) { problematicVnics.add(vnic.getName()); } else { vnicToVfMap.put(vnic.getId(), freeVf); } } return problematicVnics; }

Target:
public List<String> validatePassthroughVnics(Guid vmId, Guid hostId, List<VmNetworkInterface> vnics) { List<VmNetworkInterface> pluggedPassthroughVnics = getPluggedPassthroughVnics(vnics); if (pluggedPassthroughVnics.isEmpty()) { return Collections.emptyList(); } Map<Guid, Map<Guid, String>> hostToVnicToVfMap = vmToHostToVnicToVfMap.get(vmId); if (hostToVnicToVfMap == null) { hostToVnicToVfMap = new HashMap<>(); vmToHostToVnicToVfMap.put(vmId, hostToVnicToVfMap); } Map<Guid, List<String>> nicToUsedVfs = new HashMap<>(); Map<Guid, VdsNetworkInterface> fetchedNics = new HashMap<>(); List<String> problematicVnics = new ArrayList<>(); List<HostNicVfsConfig> vfsConfigs = networkDeviceHelper.getHostNicVfsConfigsWithNumVfsDataByHostId(hostId); Map<Guid, String> vnicToVfMap = new HashMap<>(); hostToVnicToVfMap.put(hostId, vnicToVfMap); for (final VmNetworkInterface vnic : pluggedPassthroughVnics) { String freeVf = null; freeVf = findFreeVfForVnic(vfsConfigs, nicToUsedVfs, fetchedNics, vnic.getNetworkName() == null ? null : networkDao.getByName(vnic.getNetworkName()), vnic.getVmId(), true); if (freeVf == null) { problematicVnics.add(vnic.getName()); } else { vnicToVfMap.put(vnic.getId(), freeVf); } } return problematicVnics; }
Source:
protected CommandBase(T parameters, CommandContext cmdContext) { if (cmdContext == null) { cmdContext = new CommandContext().setEngineContext(new EngineContext(parameters.getSessionId())) .setExecutionContext(new ExecutionContext()); } this.context = cmdContext; _parameters = parameters; DbUser user = SessionDataContainer.getInstance().getUser(cmdContext.getEngineContext().getSessionId(), true); if (user != null) { setCurrentUser(user); } ExecutionContext executionContext = cmdContext.getExecutionContext(); if (executionContext.getJob() != null) { setJobId(executionContext.getJob().getId()); } else if (executionContext.getStep() != null) { setJobId(executionContext.getStep().getJobId()); } Guid commandIdFromParameters = parameters.getCommandId(); if (commandIdFromParameters == null) { commandIdFromParameters = Guid.newGuid(); getParameters().setCommandId(commandIdFromParameters); } commandId = commandIdFromParameters; taskHandlers = initTaskHandlers(); setCorrelationId(parameters.getCorrelationId()); }

Target:
protected CommandBase(T parameters, CommandContext cmdContext) { if (cmdContext == null) { cmdContext = new CommandContext(new EngineContext().setSessionId(parameters.getSessionId())) .setExecutionContext(new ExecutionContext()); } this.context = cmdContext; _parameters = parameters; DbUser user = SessionDataContainer.getInstance().getUser(cmdContext.getEngineContext().getSessionId(), true); if (user != null) { setCurrentUser(user); } ExecutionContext executionContext = cmdContext.getExecutionContext(); if (executionContext.getJob() != null) { setJobId(executionContext.getJob().getId()); } else if (executionContext.getStep() != null) { setJobId(executionContext.getStep().getJobId()); } Guid commandIdFromParameters = parameters.getCommandId(); if (commandIdFromParameters == null) { commandIdFromParameters = Guid.newGuid(); getParameters().setCommandId(commandIdFromParameters); } commandId = commandIdFromParameters; taskHandlers = initTaskHandlers(); setCorrelationId(parameters.getCorrelationId()); }
Source:
public void initialize(DataManager manager, ARXConfiguration config){ if (config != null) { return; } if (beta < 0) { ParameterCalculation pCalc = null; try { pCalc = new ParameterCalculation(epsilon, delta); } catch (IntervalArithmeticException e) { throw new RuntimeException(e); } beta = pCalc.getBeta(); k = pCalc.getK(); } if (subset == null || initialized) { Random random; if (deterministic) { random = new Random(0xDEADBEEF); } else { random = new SecureRandom(); } Set<Integer> subsetIndices = new HashSet<Integer>(); int numRecords = manager.getDataGeneralized().getDataLength(); for (int i = 0; i < numRecords; ++i) { if (random.nextDouble() < beta) { subsetIndices.add(i); } } this.subset = DataSubset.create(numRecords, subsetIndices); } initialized = true; }

Target:
public void initialize(DataManager manager, ARXConfiguration config){ if (config != null) { return; } if (beta < 0) { ParameterCalculation pCalc = null; try { pCalc = new ParameterCalculation(epsilon, delta); } catch (IntervalArithmeticException e) { throw new RuntimeException(e); } beta = pCalc.getBeta(); k = pCalc.getK(); } if (subset == null || initialized) { Random random = deterministic ? new Random(0xDEADBEEF) : new SecureRandom(); Set<Integer> subsetIndices = new HashSet<Integer>(); int numRecords = manager.getDataGeneralized().getDataLength(); for (int i = 0; i < numRecords; ++i) { if (random.nextDouble() < beta) { subsetIndices.add(i); } } this.subset = DataSubset.create(numRecords, subsetIndices); } initialized = true; }
Source:
private Set<EnrichedThingDTO> convertToListBean(Collection<Thing> things, Locale locale) { Set<EnrichedThingDTO> thingBeans = new LinkedHashSet<>(); for (Thing thing : things) { EnrichedThingDTO thingBean = EnrichedThingDTOMapper.map(thing, uriInfo.getBaseUri(), locale, getLinkedItemsMap(thing), thingStatusInfoI18nLocalizationService); thingBeans.add(thingBean); } return thingBeans; }

Target:
private Set<EnrichedThingDTO> convertToListBean(Collection<Thing> things, Locale locale) { Set<EnrichedThingDTO> thingBeans = new LinkedHashSet<>(); for (Thing thing : things) { ThingStatusInfo thingStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing, locale); EnrichedThingDTO thingBean = EnrichedThingDTOMapper.map(thing, thingStatusInfo, getLinkedItemsMap(thing)); thingBeans.add(thingBean); } return thingBeans; }
Source:
public void scrollSelectedCellIntoView_HeaderSelected_WithDeltaXScroll() { when(gridData.getSelectedHeaderCells()).thenReturn(Collections.singletonList(new GridData.SelectedCell(0,0))); when(layer.getVisibleBounds()).thenReturn(new BaseBounds(500, 0, BOUNDS_WIDTH, BOUNDS_HEIGHT)); assertTrue(baseKeyboardOperationSpy.scrollSelectedCellIntoView(gridWidget)); verify(layer, times(1)).getViewport(); verify(viewport, times(1)).getTransform(); }

Target:
public void scrollSelectedCellIntoView_HeaderSelected_WithDeltaXScroll() { when(gridData.getSelectedHeaderCells()).thenReturn(Collections.singletonList(new GridData.SelectedCell(0,0))); when(layer.getVisibleBounds()).thenReturn(new BaseBounds(600, 0, BOUNDS_WIDTH, BOUNDS_HEIGHT)); assertTrue(baseKeyboardOperationSpy.scrollSelectedCellIntoView(gridWidget)); verify(layer, times(1)).getViewport(); verify(viewport, times(1)).getTransform(); verify(transform, times(1)).scale(1, 1); verify(transform, times(1)).translate(600, 0); }
Source:
public static String[] getPluginConfiguration(MavenProject proj, String pluginGroupId, String pluginArtifactId, String key1, String key2, String childName) { Xpp3Dom dom = proj.getGoalConfiguration(pluginGroupId, pluginArtifactId, null, null); if (dom != null) { Xpp3Dom val1 = dom.getChild(key1); if (val1 != null) { Xpp3Dom val2 = null; if (key2 == null) { val2 = val1; } else { val2 = val1.getChild(key2); } if (val2 != null) { Xpp3Dom[] children = null; if (childName == null) children = val2.getChildren(); else children = val2.getChildren(childName); if (children != null) { String[] result = new String[children.length]; for (int i = 0; i < children.length; i++) { result[i] = children[i].getValue(); } return result; } return null; } } } return null; }

Target:
public static String[] getPluginConfiguration(MavenProject proj, String pluginGroupId, String pluginArtifactId, String key1, String key2, String childName) { Xpp3Dom dom = proj.getGoalConfiguration(pluginGroupId, pluginArtifactId, null, null); if (dom != null) { Xpp3Dom val1 = dom.getChild(key1); if (val1 != null) { Xpp3Dom val2 = null; if (key2 == null) { val2 = val1; } else { val2 = val1.getChild(key2); } if (val2 != null) { Xpp3Dom[] children = null; if (childName == null) { children = val2.getChildren(); } else { children = val2.getChildren(childName); } if (children != null) { String[] result = new String[children.length]; for (int i = 0; i < children.length; i++) { result[i] = children[i].getValue(); } return result; } return null; } } } return null; }
Source:
public void registerClassDefinitions(Collection<ClassDefinition> classDefinitions, boolean checkClassDefErrors) { Map<Integer, Map<Integer, ClassDefinition>> factoryMap = createHashMap(classDefinitions.size()); for (ClassDefinition cd : classDefinitions) { int factoryId = cd.getFactoryId(); Map<Integer, ClassDefinition> classDefMap = factoryMap.computeIfAbsent(factoryId, k -> new HashMap<>()); if (classDefMap.containsKey(cd.getClassId())) { throw new HazelcastSerializationException("Duplicate registration found for factory-id : " + factoryId + ", class-id " + cd.getClassId()); } classDefMap.put(factoryId, cd); } for (ClassDefinition classDefinition : classDefinitions) { registerClassDefinition(classDefinition, factoryMap, checkClassDefErrors); } }

Target:
public void registerClassDefinitions(Collection<ClassDefinition> classDefinitions, boolean checkClassDefErrors) { Map<Integer, Map<Integer, ClassDefinition>> factoryMap = createHashMap(classDefinitions.size()); for (ClassDefinition cd : classDefinitions) { int factoryId = cd.getFactoryId(); Map<Integer, ClassDefinition> classDefMap = factoryMap.computeIfAbsent(factoryId, k -> new HashMap<>()); int classId = cd.getClassId(); if (classDefMap.containsKey(classId)) { throw new HazelcastSerializationException("Duplicate registration found for factory-id : " + factoryId + ", class-id " + classId); } classDefMap.put(classId, cd); } for (ClassDefinition classDefinition : classDefinitions) { registerClassDefinition(classDefinition, factoryMap, checkClassDefErrors); } }
Source:
protected InterfaceList parseInterfaceList(String interfaceListName) throws TypeImportException, XMLStreamException { InterfaceList interfaceList = LibraryElementFactory.eINSTANCE.createInterfaceList(); final String inputEventListName = getEventInputElement(); final String outputEventListName = getEventOutputElement(); processChildren(interfaceListName, name -> { if (name.equals(inputEventListName)) { parseEventList(interfaceList.getEventInputs(), inputEventListName, true); } else if (name.equals(outputEventListName)) { parseEventList(interfaceList.getEventOutputs(), outputEventListName, false); } else { switch (name) { case LibraryElementTags.INPUT_VARS_ELEMENT: parseVariableList(LibraryElementTags.INPUT_VARS_ELEMENT, interfaceList.getInputVars()); interfaceList.getInputVars().forEach(v -> { variables.put(v.getName(), v); v.setIsInput(true); }); break; case LibraryElementTags.OUTPUT_VARS_ELEMENT: parseVariableList(LibraryElementTags.OUTPUT_VARS_ELEMENT, interfaceList.getOutputVars()); interfaceList.getOutputVars().forEach(v -> variables.put(v.getName(), v)); break; case LibraryElementTags.SOCKETS_ELEMENT: parseAdapterList(interfaceList.getSockets(), LibraryElementTags.SOCKETS_ELEMENT, true); break; case LibraryElementTags.PLUGS_ELEMENT: parseAdapterList(interfaceList.getPlugs(), LibraryElementTags.PLUGS_ELEMENT, false); break; default: return false; } } return true; }); processWiths(); return interfaceList; }

Target:
protected InterfaceList parseInterfaceList(String interfaceListName) throws TypeImportException, XMLStreamException { InterfaceList interfaceList = LibraryElementFactory.eINSTANCE.createInterfaceList(); final String inputEventListName = getEventInputElement(); final String outputEventListName = getEventOutputElement(); processChildren(interfaceListName, name -> { if (inputEventListName.equals(name)) { parseEventList(interfaceList.getEventInputs(), inputEventListName, true); } else if (outputEventListName.equals(name)) { parseEventList(interfaceList.getEventOutputs(), outputEventListName, false); } else { switch (name) { case LibraryElementTags.INPUT_VARS_ELEMENT: parseVariableList(LibraryElementTags.INPUT_VARS_ELEMENT, interfaceList.getInputVars()); interfaceList.getInputVars().forEach(v -> { variables.put(v.getName(), v); v.setIsInput(true); }); break; case LibraryElementTags.OUTPUT_VARS_ELEMENT: parseVariableList(LibraryElementTags.OUTPUT_VARS_ELEMENT, interfaceList.getOutputVars()); interfaceList.getOutputVars().forEach(v -> variables.put(v.getName(), v)); break; case LibraryElementTags.SOCKETS_ELEMENT: parseAdapterList(interfaceList.getSockets(), LibraryElementTags.SOCKETS_ELEMENT, true); break; case LibraryElementTags.PLUGS_ELEMENT: parseAdapterList(interfaceList.getPlugs(), LibraryElementTags.PLUGS_ELEMENT, false); break; default: return false; } } return true; }); processWiths(); return interfaceList; }
Source:
public String prettyMessages() { StringBuffer message = new StringBuffer(); for(String m: messages) { message.append(m); message.append("\n"); } return message.toString(); }

Target:
public String prettyMessages() { return Strings.join(messages, "\n"); }
Source:
boolean update(long timestamp, String taskName) { final long preWatermarkTime = watermarkTime; if (taskName != null) { timestamps.put(taskName, timestamp); } if (timestamps.size() == expectedTotal) { Optional<Long> min = timestamps.values().stream().min(Long::compare); watermarkTime = min.orElse(timestamp); } return preWatermarkTime != watermarkTime; }

Target:
synchronized void update(long timestamp, String taskName) { if (taskName != null) { Long ts = timestamps.get(taskName); if (ts != null && ts > timestamp) { LOG.warn(String.format("Incoming watermark %s is smaller than existing watermark %s for upstream task %s", timestamp, ts, taskName)); } else { timestamps.put(taskName, timestamp); } } if (timestamps.size() == expectedTotal) { Optional<Long> min = timestamps.values().stream().min(Long::compare); watermarkTime = min.orElse(timestamp); } }
Source:
private Boolean doAbandonChange(final String message, final Change change, final PatchSet.Id psid, final ChangeMessage cm, final ReviewDb db, final Transaction txn) throws OrmException { if (change.getStatus() == Change.Status.NEW && change.currentPatchSetId().equals(psid)) { change.setStatus(Change.Status.ABANDONED); ChangeUtil.updated(change); final ReviewDb schema = Common.getSchemaFactory().open(); final List<ChangeApproval> approvals = schema.changeApprovals().byChange(change.getId()).toList(); for (ChangeApproval a : approvals) { a.cache(change); } schema.changeApprovals().update(approvals, txn); db.changeMessages().insert(Collections.singleton(cm), txn); db.changes().update(Collections.singleton(change), txn); return Boolean.TRUE; } return Boolean.FALSE; }

Target:
private Boolean doAbandonChange(final String message, final Change change, final PatchSet.Id psid, final ChangeMessage cm, final ReviewDb db, final Transaction txn) throws OrmException { if (change.getStatus() == Change.Status.NEW && change.currentPatchSetId().equals(psid)) { change.setStatus(Change.Status.ABANDONED); ChangeUtil.updated(change); final List<ChangeApproval> approvals = db.changeApprovals().byChange(change.getId()).toList(); for (ChangeApproval a : approvals) { a.cache(change); } db.changeApprovals().update(approvals, txn); db.changeMessages().insert(Collections.singleton(cm), txn); db.changes().update(Collections.singleton(change), txn); return Boolean.TRUE; } return Boolean.FALSE; }
Source:
public int archiveWorkflows(DateTime olderThan, int batchSize) { Assert.notNull(olderThan, "olderThan must not be null"); Assert.isTrue(batchSize > 0, "batchSize must be greater than 0"); archiveDao.ensureValidArchiveTablesExist(); log.info("Archiving starting. Archiving passive workflows older than {}, in batches of {}.", olderThan, batchSize); StopWatch stopWatch = new StopWatch(); stopWatch.start(); List<Integer> workflowIds; int archivedWorkflows = 0; do { workflowIds = archiveDao.listArchivableWorkflows(olderThan, batchSize); if (workflowIds.isEmpty()) { break; } archiveDao.archiveWorkflows(workflowIds); archivedWorkflows += workflowIds.size(); double timeDiff = stopWatch.getTime() / 1000.0; log.debug("Archived workflows. workflows / second. Workflow ids: {}. ", workflowIds.size(), archivedWorkflows / timeDiff, workflowIds); } while (!workflowIds.isEmpty()); log.info("Archiving finished. Archived workflows.", archivedWorkflows); return archivedWorkflows; }

Target:
public int archiveWorkflows(DateTime olderThan, int batchSize) { Assert.notNull(olderThan, "olderThan must not be null"); Assert.isTrue(batchSize > 0, "batchSize must be greater than 0"); archiveDao.ensureValidArchiveTablesExist(); log.info("Archiving starting. Archiving passive workflows older than {}, in batches of {}.", olderThan, batchSize); StopWatch stopWatch = new StopWatch(); stopWatch.start(); List<Integer> rootWorkflowIds; PeriodicLogger periodicLogger = new PeriodicLogger(log, 60); int archivedRootWorkflows = 0; int archivedWorkflows = 0; do { rootWorkflowIds = archiveDao.listArchivableRootWorkflows(olderThan, batchSize); if (rootWorkflowIds.isEmpty()) { break; } archivedWorkflows += archiveDao.archiveRootWorkflows(rootWorkflowIds); archivedRootWorkflows += rootWorkflowIds.size(); double timeDiff = stopWatch.getTime() / 1000.0; log.debug("Archived workflow trees. workflow trees / second. Root workflow ids: {}. ", rootWorkflowIds.size(), archivedRootWorkflows / timeDiff, rootWorkflowIds); periodicLogger.log("Archived workflow trees and workflow instances (incl. child workflows) so far. " + "Archiving about workflow trees / second and workflow instances / second.", archivedRootWorkflows, archivedWorkflows, archivedRootWorkflows / timeDiff, archivedWorkflows / timeDiff); } while (!rootWorkflowIds.isEmpty()); log.info("Archiving finished. Archived workflow trees and workflow instances (incl. child workflows).", archivedRootWorkflows, archivedWorkflows); return archivedRootWorkflows; }
Source:
public GradleInstallation[] getInstallations() { return Jenkins.getActiveInstance().getDescriptorByType(Gradle.DescriptorImpl.class).getInstallations(); }

Target:
public GradleInstallation[] getInstallations() { return getGradleDescriptor().getInstallations(); }
Source:
public void resendPhoneVerificationInvalid() { Identifier identifier = new Identifier(null, (Phone)null); service.resendVerification(ChannelType.EMAIL, identifier); }

Target:
public void resendPhoneVerificationInvalid() throws Exception { AccountId accountId = BridgeObjectMapper.get().readValue("{}", AccountId.class); service.resendVerification(ChannelType.PHONE, accountId); }
Source:
public Iterator<K> iterator() { if (samIterator != null) { throw new IllegalStateException("Cannot call iterator() more than once on SamLocusIterator"); } CloseableIterator<SAMRecord> tempIterator; if (intervals != null) { tempIterator = new SamRecordIntervalIteratorFactory().makeSamRecordIntervalIterator(samReader, intervals, useIndex); } else { tempIterator = samReader.iterator(); } if (samFilters != null) { tempIterator = new FilteringSamIterator(tempIterator, new AggregateFilter(samFilters)); } samIterator = new PeekableIterator<>(tempIterator); return this; }

Target:
public Iterator<K> iterator() { if (samIterator != null) { throw new IllegalStateException("Cannot call iterator() more than once on " + this.getClass().getSimpleName()); } CloseableIterator<SAMRecord> tempIterator; if (intervals != null) { tempIterator = new SamRecordIntervalIteratorFactory().makeSamRecordIntervalIterator(samReader, intervals, useIndex); } else { tempIterator = samReader.iterator(); } if (samFilters != null) { tempIterator = new FilteringSamIterator(tempIterator, new AggregateFilter(samFilters)); } samIterator = new PeekableIterator<>(tempIterator); return this; }
Source:
protected int getMaxVolumeChain() { return Config.<Integer> getValue(ConfigValues.MaxImagesInChain); }

Target:
protected int getMaxVolumeChain() { return Config.getValue(ConfigValues.MaxImagesInChain); }
Source:
public void shutdown() { ExecutorService executor; ExecutorService secondaryExecutor; boolean shutdown; synchronized (this) { executor = this.executor; secondaryExecutor = this.secondaryExecutor; shutdown = !this.detachExecutor; this.executor = null; } if (shutdown) { if (executor != null) { executor.shutdownNow(); } if (secondaryExecutor != null) { secondaryExecutor.shutdownNow(); } } }

Target:
public void shutdown() { ExecutorService executor; ExecutorService secondaryExecutor; boolean shutdown; synchronized (this) { executor = this.executor; secondaryExecutor = this.secondaryExecutor; shutdown = !this.detachExecutor; this.executor = null; this.secondaryExecutor = null; } if (shutdown) { if (executor != null) { executor.shutdownNow(); } if (secondaryExecutor != null) { secondaryExecutor.shutdownNow(); } } }
Source:
public void init() { if (started) { return; } WorkManagerImpl wmi = (WorkManagerImpl) Framework.getRuntime().getComponent("org.nuxeo.ecm.core.work.service"); wmi.active = false; log.debug("Initializing"); synchronized (this) { if (started) { return; } getDescriptors(QUEUES_EP).forEach(d -> categoryToQueueId.put(d.getId(), d.getId())); index(); initTopology(); logManager = getLogManager(); streamManager = getStreamManager(); streamManager.register("SWMDisable", topologyDisabled, settings); streamProcessor = streamManager.registerAndCreateProcessor("SWM", topology, settings); started = true; new ComponentListener().install(); log.info("Initialized"); } }

Target:
public void init() { if (started) { return; } WorkManagerImpl wmi = (WorkManagerImpl) Framework.getRuntime().getComponent("org.nuxeo.ecm.core.work.service"); wmi.active = false; log.debug("Initializing"); synchronized (this) { if (started) { return; } getDescriptors(QUEUES_EP).forEach(d -> categoryToQueueId.put(d.getId(), d.getId())); index(); initTopology(); logManager = getLogManager(); streamManager = getStreamManager(); streamManager.register("StreamWorkManagerDisable", topologyDisabled, settings); streamProcessor = streamManager.registerAndCreateProcessor("StreamWorkManager", topology, settings); started = true; new ComponentListener().install(); log.info("Initialized"); } }
Source:
private boolean areCurrentCoordinatesValid() { final Geopoint current; final String lat = getLatResult(); final String lon = getLonResult(); if (lat.contains("_") || lat.contains("*") || lon.contains("_") || lon.contains("*")) { return false; } final String delimiters = "[ °'\"\\.]+"; final String[] latTokens = lat.split(delimiters); final String[] lonTokens = lon.split(delimiters); try { switch (currentFormat) { case Deg: current = new Geopoint(latTokens[0], latTokens[1], latTokens[2], lonTokens[0], lonTokens[1], lonTokens[2]); break; case Min: current = new Geopoint(latTokens[0], latTokens[1], latTokens[2], latTokens[3], lonTokens[0], lonTokens[1], lonTokens[2], lonTokens[3]); break; case Sec: current = new Geopoint(latTokens[0], latTokens[1], latTokens[2], latTokens[3], latTokens[4], lonTokens[0], lonTokens[1], lonTokens[2], lonTokens[3], lonTokens[4]); break; case Plain: current = new Geopoint(lat, lon); break; default: throw new IllegalStateException("can never happen, keep tools happy"); } if (current.isValid()) { gp = current; return true; } } catch (final Geopoint.ParseException ignored) { } return false; }

Target:
private boolean areCurrentCoordinatesValid() { final Geopoint current; final String lat = getLatResult(); final String lon = getLonResult(); if (currentFormat == null || lat.contains("_") || lat.contains("*") || lon.contains("_") || lon.contains("*")) { return false; } try { current = new Geopoint(lat, lon); if (current.isValid()) { gp = current; return true; } } catch (final Geopoint.ParseException ignored) { } return false; }
Source:
static Block1BlockwiseStatus forOutboundRequest(final Exchange exchange, final Request request, final int preferredBlockSize) { Block1BlockwiseStatus status = new Block1BlockwiseStatus(request.getOptions().getContentFormat()); status.request = request; status.setCurrentSzx(BlockOption.size2Szx(preferredBlockSize)); return status; }

Target:
static Block1BlockwiseStatus forOutboundRequest(final Exchange exchange, final Request request, final int preferredBlockSize) { Block1BlockwiseStatus status = new Block1BlockwiseStatus(0, request.getOptions().getContentFormat()); status.request = request; status.setCurrentSzx(BlockOption.size2Szx(preferredBlockSize)); return status; }
Source:
protected void apply(String id, Collection<FeaturesLoader.Holder> holders, ThrowableConsumer<FeaturesLoader.Holder, Exception> consumer) { log.trace("Invoke on features: {}", () -> id, () -> formatFeatures(holders)); Supplier<String> msg = () -> String.format("Error while invoking %s on features: %s", id, formatFeatures(holders)); var errors = new ArrayList<Throwable>(); for (FeaturesLoader.Holder each : holders) { try { consumer.accept(each); } catch (AssumptionViolatedException cause) { log.debug("Test ignore by feature: {}", each.type); throw cause; } catch (InterruptedException cause) { Thread.currentThread().interrupt(); throw new AssertionError(msg.get(), cause); } catch (Throwable cause) { log.debug("Error while invoking on feature: {}", id, each.type); errors.add(cause); } } if (!errors.isEmpty()) { var exception = new AssertionError(msg.get()); errors.forEach(exception::addSuppressed); throw exception; } }

Target:
protected void apply(String id, Collection<FeaturesLoader.Holder> holders, ThrowableConsumer<FeaturesLoader.Holder, Exception> consumer) { log.trace("Invoke: on features: {}", () -> id, () -> formatFeatures(holders)); Supplier<String> msg = () -> String.format("Error while invoking %s on features: %s", id, formatFeatures(holders)); var errors = new ArrayList<Throwable>(); for (FeaturesLoader.Holder holder : holders) { try { consumer.accept(holder); } catch (AssumptionViolatedException cause) { log.debug("Test ignored by the feature: {}", holder.type); throw cause; } catch (InterruptedException cause) { Thread.currentThread().interrupt(); throw new RuntimeServiceException(msg.get(), cause); } catch (Throwable cause) { log.debug("Error while invoking: on feature: {}", id, holder.type); throwSeriousError(cause); errors.add(cause); } } if (!errors.isEmpty()) { var exception = new AssertionError(msg.get()); errors.forEach(exception::addSuppressed); throw exception; } }
Source:
private void updateBackup() { if (getCurrentStorageItem().getRole() == StorageDomainType.ISO || getCurrentStorageItem().getRole() == StorageDomainType.ImportExport) { isBackup().setIsAvailable(false); isbackup().setEntity(false); return; } boolean backupSupported = (Boolean) AsyncDataProvider.getInstance().getConfigValuePreConverted( ConfigurationValues.BackupSupported, getDataCenter().getSelectedItem().getCompatibilityVersion().toString()); isBackup().setIsAvailable(BackupSupported); if (isBackup().getIsAvailable()) { if (isNewStorage()) { isBackup().setEntity(false); } else { isBackup().setEntity(getStorage().isBackup()); } } }

Target:
private void updateBackup() { if (getCurrentStorageItem().getRole() == StorageDomainType.ISO || getCurrentStorageItem().getRole() == StorageDomainType.ImportExport) { isBackup().setIsAvailable(false); isBackup().setEntity(false); return; } boolean backupSupported = (Boolean) AsyncDataProvider.getInstance().getConfigValuePreConverted( ConfigurationValues.BackupSupported, getDataCenter().getSelectedItem().getCompatibilityVersion().toString()); isBackup().setIsAvailable(backupSupported); if (isBackup().getIsAvailable()) { if (isNewStorage()) { isBackup().setEntity(false); } else { isBackup().setEntity(getStorage().isBackup()); } } }
Source:
public CharSeq filter(Predicate<? super Character> predicate) { Objects.requireNonNull(predicate, "predicate is null"); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < back.length(); i++) { final char ch = back.charAt(i); if (predicate.test(ch)) { sb.append(ch); } } if (sb.length() == 0) { return EMPTY; } else if (sb.length() == length()) { return this; } else { return of(sb); } }

Target:
public CharSeq filter(Predicate<? super Character> predicate) { Objects.requireNonNull(predicate, "predicate is null"); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < back.length(); i++) { final char ch = get(i); if (predicate.test(ch)) { sb.append(ch); } } if (sb.length() == 0) { return EMPTY; } else if (sb.length() == length()) { return this; } else { return of(sb); } }
Source:
public void setContext(PrincipalRoleMapperContext context) { this.cacheManager = context.getCacheManager(); GlobalConfiguration globalConfiguration = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration(); CacheMode cacheMode = globalConfiguration.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.clustering().cacheMode(cacheMode).sync().stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(false); InternalCacheRegistry internalCacheRegistry = cacheManager.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class); internalCacheRegistry.registerInternalCache(CLUSTER_ROLE_MAPPER_CACHE, cfg.build(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT)); }

Target:
public void setContext(PrincipalRoleMapperContext context) { this.cacheManager = context.getCacheManager(); GlobalConfiguration globalConfiguration = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration(); CacheMode cacheMode = globalConfiguration.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.clustering().cacheMode(cacheMode).sync() .stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(false) .security().authorization().disable(); InternalCacheRegistry internalCacheRegistry = cacheManager.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class); internalCacheRegistry.registerInternalCache(CLUSTER_ROLE_MAPPER_CACHE, cfg.build(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT)); }
Source:
protected void handleRemoteServiceSelected(IRemoteConnection conn) throws CoreException { final boolean enabled = fWidgetListener.isEnabled(); fWidgetListener.disable(); try { IRemoteConnectionType selectedConnectionType = getSelectedConnectionType(); if (conn != null) { selectedConnectionType = conn.getConnectionType(); } if (fDefaultConnectionType == null && conn != null) { for (int index = 0; index < fConnectionTypes.size(); index++) { if (fConnectionTypes.get(index).getId().equals(selectedConnectionType.getId())) { fServicesCombo.select(index + 1); break; } } } fConnectionCombo.removeAll(); fConnectionCombo.add(Messages.RemoteConnectionWidget_selectConnection); if (selectedConnectionType == null) { fConnectionCombo.select(0); fConnectionCombo.setEnabled(false); fNewConnectionButton.setEnabled(false); } else { fConnectionCombo.setEnabled(true); int selected = 0; int offset = 1; Set<IRemoteConnection> sorted = new TreeSet<IRemoteConnection>(selectedConnectionType.getConnections()); for (IRemoteConnection s : sorted) { fConnectionCombo.add(s.getName()); if (conn != null && s.getName().equals(conn.getName())) { selected = offset; } offset++; } fConnectionCombo.select(selected); handleConnectionSelected(); fNewConnectionButton .setEnabled((selectedConnectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_ADD_CONNECTIONS) != 0); } } finally { fWidgetListener.setEnabled(enabled); } }

Target:
protected void handleRemoteServiceSelected(IRemoteConnection conn) { final boolean enabled = fWidgetListener.isEnabled(); fWidgetListener.disable(); try { IRemoteConnectionType selectedConnectionType = getSelectedConnectionType(); if (conn != null) { selectedConnectionType = conn.getConnectionType(); } if (fDefaultConnectionType == null && conn != null) { for (int index = 0; index < fConnectionTypes.size(); index++) { if (fConnectionTypes.get(index).getId().equals(selectedConnectionType.getId())) { fServicesCombo.select(index + 1); break; } } } fConnectionCombo.removeAll(); fConnectionCombo.add(Messages.RemoteConnectionWidget_selectConnection); if (selectedConnectionType == null) { fConnectionCombo.select(0); fConnectionCombo.setEnabled(false); fNewConnectionButton.setEnabled(false); } else { fConnectionCombo.setEnabled(true); int selected = 0; int offset = 1; Set<IRemoteConnection> sorted = new TreeSet<IRemoteConnection>(selectedConnectionType.getConnections()); for (IRemoteConnection s : sorted) { fConnectionCombo.add(s.getName()); if (conn != null && s.getName().equals(conn.getName())) { selected = offset; } offset++; } fConnectionCombo.select(selected); handleConnectionSelected(); fNewConnectionButton .setEnabled((selectedConnectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_ADD_CONNECTIONS) != 0); } } finally { fWidgetListener.setEnabled(enabled); } }
Source:
public void testPoll() { EasyMock.expect(dbi.withHandle(EasyMock.<HandleCallback>anyObject())).andReturn(testRows); EasyMock.expect(dbi.withHandle(EasyMock.<HandleCallback>anyObject())).andReturn(testRows); EasyMock.replay(dbi); manager.start(); manager.poll(); manager.stop(); }

Target:
public void testPoll() { EasyMock.expect(dbi.withHandle(EasyMock.<HandleCallback>anyObject())).andReturn(testRows).times(2); EasyMock.replay(dbi); manager.start(); manager.poll(); manager.stop(); }
Source:
public Response getDispoItemsById(@PathParam("fileName") String fileName) { if (!fileName.endsWith(".LIS")) { fileName = fileName.replaceAll("\\.(c|ad[ab])($|\\.).*", ".LIS"); } DispoSet set = dispoApi.getDispoSetById(branch, setId); String fullPath = set.getImportPath() + File.separator + "vcast" + File.separator + fileName; final File result = new File(fullPath); StreamingOutput streamingOutput = new StreamingOutput() { @Override public void write(OutputStream outputStream) throws WebApplicationException { FileInputStream inputStream = null; Writer writer = null; try { inputStream = new FileInputStream(result); writer = new OutputStreamWriter(outputStream, "UTF-8"); int c; while ((c = inputStream.read()) != -1) { writer.write(c); } outputStream.flush(); } catch (IOException ex) { throw new OseeCoreException(ex); } finally { Lib.close(inputStream); Lib.close(writer); } } }; String contentDisposition = String.format("attachment; filename=\"%s\"; creation-date=\"%s\"", fileName, new Date()); return Response.ok(streamingOutput).header("Content-Disposition", contentDisposition).type( "application/text").build(); }

Target:
public Response getDispoItemsById(@PathParam("fileName") String fileName) { if (!fileName.endsWith(".LIS")) { fileName = fileName.replaceAll("\\.(?i)(a|c|ad[ab])($|\\.).*", ".LIS"); } DispoSet set = dispoApi.getDispoSetById(branch, setId); String fullPath = set.getImportPath() + File.separator + "vcast" + File.separator + fileName; final File result = new File(fullPath); StreamingOutput streamingOutput = new StreamingOutput() { @Override public void write(OutputStream outputStream) throws WebApplicationException { FileInputStream inputStream = null; Writer writer = null; try { inputStream = new FileInputStream(result); writer = new OutputStreamWriter(outputStream, "UTF-8"); int c; while ((c = inputStream.read()) != -1) { writer.write(c); } outputStream.flush(); } catch (IOException ex) { throw new OseeCoreException(ex); } finally { Lib.close(inputStream); Lib.close(writer); } } }; String contentDisposition = String.format("attachment; filename=\"%s\"; creation-date=\"%s\"", fileName, new Date()); return Response.ok(streamingOutput).header("Content-Disposition", contentDisposition).type( "application/text").build(); }
Source:
@Override public List<? extends ItemGroup<?>> validDestinations(Item item) { List<DirectlyModifiableTopLevelItemGroup> result = new ArrayList<DirectlyModifiableTopLevelItemGroup>(); Jenkins instance = Jenkins.getActiveInstance(); if (permitted(item, instance)) { result.add(instance); } ITEM: for (Item g : instance.getAllItems()) { if (g instanceof DirectlyModifiableTopLevelItemGroup) { DirectlyModifiableTopLevelItemGroup itemGroup = (DirectlyModifiableTopLevelItemGroup) g; if (!permitted(item, itemGroup)) { continue; } ItemGroup<?> p = itemGroup; Item i = (Item) p; if (i == item || i == item.getParent()) { continue ITEM; } if (i instanceof Folder) { Folder folder = (Folder) i; if (folder.getItem(item.getName()) != null) { continue ITEM; } } result.add(itemGroup); } } return result; }

Target:
@Override public List<? extends ItemGroup<?>> validDestinations(Item item) { List<DirectlyModifiableTopLevelItemGroup> result = new ArrayList<DirectlyModifiableTopLevelItemGroup>(); Jenkins instance = Jenkins.getActiveInstance(); if (permitted(item, instance) && (instance.getItem(item.getName()) == null) || instance.getItem(item.getName()) == item) { result.add(instance); } ITEM: for (Item g : instance.getAllItems()) { if (g instanceof DirectlyModifiableTopLevelItemGroup) { DirectlyModifiableTopLevelItemGroup itemGroup = (DirectlyModifiableTopLevelItemGroup) g; if (!permitted(item, itemGroup)) { continue; } ItemGroup<?> p = itemGroup; if (p instanceof Item) { Item i = (Item) p; if (i == item) { continue ITEM; } if (item.getParent() == i) { result.add(itemGroup); } if (i instanceof Folder) { Folder folder = (Folder) i; if (folder.getItem(item.getName()) != null) { continue ITEM; } } ItemGroup itemGroupSubElement = i.getParent(); while (itemGroupSubElement != instance) { if (itemGroupSubElement instanceof Folder) { Folder currentFolder = (Folder) itemGroupSubElement; if (item == currentFolder) { continue ITEM; } itemGroupSubElement = currentFolder.getParent(); } } result.add(itemGroup); } } } return result; }
Source:
protected void doChmod(RemoteFileOperations<FTPFile> remoteFileOperations, final String path, final int chmod) { remoteFileOperations.executeWithClient((ClientCallbackWithoutResult<FTPClient>) client -> { String chModCommand = "chmod " + Integer.toOctalString(chmod) + " " + path; try { client.sendSiteCommand(chModCommand); } catch (IOException e) { throw new UncheckedIOException("Failed to execute chmod", e); } }); }

Target:
protected void doChmod(RemoteFileOperations<FTPFile> remoteFileOperations, final String path, final int chmod) { remoteFileOperations.executeWithClient((ClientCallbackWithoutResult<FTPClient>) client -> { String chModCommand = "chmod " + Integer.toOctalString(chmod) + " " + path; try { client.sendSiteCommand(chModCommand); } catch (IOException e) { throw new UncheckedIOException("Failed to execute '" + chModCommand + "'", e); } }); }
Source:
Subscriber getSubscriber() { return subscriber; }

Target:
SubscriptionState getSubscriber() { return subscriber; }
Source:
public String getLiteral() { return ",".equals(defaultDelimiter) ? "comma" : "tab"; }

Target:
public String getLiteral() { return literal; }
Source:
public void invoke(RowData value, Context context) throws Exception { RowKind kind = value.getRowKind(); if (value.getRowKind() == RowKind.INSERT) { Row row = (Row) converter.toExternal(value); assert row != null; if (rowtimeIndex >= 0) { TimestampData rowtime = TimestampData.fromLocalDateTime((LocalDateTime) row.getField(rowtimeIndex)); long mark = context.currentWatermark(); if (mark > rowtime.getMillisecond()) { return; } } localRawResult.add(kind.shortString() + "(" + row.toString() + ")"); } else { throw new RuntimeException( "AppendingSinkFunction received " + value.getRowKind() + " messages."); } }

Target:
public void invoke(RowData value, Context context) throws Exception { RowKind kind = value.getRowKind(); if (value.getRowKind() == RowKind.INSERT) { Row row = (Row) converter.toExternal(value); assert row != null; if (rowtimeIndex >= 0) { TimestampData rowtime = value.getTimestamp(rowtimeIndex, 3); long mark = context.currentWatermark(); if (mark > rowtime.getMillisecond()) { return; } } localRawResult.add(kind.shortString() + "(" + row.toString() + ")"); } else { throw new RuntimeException( "AppendingSinkFunction received " + value.getRowKind() + " messages."); } }
Source:
public void applyEntityCollision(Entity entity) { if (entity.riding != this && entity.linkedEntity != this) { double dx = entity.x - this.x; double dy = entity.z - this.z; double dz = NukkitMath.getDirection(dx, dy); if (dz >= 0.009999999776482582D) { dz = MathHelper.sqrt((float) dz); dx /= dz; dy /= dz; double d3 = 1.0D / dz; if (d3 > 1.0D) { d3 = 1.0D; } dx *= d3; dy *= d3; dx *= 0.05000000074505806D; dy *= 0.05000000074505806D; dx *= 1.0F + entityCollisionReduction; dz *= 1.0F + entityCollisionReduction; if (this.riding == null) { motionX += -dx; motionZ += -dy; } } } }

Target:
public void applyEntityCollision(Entity entity) { if (entity.riding != this && entity.linkedEntity != this) { double dx = entity.x - this.x; double dy = entity.z - this.z; double dz = NukkitMath.getDirection(dx, dy); if (dz >= 0.009999999776482582D) { dz = MathHelper.sqrt((float) dz); dx /= dz; dy /= dz; double d3 = 1.0D / dz; if (d3 > 1.0D) { d3 = 1.0D; } dx *= d3; dy *= d3; dx *= 0.05000000074505806D; dy *= 0.05000000074505806D; dx *= 1.0F + entityCollisionReduction; dz *= 1.0F + entityCollisionReduction; if (this.riding == null) { motionX -= dx; motionZ -= dy; } } } }
Source:
private MainThread[] startQuorum() throws IOException { final int[] clientPorts = new int[SERVER_COUNT]; StringBuilder sb = new StringBuilder(); String server; for (int i = 0; i < SERVER_COUNT; i++) { clientPorts[i] = PortAssignment.unique(); server = "server." + i + "=127.0.0.1:" + PortAssignment.unique() + ":" + PortAssignment.unique() + ":participant;127.0.0.1:" + clientPorts[i]; sb.append(server + "\n"); } String currentQuorumCfgSection = sb.toString(); MainThread[] mt = new MainThread[SERVER_COUNT]; for (int i = 0; i < SERVER_COUNT; i++) { mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false) { @Override public TestQPMain getTestQPMain() { return new MockTestQPMain(); } }; mt[i].start(); } for (int i = 0; i < SERVER_COUNT; i++) { Assert.assertTrue("waiting for server " + i + " being up", ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i], CONNECTION_TIMEOUT)); } return mt; }

Target:
private MainThread[] startQuorum() throws IOException { final int[] clientPorts = new int[SERVER_COUNT]; StringBuilder sb = new StringBuilder(); String server; for (int i = 0; i < SERVER_COUNT; i++) { clientPorts[i] = PortAssignment.unique(); server = "server." + i + "=127.0.0.1:" + PortAssignment.unique() + ":" + PortAssignment.unique() + ":participant;127.0.0.1:" + clientPorts[i]; sb.append(server + "\n"); } String currentQuorumCfgSection = sb.toString(); MainThread[] mt = new MainThread[SERVER_COUNT]; for (int i = 0; i < SERVER_COUNT; i++) { mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false) { @Override public TestQPMain getTestQPMain() { return new MockTestQPMain(); } }; mt[i].start(); } for (int i = 0; i < SERVER_COUNT; i++) { assertTrue( "waiting for server " + i + " being up", ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i], CONNECTION_TIMEOUT)); } return mt; }