auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public String getCardType() { <END> return cardType; }</code><technical_language>this is optional do a != null this returning Optional<String></technical_language>

Target:
public Optional<String> getCardType() { return Optional.ofNullable(cardType); }
Source:
<code><START> public static String selfRedirect(String suffix) { <END> String path = Location.getPath(); if (path == null || path.isEmpty()) { path = "/"; } else { while (path.startsWith(" path = path.substring(1); } while (path.endsWith(" path = path.substring(0, path.length() - 1); } if (!path.endsWith("/")) { path = path + "/"; } } if (suffix != null) { while (suffix.startsWith("/")) { suffix = suffix.substring(1); } path += suffix; } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String port = Location.getPort(); if (port != null && !port.isEmpty()) { builder.setPort(Integer.parseInt(port)); } return builder.buildString() + path; }</code><technical_language>Method is called other loginRedirect, assume input is encoded</technical_language>

Target:
public static String selfRedirect(String suffix) { String path = Location.getPath(); if (path == null || path.isEmpty()) { path = "/"; } else { while (path.startsWith(" path = path.substring(1); } while (path.endsWith(" path = path.substring(0, path.length() - 1); } if (!path.endsWith("/")) { path = path + "/"; } } if (suffix != null) { while (suffix.startsWith("/")) { suffix = suffix.substring(1); } path += suffix; } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String port = Location.getPort(); if (port != null && !port.isEmpty()) { builder.setPort(Integer.parseInt(port)); } builder.setPath(path); return builder.buildString(); }
Source:
<code>protected void addSlots() { if (itemConduit != null) { addSlotToContainer(slotInputFilter = new FilterSlot(getItemHandler(), 3, 23, 71)); addSlotToContainer(slotOutputFilter = new FilterSlot(getItemHandler(), 2, 113, 71)); addSlotToContainer(slotSpeedUpgrades = new SlotItemHandler(getItemHandler(), 0, 131, 71) { @Override public boolean isItemValid(@Nonnull ItemStack itemStack) { <START> return itemStack.getItem() instanceof ItemExtractSpeedUpgrade; <END> } @Override public int getSlotStackLimit() { return speedUpgradeSlotLimit; } }); addSlotToContainer(slotFunctionUpgrades = new SlotItemHandler(getItemHandler(), 1, 157, 71) { @Override public boolean isItemValid(@Nonnull ItemStack itemStack) { return false; } @Override public int getSlotStackLimit() { return 1; } }); } }</code><technical_language>why</technical_language>

Target:
protected void addSlots() { if (itemConduit != null) { addSlotToContainer(slotInputFilter = new FilterSlot(getItemHandler(), 3, 23, 71)); addSlotToContainer(slotOutputFilter = new FilterSlot(getItemHandler(), 2, 113, 71)); addSlotToContainer(slotSpeedUpgrades = new SlotItemHandler(getItemHandler(), 0, 131, 71) { @Override public boolean isItemValid(@Nonnull ItemStack itemStack) { return inventory.isItemValidForSlot(0, itemStack); } @Override public int getSlotStackLimit() { return speedUpgradeSlotLimit; } }); addSlotToContainer(slotFunctionUpgrades = new SlotItemHandler(getItemHandler(), 1, 157, 71) { @Override public boolean isItemValid(@Nonnull ItemStack itemStack) { return false; } @Override public int getSlotStackLimit() { return 1; } }); } }
Source:
<code>public boolean hasNext() { if (dataStream == null) { return false; } if (currentIterator == null || !currentIterator.hasNext()) { try { if (pageIndex < pageSizeArray.length) { byte[] nextPage = new byte[pageSizeArray[pageIndex]]; dataStream.read(nextPage); currentPage = new CookiePage(nextPage); currentIterator = currentPage.iterator(); } else { closeStream(); return false; } pageIndex++; } catch (IOException ex) { closeStream(); <START> logger.log(Level.WARNING, "A read error occured for file {0} page {1} {2}", new Object[]{cookieFile.getName(), pageIndex, ex}); END> return false; } } return currentIterator.hasNext(); }</code><technical_language>exception fourth argument method is logged causing exception a full stack trace - throw debugging data</technical_language>

Target:
public boolean hasNext() { if (dataStream == null) { return false; } if (currentIterator == null || !currentIterator.hasNext()) { try { if (pageIndex < pageSizeArray.length) { byte[] nextPage = new byte[pageSizeArray[pageIndex]]; dataStream.read(nextPage); currentPage = new CookiePage(nextPage); currentIterator = currentPage.iterator(); } else { closeStream(); return false; } pageIndex++; } catch (IOException ex) { closeStream(); String errorMessage = String.format("A read error occured for file %s (pageIndex = %d)", cookieFile.getName(), pageIndex); LOG.log(Level.WARNING, errorMessage, ex); return false; } } return currentIterator.hasNext(); }
Source:
<code>public byte[] transform(ClassLoader classLoader, String className, Class<?> aClass, ProtectionDomain protectionDomain, byte[] originalBuffer) throws IllegalClassFormatException { <START> byte[] transformedBuffer = originalBuffer; <END> boolean transformed = false; for (javax.persistence.spi.ClassTransformer transformer : persistenceUnitMetadata.getTransformers()) { byte[] result = transformer.transform(classLoader, className, aClass, protectionDomain, transformedBuffer); if (result != null) { transformedBuffer = result; transformed = true; } } return transformed ? transformedBuffer : null; }</code><technical_language>introduced new method, logic in place. This method delegate simply calling transform(classLoader, className, protectionDomain, ByteBuffer.wrap(originalBuffer)). factor out a private utility method 'convert' ByteBuffer array in methods</technical_language>

Target:
public byte[] transform(ClassLoader classLoader, String className, Class<?> aClass, ProtectionDomain protectionDomain, byte[] originalBuffer) { return getBytes(transform(classLoader, className, protectionDomain, ByteBuffer.wrap(originalBuffer))); }
Source:
<code>protected Stream<T> fetchFromProvider(int offset, int limit) { Stream<T> stream; QueryTrace query = null; if (pagingEnabled) { final int pages = (limit - 1) / pageSize + 1; if (limit > pageSize) { final Collection<T> fetchedPages = new LinkedList<>(); for (int page = 0; page < pages; page++) { final int newOffset = offset + page * pageSize; query = new QueryTrace(newOffset, pageSize, backEndSorting, inMemorySorting, filter); Stream<T> fetchedPageStream = getDataProvider().fetch(query); List<T> fetchedPage = <START> fetchedPageStream.collect(Collectors.toList()); <END> fetchedPages.addAll(fetchedPage); if (fetchedPage.size() < pageSize) { break; } } stream = fetchedPages.stream(); } else { query = new QueryTrace(offset, pageSize, backEndSorting, inMemorySorting, filter); stream = getDataProvider().fetch(query); } limit = pages * pageSize; } else { query = new QueryTrace(offset, limit, backEndSorting, inMemorySorting, filter); stream = getDataProvider().fetch(query); } if (stream.isParallel()) { LoggerFactory.getLogger(DataCommunicator.class) .debug("Data provider has returned " + "parallel stream on 'fetch' call", getDataProvider().getClass()); stream = stream.collect(Collectors.toList()).stream(); assert !stream.isParallel(); } SizeVerifier verifier = new SizeVerifier<>(limit); stream = stream.peek(verifier); assert query != null : "Fetch query cannot be null"; if (!query.isLimitCalled()) { throw new IllegalStateException( getInvalidContractMessage("getLimit or getPageSize")); } if (!query.isOffsetCalled()) { throw new IllegalStateException( getInvalidContractMessage("getOffset or getPage")); } return stream; }</code><technical_language>fine, if this is added I if in method, if means returning a holder object query is needed for checks end</technical_language>

Target:
protected Stream<T> fetchFromProvider(int offset, int limit) { Stream<T> stream; if (pagingEnabled) { final int pages = (limit - 1) / pageSize + 1; if (limit > pageSize) { final Stream.Builder<T> streamBuilder = Stream.builder(); final AtomicInteger fetchedPerPage = new AtomicInteger(0); Consumer<T> addItemAndCheckConsumer = item -> { streamBuilder.add(item); fetchedPerPage.getAndIncrement(); }; int page = 0; do { final int newOffset = offset + page * pageSize; doFetchFromDataProvider(newOffset, pageSize) .forEach(addItemAndCheckConsumer); page++; } while (page < pages && fetchedPerPage.getAndSet(0) == pageSize); stream = streamBuilder.build(); } else { stream = doFetchFromDataProvider(offset, pageSize); } limit = pages * pageSize; } else { stream = doFetchFromDataProvider(offset, limit); } if (stream.isParallel()) { LoggerFactory.getLogger(DataCommunicator.class) .debug("Data provider has returned " + "parallel stream on 'fetch' call", getDataProvider().getClass()); stream = stream.collect(Collectors.toList()).stream(); assert !stream.isParallel(); } SizeVerifier verifier = new SizeVerifier<>(limit); return stream.peek(verifier); }
Source:
<code>public void replicateNewProject(Project.NameKey projectName, String head) { if (!isEnabled()) { return; } for (ReplicationConfig config : configs) { List<URIish> uriList = config.getURIs(projectName, "*"); String adminUrl = config.getAdminUrl(); URIish adminURI = null; try { if (adminUrl != null && !adminUrl.isEmpty()) { adminURI = new URIish(adminUrl); } } catch (URISyntaxException e) { } boolean adminURLUsed = false; if (adminURI != null) { final String replacedPath = replace(adminURI.getPath(), "name", projectName.get()); if (replacedPath != null) { adminURI = adminURI.setPath(replacedPath); <START> if (usingSSH(adminURI)) { <END> replicateProject(adminURI, head); adminURLUsed = true; } } } if (!adminURLUsed) { for (URIish uri : uriList) { replicateProject(uri, head); } } } }</code><technical_language>ignore a non-SSH admin URL? OK, I admit other URL type support project creation right now. if a non-SSH admin URL admin, a configuration error. log a message it</technical_language>

Target:
public void replicateNewProject(Project.NameKey projectName, String head) { if (!isEnabled()) { return; } for (ReplicationConfig config : configs) { List<URIish> uriList = config.getURIs(projectName, "*"); String[] adminUrls = config.getAdminUrls(); boolean adminURLUsed = false; for (String url : adminUrls) { URIish adminURI = null; try { if (url != null && !url.isEmpty()) { adminURI = new URIish(url); } } catch (URISyntaxException e) { log.error("The URL '" + url + "' is invalid"); } if (adminURI != null) { final String replacedPath = replace(adminURI.getPath(), "name", projectName.get()); if (replacedPath != null) { adminURI = adminURI.setPath(replacedPath); if (usingSSH(adminURI)) { replicateProject(adminURI, head); adminURLUsed = true; } else { log.error("The adminURL '" + url + "' is non-SSH which is not allowed"); } } } } if (!adminURLUsed) { for (URIish uri : uriList) { replicateProject(uri, head); } } } }
Source:
<code>protected boolean requireRootAclUpdate( ACLEditor editor ) throws RepositoryException { final String rootPath = session.getRootNode().getPath(); final AccessControlPolicy[] acls = editor.getPolicies( rootPath ); if ( acls != null && acls.length > 0 ) { final PrincipalManager pMgr = session.getPrincipalManager(); final AccessControlManager acMgr = session.getAccessControlManager(); final Privilege jcrReadAccessControlPriv = acMgr.privilegeFromName( Privilege.JCR_READ_ACCESS_CONTROL ); final Principal everyone = pMgr.getEveryone(); final AccessControlList acList = (AccessControlList) acls[0]; final AccessControlEntry[] acEntries = acList.getAccessControlEntries(); if ( acEntries != null ) { for ( AccessControlEntry acEntry : acEntries ) { if ( acEntry.getPrincipal() != null && acEntry.getPrincipal().equals( everyone ) ) { if ( acEntry.getPrivileges() != null ) { for ( Privilege privilege : acEntry.getPrivileges() ) { if ( jcrReadAccessControlPriv.equals( privilege ) ) { return false; } } } <START> } <END> } } } return true; }</code><technical_language>if logic is below? if ( acEntry.getPrincipal() != null && acEntry.getPrincipal().equals( ) && acEntry.getPrivileges() != null ) { return !Arrays.asList( acEntry.getPrivileges() ).contains( jcrReadAccessControlPriv ); }</technical_language>

Target:
protected boolean requireRootAclUpdate( ACLEditor editor ) throws RepositoryException { final String rootPath = session.getRootNode().getPath(); final AccessControlPolicy[] acls = editor.getPolicies( rootPath ); if ( acls != null && acls.length > 0 ) { final PrincipalManager pMgr = session.getPrincipalManager(); final AccessControlManager acMgr = session.getAccessControlManager(); final Privilege jcrReadAccessControlPriv = acMgr.privilegeFromName( Privilege.JCR_READ_ACCESS_CONTROL ); final Principal everyone = pMgr.getEveryone(); final AccessControlList acList = (AccessControlList) acls[0]; final AccessControlEntry[] acEntries = acList.getAccessControlEntries(); if ( acEntries != null ) { for ( AccessControlEntry acEntry : acEntries ) { if ( acEntry.getPrincipal() != null && acEntry.getPrincipal().equals( everyone ) && acEntry.getPrivileges() != null ) { return !Arrays.asList( acEntry.getPrivileges() ).contains( jcrReadAccessControlPriv ); } } } } return true; }
Source:
<code>private boolean isDiskImage() { <START> return getOldDisk() != null && getNewDisk() != null && DiskStorageType.IMAGE == getOldDisk().getDiskStorageType(); <END> }</code><technical_language>Suggestion: Please change this method called isDiskType(DiskStorageType diskStorageType) for Cinder</technical_language>

Target:
private boolean isDiskImage() { return isDiskStorageType(DiskStorageType.IMAGE); }
Source:
<code>public void theMbusDeviceIsNotCoupledToTheDevice(final String gMeter, final String eMeter) { Wait.until(() -> { final SmartMeter mbusDevice = this.smartMeterRepository.findByDeviceIdentification(gMeter); final Device gatewayDevice = this.deviceRepository.findByDeviceIdentification(eMeter); Assert.assertNotNull("No GatewayDevice found", gatewayDevice); Assert.assertNotNull("No MbusDevice found", mbusDevice); <START> Assert.assertNotEquals("GatewayDevice must be coupled to other MbusDevice", gatewayDevice, <END> mbusDevice.getGatewayDevice()); }); }</code><technical_language>a message "mBusDevice coupled this gatewayDevice" is more in line step, this is called: theMbusDeviceIsNotCoupledToTheDevice</technical_language>

Target:
public void theMbusDeviceIsNotCoupledToTheDevice(final String gMeter, final String eMeter) { Wait.until(() -> { final SmartMeter mbusDevice = this.smartMeterRepository.findByDeviceIdentification(gMeter); final Device gatewayDevice = this.deviceRepository.findByDeviceIdentification(eMeter); Assert.assertNotNull("No GatewayDevice found", gatewayDevice); Assert.assertNotNull("No MbusDevice found", mbusDevice); Assert.assertNotEquals("MbusDevice should not be coupled to this GatewayDevice", gatewayDevice, mbusDevice.getGatewayDevice()); }); }
Source:
<code>public String toString() { <START> return "ConstraintCheckError [annotationMirror=" + annotationMirror <END> + ", element=" + element + ", messageKey=" + messageKey + ", messageParameters=" + Arrays.toString( messageParameters ) + "]"; }</code><technical_language>ConstraintCheckError=ConstraintCheckIssue</technical_language>

Target:
public String toString() { return "ConstraintCheckIssue [annotationMirror=" + annotationMirror + ", element=" + element + ", kind=" + kind + ", messageKey=" + messageKey + ", messageParameters=" + Arrays.toString( messageParameters ) + "]"; }
Source:
<code>public void <START> testSimpleCaseHorizontallyNodeSelectionEdgeSelectableZonePresent() <END> { openDiagram(DIAGRAM_DESCRIPTION, DIAGRAM_INSTANCE_NAME); SWTBotGefEditPart sourceNodePart = editor.getEditPart("C2"); Point sourceNodePartLocation = editor.getLocation(sourceNodePart); CheckSelectedCondition checkc1Selected = new CheckSelectedCondition(editor, sourceNodePart.part().getParent()); editor.click(new Point(sourceNodePartLocation.x - 7, sourceNodePartLocation.y)); bot.waitUntil(checkc1Selected); }</code><technical_language>test similar, able extract a method a parameter: label of source/target edit part, edge edit part select (if needed), int in position computation clicking..</technical_language>

Target:
public void testSimpleCaseHorizontallyNodeSelectionEdgeSelectableZonePresent() { openDiagram(DIAGRAM_DESCRIPTION, DIAGRAM_INSTANCE_NAME, ZoomLevel.ZOOM_75); SWTBotGefEditPart sourceNodePart = editor.getEditPart("C2"); Point sourceNodePartLocation = editor.getLocation(sourceNodePart); CheckSelectedCondition checkc1Selected = new CheckSelectedCondition(editor, sourceNodePart.part().getParent()); editor.click(new Point(sourceNodePartLocation.x - LENGTH_TO_REACH_LAST_PIXEL_OF_EXPANDED_NODE, sourceNodePartLocation.y)); bot.waitUntil(checkc1Selected); }
Source:
<code><START> private String createIntermediateTable() { <END> if (DbConnectionFactory.isMySql()) { return MYSQL_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isPostgres()) { return POSTGRES_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isMsSql()) { return MSSQL_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isOracle()) { return ORACLE_CREATE_INTERMEDIATE_TABLE; } else { return StringUtils.EMPTY; } }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Reduce number of returns of this method 5, maximum allowed 3. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
private String createIntermediateTable() { String sql = StringUtils.EMPTY; if (DbConnectionFactory.isMySql()) { sql = MYSQL_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isPostgres()) { sql = POSTGRES_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isMsSql()) { sql = MSSQL_CREATE_INTERMEDIATE_TABLE; } else if (DbConnectionFactory.isOracle()) { sql = ORACLE_CREATE_INTERMEDIATE_TABLE; } return sql; }
Source:
<code><START> Parent( String parentAttribute ) { <END> this.parentAttribute = parentAttribute; }</code><technical_language>public</technical_language>

Target:
public Parent( String parentAttribute ) { this.parentAttribute = parentAttribute; }
Source:
<code><START> @Before public void prepareTest() throws Exception{ <END> Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); conn = DriverManager.getConnection(getUrl(), props); schemaName = generateUniqueName(); dataTableName = generateUniqueName(); viewName = generateUniqueName(); dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); viewFullName = SchemaUtil.getTableName(schemaName, viewName); globalIndexName = generateUniqueName(); globalIndexFullName = SchemaUtil.getTableName(schemaName, globalIndexName); createTestTable(getUrl(), String.format(DATA_TABLE_DDL, dataTableFullName)); createTestTable(getUrl(), String.format(VIEW_DDL, viewFullName, dataTableFullName)); String dataTableUpsert = String.format(UPSERT_SQL, dataTableFullName); PreparedStatement stmt = conn.prepareStatement(dataTableUpsert); upsertRow(stmt, "tenantID1",1, "name1", 9991); upsertRow(stmt, "tenantID1",2, "name2", 9992); upsertRow(stmt, "tenantID1",3, "name3", 9993); conn.commit(); }</code><technical_language>nit: new line space opening braces</technical_language>

Target:
public void prepareTest() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); conn = DriverManager.getConnection(getUrl(), props); schemaName = generateUniqueName(); dataTableName = generateUniqueName(); viewName = generateUniqueName(); dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); viewFullName = SchemaUtil.getTableName(schemaName, viewName); globalIndexName = "GLBL_IDX_" + generateUniqueName(); globalIndexFullName = SchemaUtil.getTableName(schemaName, globalIndexName); createTestTable(getUrl(), String.format(DATA_TABLE_DDL, dataTableFullName)); createTestTable(getUrl(), String.format(VIEW_DDL, viewFullName, dataTableFullName)); String dataTableUpsert = String.format(UPSERT_SQL, dataTableFullName); PreparedStatement stmt = conn.prepareStatement(dataTableUpsert); for (int i=1; i < 4; i++) { upsertRow(stmt, "tenantID1", i, "name" + i, 9990+i); } conn.commit(); }
Source:
<code>public Collection<IProjectAdapter> getProjectsFor(final IOpenShiftConnection conn) { String key = getCacheKey(conn); Set<IProjectAdapter> adapters = null; if (!contains(key)) { adapters = createEntry(key); Collection<IProject> projects = conn.<IProject>getResources(ResourceKind.PROJECT); for (IProject project : projects) { IProjectAdapter adapter = addNewProjectAdapter(adapters, conn, project); notifyAdd(adapter); } } else { adapters = getEntry(key); } <START> return new ArrayList<>(adapters); <END> }</code><technical_language>A hole. Creating list synchronized adapters</technical_language>

Target:
public Collection<IProjectAdapter> getProjectsFor(final IOpenShiftConnection conn) { String key = getCacheKey(conn); Set<IProjectAdapter> adapters = getOrCreateEntry(key); if (adapters.isEmpty()) { Collection<IProject> projects = conn.<IProject>getResources(ResourceKind.PROJECT); for (IProject project : projects) { IProjectAdapter adapter = addNewProjectAdapter(adapters, conn, project); notifyAdd(adapter); } } else { adapters = getEntry(key); } return new ArrayList<>(adapters); }
Source:
<code>public void setRequestInputStream(InputStream is) { ClonedInputStream cis = new ClonedInputStream(is); is = cis; try { while (cis.read() != -1) { } } catch (IOException ioe) { <START> <END> } copy = cis.getOutput(); int size = copy.size(); if (size != 0) size--; inputStreamEntity = new RepeatableInputStreamRequestEntity(new ByteArrayInputStream(copy.toByteArray()), size); }</code><technical_language>handle exception</technical_language>

Target:
public void setRequestInputStream(InputStream is) { ClonedInputStream cis = new ClonedInputStream(is); is = cis; try { while (cis.read() != -1) { } } catch (IOException ioe) { LOG.warn("Error reading input stream", ioe); } copy = cis.getOutput(); int size = copy.size(); if (size != 0) size--; inputStreamEntity = new RepeatableInputStreamRequestEntity(new ByteArrayInputStream(copy.toByteArray()), size); }
Source:
<code>protected void doRun() throws Exception { List<GitHubRepositoryName> names; synchronized (this) { names = new ArrayList<GitHubRepositoryName>(couldHaveBeenRemoved); couldHaveBeenRemoved.clear(); } <START> for (Job<?,?> job : Jenkins.getInstance().getAllItems(Job.class)) { <END> ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) job; for (Trigger trigger : pJob.getTriggers().values()) { if(trigger instanceof GitHubPushTrigger) { names.removeAll(GitHubRepositoryNameContributor.parseAssociatedNames(job)); break; } } } OUTER: for (GitHubRepositoryName r : names) { for (GHRepository repo : r.resolve()) { try { removeHook(repo, Trigger.all().get(DescriptorImpl.class).getHookUrl()); LOGGER.info("Removed a hook from "+r+""); continue OUTER; } catch (Throwable e) { LOGGER.log(Level.WARNING,"Failed to remove hook from "+r,e); } } } }</code><technical_language>I need add a null check Jenkins.getInstance(). Otherwise, FindBugs errors I think</technical_language>

Target:
protected void doRun() throws Exception { URL url = GitHubPlugin.configuration().getHookUrl(); List<Job> jobs = Jenkins.getInstance().getAllItems(Job.class); List<GitHubRepositoryName> aliveRepos = from(jobs) .filter(isAlive()) .transformAndConcat(associatedNames()).toList(); while (!сleanQueue.isEmpty()) { GitHubRepositoryName name = сleanQueue.poll(); WebhookManager.forHookUrl(url).unregisterFor(name, aliveRepos); } }
Source:
<code>public Order cloneForRevision() { DrugOrder newOrder = new DrugOrder(); newOrder.setCareSetting(this.getCareSetting()); newOrder.setConcept(this.getConcept()); newOrder.setAction(Action.REVISE); newOrder.setPreviousOrder(this); newOrder.setPatient(this.getPatient()); <START> newOrder.setOrderer(this.getOrderer()); <END> newOrder.setInstructions(this.getInstructions()); newOrder.setUrgency(this.getUrgency()); newOrder.setCommentToFulfiller(this.getCommentToFulfiller()); newOrder.setAccessionNumber(this.getAccessionNumber()); newOrder.setAutoExpireDate(this.getAutoExpireDate()); newOrder.setOrderReason(this.getOrderReason()); newOrder.setOrderReasonNonCoded(this.getOrderReasonNonCoded()); newOrder.setDose(this.getDose()); newOrder.setDoseUnits(this.getDoseUnits()); newOrder.setFrequency(this.getFrequency()); newOrder.setAsNeeded(this.getAsNeeded()); newOrder.setAsNeededCondition(this.getAsNeededCondition()); newOrder.setQuantity(this.getQuantity()); newOrder.setQuantityUnits(this.getQuantityUnits()); newOrder.setDrug(this.getDrug()); newOrder.setDosingType(this.getDosingType()); newOrder.setDosingInstructions(this.getDosingInstructions()); newOrder.setDuration(this.getDuration()); newOrder.setDurationUnits(this.getDurationUnits()); newOrder.setRoute(this.getRoute()); newOrder.setAdministrationInstructions(this.getAdministrationInstructions()); newOrder.setNumRefills(this.getNumRefills()); return newOrder; }</code><technical_language>here, copy orderer</technical_language>

Target:
public Order cloneForRevision() { DrugOrder newOrder = new DrugOrder(); newOrder.setCareSetting(this.getCareSetting()); newOrder.setConcept(this.getConcept()); newOrder.setAction(Action.REVISE); newOrder.setPreviousOrder(this); newOrder.setPatient(this.getPatient()); newOrder.setInstructions(this.getInstructions()); newOrder.setUrgency(this.getUrgency()); newOrder.setCommentToFulfiller(this.getCommentToFulfiller()); newOrder.setAccessionNumber(this.getAccessionNumber()); newOrder.setAutoExpireDate(this.getAutoExpireDate()); newOrder.setOrderReason(this.getOrderReason()); newOrder.setOrderReasonNonCoded(this.getOrderReasonNonCoded()); newOrder.setDose(this.getDose()); newOrder.setDoseUnits(this.getDoseUnits()); newOrder.setFrequency(this.getFrequency()); newOrder.setAsNeeded(this.getAsNeeded()); newOrder.setAsNeededCondition(this.getAsNeededCondition()); newOrder.setQuantity(this.getQuantity()); newOrder.setQuantityUnits(this.getQuantityUnits()); newOrder.setDrug(this.getDrug()); newOrder.setDosingType(this.getDosingType()); newOrder.setDosingInstructions(this.getDosingInstructions()); newOrder.setDuration(this.getDuration()); newOrder.setDurationUnits(this.getDurationUnits()); newOrder.setRoute(this.getRoute()); newOrder.setAdministrationInstructions(this.getAdministrationInstructions()); newOrder.setNumRefills(this.getNumRefills()); return newOrder; }
Source:
<code>public static boolean openRepositoryTask(String connectorKind, String repositoryUrl, String id, TaskOpenListener listener, long timestamp) { String taskUrl = getTaskUrl(connectorKind, repositoryUrl, id); if (taskUrl == null) { return false; } IWorkbenchWindow window = getWindow(); if (window == null) { return false; } IWorkbenchPage page = window.getActivePage(); <START> OpenRepositoryTaskJob job = new OpenRepositoryTaskJob(connectorKind, repositoryUrl, id, taskUrl, timestamp, page); job.setListener(listener); job.schedule(); return true; <END> }</code><technical_language>this return tryOpen method result</technical_language>

Target:
public static boolean openRepositoryTask(String connectorKind, String repositoryUrl, String id, TaskOpenListener listener, long timestamp) { String taskUrl = getTaskUrl(connectorKind, repositoryUrl, id); if (taskUrl == null) { return false; } IWorkbenchWindow window = getWorkbenchWindow(); if (window == null) { return false; } IWorkbenchPage page = window.getActivePage(); OpenRepositoryTaskJob job = new OpenRepositoryTaskJob(connectorKind, repositoryUrl, id, taskUrl, timestamp, page); job.setListener(listener); job.schedule(); return true; }
Source:
<code>public void configure(Binder binder) { binder.bind(RaptorConnectorId.class).toInstance(new RaptorConnectorId(connectorId)); binder.bind(RaptorConnector.class).in(Scopes.SINGLETON); binder.bind(RaptorMetadataFactory.class).in(Scopes.SINGLETON); binder.bind(RaptorSplitManager.class).in(Scopes.SINGLETON); binder.bind(RaptorPageSourceProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorHandleResolver.class).in(Scopes.SINGLETON); binder.bind(RaptorNodePartitioningProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorSessionProperties.class).in(Scopes.SINGLETON); binder.bind(RaptorTableProperties.class).in(Scopes.SINGLETON); <START> binder.bind(TemporalFunction.class).in(Scopes.SINGLETON); <END> Multibinder<SystemTable> tableBinder = newSetBinder(binder, SystemTable.class); tableBinder.addBinding().to(ShardMetadataSystemTable.class).in(Scopes.SINGLETON); tableBinder.addBinding().to(TableMetadataSystemTable.class).in(Scopes.SINGLETON); tableBinder.addBinding().to(TableStatsSystemTable.class).in(Scopes.SINGLETON); }</code><technical_language>Move this binding StorageModule</technical_language>

Target:
public void configure(Binder binder) { binder.bind(RaptorConnectorId.class).toInstance(new RaptorConnectorId(connectorId)); binder.bind(RaptorConnector.class).in(Scopes.SINGLETON); binder.bind(RaptorMetadataFactory.class).in(Scopes.SINGLETON); binder.bind(RaptorSplitManager.class).in(Scopes.SINGLETON); binder.bind(RaptorPageSourceProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorHandleResolver.class).in(Scopes.SINGLETON); binder.bind(RaptorNodePartitioningProvider.class).in(Scopes.SINGLETON); binder.bind(RaptorSessionProperties.class).in(Scopes.SINGLETON); binder.bind(RaptorTableProperties.class).in(Scopes.SINGLETON); Multibinder<SystemTable> tableBinder = newSetBinder(binder, SystemTable.class); tableBinder.addBinding().to(ShardMetadataSystemTable.class).in(Scopes.SINGLETON); tableBinder.addBinding().to(TableMetadataSystemTable.class).in(Scopes.SINGLETON); tableBinder.addBinding().to(TableStatsSystemTable.class).in(Scopes.SINGLETON); }
Source:
<code>private void pausePartitions() { _logger.info("About to pause partitions."); Validate.isTrue(_consumer != null, "Consumer cannot be null when pausing partitions."); _pausedPartitionsUpdatedCount++; Set<TopicPartition> currentPausedPartitions = _consumer.paused(); Set<TopicPartition> currentAssignedPartitions = _consumer.assignment(); _logger.info("Current partition assignment for task is: {}, and paused partitions are: {}", _taskName, currentAssignedPartitions, currentPausedPartitions); Set<TopicPartition> partitionsToResume = getPartitionsToResume(currentPausedPartitions, _pausedSourcePartitions, _autoPausedSourcePartitions); if (!partitionsToResume.isEmpty()) { _logger.info("Partitions to resume for task are {}", _taskName, partitionsToResume); _consumer.resume(partitionsToResume); _logger.info("Resumed these partitions: {}", partitionsToResume); } else { _logger.debug("No partitions to resume for task {}", _taskName); } Set<TopicPartition> partitionsToPause = getPartitionsToPause(currentAssignedPartitions, currentPausedPartitions, _pausedSourcePartitions, _autoPausedSourcePartitions); if (!partitionsToPause.isEmpty()) { _logger.info("Partitions to pause for task are {}", _taskName, partitionsToPause); _consumer.pause(partitionsToPause); _logger.info("Paused these partitions: {}", partitionsToPause); } else { _logger.debug("No partitions to pause for task {}", _taskName); } <START> _taskUpdates.remove(DatastreamConstants.UpdateType.PAUSE_RESUME_PARTITIONS); <END> }</code><technical_language>remove this? pop head of queue calling pausePartitions() in preConsumerPollHook()</technical_language>

Target:
private void pausePartitions() { _logger.info("Checking for partitions to pause or resume."); Validate.isTrue(_consumer != null, "Consumer cannot be null when pausing partitions."); _pausedPartitionsConfigUpdateCount++; Set<TopicPartition> currentPausedPartitions = _consumer.paused(); Set<TopicPartition> currentAssignedPartitions = _consumer.assignment(); _logger.info("Current partition assignment for task is: {}, and paused partitions are: {}", _taskName, currentAssignedPartitions, currentPausedPartitions); _logger.info("Current auto-pause partition set is: {}", _autoPausedSourcePartitions); _consumer.resume(currentPausedPartitions); Set<TopicPartition> partitionsToPause = determinePartitionsToPause(currentAssignedPartitions, _pausedPartitionsConfig, _autoPausedSourcePartitions); _autoPausedSourcePartitions.retainAll(currentAssignedPartitions); if (!partitionsToPause.equals(currentPausedPartitions)) { _logger.info("There were new partitions to pause. New partitions pause list is: {}", partitionsToPause); } _logger.info("Full pause list is: {}", partitionsToPause); _consumer.pause(partitionsToPause); }
Source:
<code>protected synchronized void processGetBlockHeaders(GetBlockHeadersMessage msg) { Iterator<BlockHeader> headersIterator = blockchain.getIteratorOfHeadersStartFrom( msg.getBlockIdentifier(), msg.getSkipBlocks(), min(msg.getMaxHeaders(), MAX_HASHES_TO_SEND), msg.isReverse() ); <START> BlockHeadersMessage response = new BlockHeadersMessage(headersIterator); <END> sendMessage(response); }</code><technical_language>do need change BlockHeadersMessage</technical_language>

Target:
protected synchronized void processGetBlockHeaders(GetBlockHeadersMessage msg) { Iterator<BlockHeader> headersIterator = blockchain.getIteratorOfHeadersStartFrom( msg.getBlockIdentifier(), msg.getSkipBlocks(), min(msg.getMaxHeaders(), MAX_HASHES_TO_SEND), msg.isReverse() ); List<BlockHeader> blockHeaders = new ArrayList<>(); while (headersIterator.hasNext()) { blockHeaders.add(headersIterator.next()); } BlockHeadersMessage response = new BlockHeadersMessage(blockHeaders); sendMessage(response); }
Source:
<code>public ActionResult execute() throws EntityNotFoundException { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String studentsInfo = getNonNullRequestParamValue(Const.ParamsNames.STUDENTS_ENROLLMENT_INFO); try { List<StudentAttributes>[] students = enrollAndProcessResultForDisplay(studentsInfo, courseId); EnrollResults dataFormat = new EnrollResults(getInstructorCourseEnrollResult(students)); return new JsonResult(dataFormat); } catch (EntityDoesNotExistException e) { throw new EntityNotFoundException(new EntityDoesNotExistException(e)); } catch (EnrollException | InvalidParametersException e) { return new JsonResult(e.getMessage(), HttpStatus.SC_BAD_REQUEST); } catch (EntityAlreadyExistsException e) { log.severe("Entity already exists exception occurred when updating student: " + e.getMessage()); return new JsonResult("The enrollment failed, possibly because some students were re-enrolled before " + "the previous enrollment action was still being processed by TEAMMATES database " + "servers. Please try again after about 10 minutes. If the problem persists, " <START> + "please contact TEAMMATES support", HttpStatus.SC_NOT_FOUND); <END> } }</code><technical_language>This is a 404. This fits 409 Conflict better</technical_language>

Target:
public ActionResult execute() throws EntityNotFoundException { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String studentsInfo = getRequestBody(); try { List<StudentAttributes>[] students = enrollAndProcessResultForDisplay(studentsInfo, courseId); EnrollResults dataFormat = new EnrollResults(getInstructorCourseEnrollResult(students)); return new JsonResult(dataFormat); } catch (EntityDoesNotExistException e) { throw new EntityNotFoundException(e); } catch (EnrollException | InvalidParametersException e) { return new JsonResult(e.getMessage(), HttpStatus.SC_BAD_REQUEST); } catch (EntityAlreadyExistsException e) { log.severe("Entity already exists exception occurred when updating student: " + e.getMessage()); return new JsonResult("The enrollment failed, possibly because some students were re-enrolled before " + "the previous enrollment action was still being processed by TEAMMATES database " + "servers. Please try again after about 10 minutes. If the problem persists, " + "please contact TEAMMATES support", HttpStatus.SC_CONFLICT); } }
Source:
<code>public Map<Guid, HostNicVfsConfig> findHostNicVfsConfigs() { final List<HostNicVfsConfig> hostNicVfsConfigs = getBackendCollection(HostNicVfsConfig.class, VdcQueryType.GetAllVfsConfigByHostId, new IdQueryParameters(asGuid(hostId))); return <START> hostNicVfsConfigs.stream().collect(Collectors.toMap(HostNicVfsConfig::getNicId, <END> x -> x)); }</code><technical_language>A static import nicer</technical_language>

Target:
public Map<Guid, HostNicVfsConfig> findHostNicVfsConfigs() { final List<HostNicVfsConfig> hostNicVfsConfigs = getBackendCollection(HostNicVfsConfig.class, VdcQueryType.GetAllVfsConfigByHostId, new IdQueryParameters(asGuid(hostId))); return hostNicVfsConfigs.stream().collect(toMap(HostNicVfsConfig::getNicId, x -> x)); }
Source:
<code>public static Artifact getDistroModule(String groupId, String artifactId, String version) { Artifact artifact = new Artifact(artifactId, version, groupId, Artifact.TYPE_ZIP); <START> artifact.setClassifier("distro"); <END> return artifact; }</code><technical_language>setting distro classifier</technical_language>

Target:
public static Artifact getDistroModule(String groupId, String artifactId, String version) { return new Artifact(artifactId, version, groupId); }
Source:
<code>public void testEmptyBitVector() { RankedBitVectorImpl bv0 = new RankedBitVectorImpl(); RankedBitVector bv1 = new RankedBitVectorImpl(); assertEqualsForBitVector(bv0, bv1); assertCorrectCount(bv0); assertCorrectCount(bv1); assertCorrectFindPosition(bv0); <START> assertCorrectFindPosition(bv1); <END> RankedBitVectorImpl bv2 = new RankedBitVectorImpl(0); assertEqualsForBitVector(bv1, bv2); assertCorrectCount(bv2); assertCorrectFindPosition(bv2); }</code><technical_language>do run tests for bv0 _and_ for bv1? Surely, expect objects created in constructor behave in way, we? Moreover, test count findpos result correspond empty bitvector. test is computed correctly bitvector, bitvector is empty. testing correct computation of rank select already, unnecessary do here</technical_language>

Target:
public void testEmptyBitVector() { RankedBitVectorImpl bv0 = new RankedBitVectorImpl(); Assert.assertEquals(0, bv0.size()); assertCorrectCount(bv0); assertCorrectFindPosition(bv0); Assert.assertNotEquals(bv0, new Object()); Assert.assertEquals(bv0, new BitVectorImpl()); RankedBitVector bv1 = new RankedBitVectorImpl(); RankedBitVectorImpl bv2 = new RankedBitVectorImpl(0); assertEqualsForBitVector(bv1, bv2); assertCorrectCount(bv2); assertCorrectFindPosition(bv2); }
Source:
<code>public DruidExpression visitCall( CallExpression call, Map<VariableReferenceExpression, DruidQueryGeneratorContext.Selection> context) { Optional<DruidExpression> basicCallHandlingResult = basicCallHandling(call, context); <START> if (basicCallHandlingResult.isPresent()) { <END> return basicCallHandlingResult.get(); } FunctionMetadata functionMetadata = functionMetadataManager.getFunctionMetadata(call.getFunctionHandle()); Optional<OperatorType> operatorTypeOptional = functionMetadata.getOperatorType(); if (operatorTypeOptional.isPresent()) { OperatorType operatorType = operatorTypeOptional.get(); if (operatorType.isArithmeticOperator()) { return handleArithmeticExpression(call, operatorType, context); } if (operatorType.isComparisonOperator()) { throw new PrestoException(DRUID_PUSHDOWN_UNSUPPORTED_EXPRESSION, "Unsupported operator: " + call + " to pushdown for Druid connector "); } } return handleFunction(call, context); }</code><technical_language>break a line</technical_language>

Target:
public DruidExpression visitCall( CallExpression call, Map<VariableReferenceExpression, DruidQueryGeneratorContext.Selection> context) { Optional<DruidExpression> basicCallHandlingResult = basicCallHandling(call, context); if (basicCallHandlingResult.isPresent()) { return basicCallHandlingResult.get(); } FunctionMetadata functionMetadata = functionMetadataManager.getFunctionMetadata(call.getFunctionHandle()); Optional<OperatorType> operatorTypeOptional = functionMetadata.getOperatorType(); if (operatorTypeOptional.isPresent()) { OperatorType operatorType = operatorTypeOptional.get(); if (operatorType.isArithmeticOperator()) { return handleArithmeticExpression(call, operatorType, context); } if (operatorType.isComparisonOperator()) { throw new PrestoException(DRUID_PUSHDOWN_UNSUPPORTED_EXPRESSION, "Unsupported operator: " + call + " to pushdown for Druid connector."); } } return handleFunction(call, context); }
Source:
<code>protected Map<String, String> params() { Map<String, String> localParams = new HashMap<>(); localParams.put("card[exp_month]", authCardDetails.expiryMonth()); localParams.put("card[exp_year]", authCardDetails.expiryYear()); localParams.put("card[number]", authCardDetails.getCardNo()); localParams.put("card[cvc]", authCardDetails.getCvc()); localParams.put("billing_details[name]", authCardDetails.getCardHolder()); localParams.put("type", "card"); authCardDetails.getAddress().ifPresent(address -> { localParams.put("billing_details[address[line1]]", address.getLine1()); if (StringUtils.isNotBlank(address.getLine2())) { localParams.put("billing_details[address[line2]]", address.getLine2()); } <START> northAmericanRegionMapper.getNorthAmericanRegionForCountry(address) .ifPresent(stateOrProvince -> localParams.put("billing_details[address[state]]", stateOrProvince.getFullName())); <END> localParams.put("billing_details[address[city]]", address.getCity()); localParams.put("billing_details[address[country]]", address.getCountry()); localParams.put("billing_details[address[postal_code]]", address.getPostcode()); }); return Map.copyOf(localParams); }</code><technical_language>do this: java northAmericanRegionMapper.getNorthAmericanRegionForCountry(address) .map(NorthAmericaRegion::getFullName) .ifPresent(stateOrProvince -> localParams.put("billing_details[address[state]]", stateOrProvince));</technical_language>

Target:
protected Map<String, String> params() { Map<String, String> localParams = new HashMap<>(); localParams.put("card[exp_month]", authCardDetails.expiryMonth()); localParams.put("card[exp_year]", authCardDetails.expiryYear()); localParams.put("card[number]", authCardDetails.getCardNo()); localParams.put("card[cvc]", authCardDetails.getCvc()); localParams.put("billing_details[name]", authCardDetails.getCardHolder()); localParams.put("type", "card"); authCardDetails.getAddress().ifPresent(address -> { localParams.put("billing_details[address[line1]]", address.getLine1()); if (StringUtils.isNotBlank(address.getLine2())) { localParams.put("billing_details[address[line2]]", address.getLine2()); } northAmericanRegionMapper.getNorthAmericanRegionForCountry(address) .map(NorthAmericaRegion::getFullName) .ifPresent(stateOrProvince -> localParams.put("billing_details[address[state]]", stateOrProvince)); localParams.put("billing_details[address[city]]", address.getCity()); localParams.put("billing_details[address[country]]", address.getCountry()); localParams.put("billing_details[address[postal_code]]", address.getPostcode()); }); return Map.copyOf(localParams); }
Source:
<code>TableAsyncBatch(String partitionKey, TableAsyncClient client) { this.partitionKey = partitionKey; <START> this.batchImpl = new BatchImpl(client.getImplementation(), new TablesMultipartSerializer()); <END> this.operationClient = new TableClientBuilder() .tableName(client.getTableName()) .endpoint(client.getImplementation().getUrl()) .serviceVersion(client.getApiVersion()) .pipeline(BuilderHelper.buildNullClientPipeline()) .buildAsyncClient(); }</code><technical_language>Do need a new instance of this serializer for batch? passed in a dependency</technical_language>

Target:
TableAsyncBatch(String partitionKey, TableAsyncClient client) { this.partitionKey = partitionKey; this.batchImpl = new BatchImpl(client.getImplementation(), BATCH_SERIALIZER); this.operationClient = new TableClientBuilder() .tableName(client.getTableName()) .endpoint(client.getImplementation().getUrl()) .serviceVersion(client.getApiVersion()) .pipeline(BuilderHelper.buildNullClientPipeline()) .buildAsyncClient(); }
Source:
<code>private CouponDefinition getIborInterpolatedStubDefinition( double notional, ZonedDateTime paymentDate, ZonedDateTime accrualStartDate, ZonedDateTime accrualEndDate, double accrualYearFraction, ZonedDateTime fixingDate, ZonedDateTime fixingPeriodStartDate, ZonedDateTime fixingPeriodEndDate, double fixingPeriodYearFraction, double initialRate, ZonedDateTime firstInterpolatedDate, double firstInterpolatedYearFraction, IborIndex firstStubIndex, ZonedDateTime secondInterpolatedDate, double secondInterpolatedYearFraction, IborIndex secondStubIndex) { <START> assert !accrualEndDate.isBefore(firstInterpolatedDate); <END> assert !accrualEndDate.isAfter(secondInterpolatedDate); ActualActualISDA dayCount = new ActualActualISDA(); double timeToPeriodEnd = dayCount.getDayCountFraction(accrualStartDate, accrualEndDate); double timeToFirstInterpolatedRateDate = dayCount.getDayCountFraction(accrualStartDate, firstInterpolatedDate); double timeToSecondInterpolatedRateDate = dayCount.getDayCountFraction(accrualStartDate, secondInterpolatedDate); double weightDenominator = timeToSecondInterpolatedRateDate - timeToFirstInterpolatedRateDate; double weightFirstIndex = (timeToSecondInterpolatedRateDate - timeToPeriodEnd) / weightDenominator; double weightSecondIndex = (timeToPeriodEnd - timeToFirstInterpolatedRateDate) / weightDenominator; return CouponIborAverageIndexDefinition.from( paymentDate, accrualStartDate, accrualEndDate, accrualYearFraction, notional, fixingDate, firstStubIndex, secondStubIndex, weightFirstIndex, weightSecondIndex, getFixingCalendar(), getFixingCalendar()); }</code><technical_language>ArgumentChecker's</technical_language>

Target:
private CouponDefinition getIborInterpolatedStubDefinition( double notional, ZonedDateTime paymentDate, ZonedDateTime accrualStartDate, ZonedDateTime accrualEndDate, double accrualYearFraction, ZonedDateTime fixingDate, ZonedDateTime fixingPeriodStartDate, ZonedDateTime fixingPeriodEndDate, double fixingPeriodYearFraction, double initialRate, ZonedDateTime firstInterpolatedDate, double firstInterpolatedYearFraction, IborIndex firstStubIndex, ZonedDateTime secondInterpolatedDate, double secondInterpolatedYearFraction, IborIndex secondStubIndex) { Pair<Double, Double> weights = getInterpolationWeights(accrualStartDate, accrualEndDate, firstInterpolatedDate, secondInterpolatedDate); return CouponIborAverageIndexDefinition.from( paymentDate, accrualStartDate, accrualEndDate, accrualYearFraction, notional, fixingDate, firstStubIndex, secondStubIndex, weights.getFirst(), weights.getSecond(), getFixingCalendar(), getFixingCalendar()); }