auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public SavedRequest getRequest(HttpServletRequest request, HttpServletResponse response) { Cookie savedRequestCookie = WebUtils.getCookie(request, COOKIE_NAME); if (savedRequestCookie != null) { final String originalURI = decodeCookie(savedRequestCookie.getValue()); UriComponents uriComponents = UriComponentsBuilder.fromUriString(originalURI).build(); DefaultSavedRequest.Builder builder = new DefaultSavedRequest.Builder(); int port = uriComponents.getPort(); if (port == -1) { if ("https".equalsIgnoreCase(uriComponents.getScheme())) { port = 443; } else { port = 80; } } final MultiValueMap<String, String> queryParams = uriComponents.getQueryParams(); if (!queryParams.isEmpty()) { final HashMap<String, String[]> parameters = new HashMap<>(queryParams.size()); queryParams.forEach((key, value) -> parameters.put(key, value.toArray(new String[]{}))); builder.setParameters(parameters); } return builder.setScheme(uriComponents.getScheme()) .setServerName(uriComponents.getHost()) .setRequestURI(uriComponents.getPath()) .setQueryString(uriComponents.getQuery()) .setServerPort(port) .setMethod(request.getMethod()) .setRequestURL(getRequestURL(originalURI, uriComponents)) <START> .setContextPath(request.getContextPath()) .setServletPath(getServletPath(uriComponents, request.getContextPath())) <END> .build(); } return null; }</code><technical_language>omit context path servlet path, accurate get saved URI</technical_language>

Target:
public SavedRequest getRequest(HttpServletRequest request, HttpServletResponse response) { Cookie savedRequestCookie = WebUtils.getCookie(request, COOKIE_NAME); if (savedRequestCookie != null) { final String originalURI = decodeCookie(savedRequestCookie.getValue()); UriComponents uriComponents = UriComponentsBuilder.fromUriString(originalURI).build(); DefaultSavedRequest.Builder builder = new DefaultSavedRequest.Builder(); int port = uriComponents.getPort(); if (port == -1) { if ("https".equalsIgnoreCase(uriComponents.getScheme())) { port = 443; } else { port = 80; } } final MultiValueMap<String, String> queryParams = uriComponents.getQueryParams(); if (!queryParams.isEmpty()) { final HashMap<String, String[]> parameters = new HashMap<>(queryParams.size()); queryParams.forEach((key, value) -> parameters.put(key, value.toArray(new String[]{}))); builder.setParameters(parameters); } return builder.setScheme(uriComponents.getScheme()) .setServerName(uriComponents.getHost()) .setRequestURI(uriComponents.getPath()) .setQueryString(uriComponents.getQuery()) .setServerPort(port) .setMethod(request.getMethod()) .build(); } return null; }
Source:
<code>public void shouldRemoveRelationshipFromExplicitIndex() throws Exception { long relId = addRelationshipToExplicitIndex(); try ( Transaction tx = session.beginTransaction() ) { ExplicitIndexWrite indexWrite = tx.indexWrite(); indexWrite.relationshipRemoveFromExplicitIndex( INDEX_NAME, relId ); tx.success(); } try ( org.neo4j.graphdb.Transaction ctx = graphDb.beginTx() ) { <START> IndexHits<Node> hits = graphDb.index().forNodes( INDEX_NAME ).get( KEY, "this is it" ); <END> assertFalse( hits.hasNext() ); hits.close(); ctx.success(); } }</code><technical_language>Magic string "this is it"</technical_language>

Target:
public void shouldRemoveRelationshipFromExplicitIndex() throws Exception { long relId = addRelationshipToExplicitIndex(); try ( Transaction tx = session.beginTransaction() ) { ExplicitIndexWrite indexWrite = tx.indexWrite(); indexWrite.relationshipRemoveFromExplicitIndex( INDEX_NAME, relId ); tx.success(); } try ( org.neo4j.graphdb.Transaction ctx = graphDb.beginTx() ) { IndexHits<Node> hits = graphDb.index().forNodes( INDEX_NAME ).get( KEY, VALUE ); assertFalse( hits.hasNext() ); hits.close(); ctx.success(); } }
Source:
<code>public void addHeaderParam_string_addsParam() { action.addHeaderParam(PARAM_NAME_1, PARAM_VALUE_1); action.addHeaderParam(PARAM_NAME_2, PARAM_VALUE_2); <START> verifyOnlyExpextedParamsArePresent(action.getHeaderParams()); <END> }</code><technical_language>expeCted</technical_language>

Target:
public void addHeaderParam_string_addsParam() { action.addHeaderParam(PARAM_NAME_1, PARAM_VALUE_1); action.addHeaderParam(PARAM_NAME_2, PARAM_VALUE_2); verifyOnlyExpectedParamsArePresent(action.getHeaderParams()); }
Source:
<code>private Metadata initializeMetadata(Data key, Data value) { try { Object keyMetadata = metadataInitializer.createFromData(key); Object valueMetadata = metadataInitializer.createFromData(value); if (keyMetadata != null || valueMetadata != null) { Metadata metadata = new Metadata(); metadata.set(true, keyMetadata); metadata.set(false, valueMetadata); <START> return metadata; <END> } } catch (Exception e) { rethrow(e); } return null; }</code><technical_language>this is thinking is a metadata initializer for some keys values return null return non-null for other values</technical_language>

Target:
private Metadata initializeMetadata(Data key, Data value) { try { Object keyMetadata = metadataInitializer.createFromData(key); Object valueMetadata = metadataInitializer.createFromData(value); if (keyMetadata != null || valueMetadata != null) { Metadata metadata = new Metadata(); metadata.setKeyMetadata(keyMetadata); metadata.setValueMetadata(valueMetadata); return metadata; } } catch (Exception e) { rethrow(e); } return null; }
Source:
<code>private void display(ChangeInfo info) { Map<Integer, AccountInfo> r = new HashMap<>(); Map<Integer, AccountInfo> cc = new HashMap<>(); for (LabelInfo label : Natives.asList(info.all_labels().values())) { if (label.all() != null) { for (ApprovalInfo ai : Natives.asList(label.all())) { (ai.value() != 0 ? r : cc).put(ai._account_id(), ai); } } } for (Integer i : r.keySet()) { cc.remove(i); } r.remove(info.owner()._account_id()); cc.remove(info.owner()._account_id()); Set<Integer> removable = new HashSet<>(); if (info.removable_reviewers() != null) { for (AccountInfo a : Natives.asList(info.removable_reviewers())) { removable.add(a._account_id()); } } Map<Integer, VotableInfo> votable = votable(info); SafeHtml rHtml = Labels.formatUserList(style, r.values(), removable, votable); SafeHtml ccHtml = Labels.formatUserList(style, cc.values(), removable, votable); reviewersText.setInnerSafeHtml(rHtml); ccText.setInnerSafeHtml(ccHtml); if (Gerrit.isSignedIn()) { int currentUser = Gerrit.getUserAccountInfo()._account_id(); boolean <START> showAddmeButton = <END> info.owner()._account_id() != currentUser && !cc.containsKey(currentUser) && !r.containsKey(currentUser); addMe.setVisible(showAddmeButton); } }</code><technical_language>This camel case naming convention is consistent variable name above</technical_language>

Target:
private void display(ChangeInfo info) { Map<Integer, AccountInfo> r = new HashMap<>(); Map<Integer, AccountInfo> cc = new HashMap<>(); for (LabelInfo label : Natives.asList(info.all_labels().values())) { if (label.all() != null) { for (ApprovalInfo ai : Natives.asList(label.all())) { (ai.value() != 0 ? r : cc).put(ai._account_id(), ai); } } } for (Integer i : r.keySet()) { cc.remove(i); } r.remove(info.owner()._account_id()); cc.remove(info.owner()._account_id()); Set<Integer> removable = new HashSet<>(); if (info.removable_reviewers() != null) { for (AccountInfo a : Natives.asList(info.removable_reviewers())) { removable.add(a._account_id()); } } Map<Integer, VotableInfo> votable = votable(info); SafeHtml rHtml = Labels.formatUserList(style, r.values(), removable, votable); SafeHtml ccHtml = Labels.formatUserList(style, cc.values(), removable, votable); reviewersText.setInnerSafeHtml(rHtml); ccText.setInnerSafeHtml(ccHtml); if (Gerrit.isSignedIn()) { int currentUser = Gerrit.getUserAccountInfo()._account_id(); boolean showAddMeButton = info.owner()._account_id() != currentUser && !cc.containsKey(currentUser) && !r.containsKey(currentUser); addMe.setVisible(showAddMeButton); } }
Source:
<code>public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws Exception { Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN); Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END); String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE); ReferenceElement.Type type = ReferenceElement.Type.valueOf(typeString); String anchor = parser.getAttributeValue(null, ReferenceElement.ATTR_ANCHOR); String uri = parser.getAttributeValue(null, ReferenceElement.ATTR_URI); ExtensionElement child = null; while (true) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elementName = parser.getName(); String namespace = parser.getNamespace(); ExtensionElementProvider<?> provider = ProviderManager.getExtensionProvider(elementName, namespace); if (provider != null) { child = provider.parse(parser); } } if (eventType == XmlPullParser.END_TAG) { <START> return new ReferenceElement(begin, end, type, anchor, uri, child); <END> } } }</code><technical_language>prefer if this parser follow idiom other parsers use, i.e. break outerloop here</technical_language>

Target:
public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws Exception { Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN); Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END); String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE); ReferenceElement.Type type = ReferenceElement.Type.valueOf(typeString); String anchor = parser.getAttributeValue(null, ReferenceElement.ATTR_ANCHOR); String uriString = parser.getAttributeValue(null, ReferenceElement.ATTR_URI); URI uri = uriString != null ? new URI(uriString) : null; ExtensionElement child = null; outerloop: while (true) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elementName = parser.getName(); String namespace = parser.getNamespace(); ExtensionElementProvider<?> provider = ProviderManager.getExtensionProvider(elementName, namespace); if (provider != null) { child = provider.parse(parser); } } if (eventType == XmlPullParser.END_TAG) { break outerloop; } } return new ReferenceElement(begin, end, type, anchor, uri, child); }
Source:
<code>public void test_equals() throws Exception { assertThat(symbolicValue("42")).isNotEqualTo(null); assertThat(symbolicValue("42")).isNotEqualTo(""); assertThat(symbolicValue("42")).isEqualTo(symbolicValue("42")); assertThat(symbolicValue("42")).isNotEqualTo(symbolicValue("null")); assertThat(symbolicValue("x")).isNotEqualTo(symbolicValue("x").constrain(Truthiness.FALSY)); <START> assertThat(symbolicValue("x").constrain(Truthiness.FALSY)).isEqualTo(symbolicValue("x").constrain(Truthiness.FALSY)); <END> }</code><technical_language>@pynicolas add assertThat(symbolicValue("42")).isEqualTo(symbolicValue("45"));</technical_language>

Target:
public void test_equals() throws Exception { assertThat(symbolicValue("42")).isNotEqualTo(null); assertThat(symbolicValue("42")).isNotEqualTo(""); assertThat(symbolicValue("42")).isEqualTo(symbolicValue("42")); assertThat(symbolicValue("42")).isEqualTo(symbolicValue("45")); assertThat(symbolicValue("42")).isNotEqualTo(symbolicValue("null")); assertThat(symbolicValue("x")).isNotEqualTo(symbolicValue("x").constrain(Truthiness.FALSY)); assertThat(symbolicValue("x").constrain(FALSY)).isEqualTo(symbolicValue("x").constrain(FALSY)); }
Source:
<code>public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) { RaptorTableHandle table = (RaptorTableHandle) tableHandle; List<TableColumn> existingColumns = dao.listTableColumns(table.getSchemaName(), table.getTableName()); TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1); long columnId = lastColumn.getColumnId() + 1; int ordinalPosition = lastColumn.getOrdinalPosition() + 1; StorageTypeConverter storageTypeConverter = new StorageTypeConverter(typeManager); <START> requireNonNull(storageTypeConverter.toStorageType(column.getType()), "storage type cannot be null"); <END> String type = column.getType().getTypeSignature().toString(); daoTransaction(dbi, MetadataDao.class, dao -> { dao.insertColumn(table.getTableId(), columnId, column.getName(), ordinalPosition, type, null, null); dao.updateTableVersion(table.getTableId(), session.getStartTime()); }); shardManager.addColumn(table.getTableId(), new ColumnInfo(columnId, column.getType())); }</code><technical_language>"requireNonNull" -> "checkState"</technical_language>

Target:
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) { RaptorTableHandle table = (RaptorTableHandle) tableHandle; List<TableColumn> existingColumns = dao.listTableColumns(table.getSchemaName(), table.getTableName()); TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1); long columnId = lastColumn.getColumnId() + 1; int ordinalPosition = lastColumn.getOrdinalPosition() + 1; StorageTypeConverter storageTypeConverter = new StorageTypeConverter(typeManager); checkState(storageTypeConverter.toStorageType(column.getType()) != null, "storage type cannot be null"); String type = column.getType().getTypeSignature().toString(); daoTransaction(dbi, MetadataDao.class, dao -> { dao.insertColumn(table.getTableId(), columnId, column.getName(), ordinalPosition, type, null, null); dao.updateTableVersion(table.getTableId(), session.getStartTime()); }); shardManager.addColumn(table.getTableId(), new ColumnInfo(columnId, column.getType())); }
Source:
<code>public static VersionNumber getMinJavaLevel() { try { Method method = Jenkins.class.getMethod("getJavaMinLevel"); Object res = method.invoke(null); if (res instanceof VersionNumber) { return (VersionNumber) res; } } catch(SecurityException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { } final VersionNumber version = Jenkins.getVersion(); if (version == null) { <START> return JAVA_LEVEL_7; <END> } return version.isNewerThan(JAVA_8_MINIMAL_SINCE) ? JAVA_LEVEL_7 : JAVA_LEVEL_8; }</code><technical_language>I assume this is JAVA_LEVEL_7 JAVA_LEVEL_6 plugin is based Jenkins 1.625 (first LTS mandate Java 7) more ugly bug reports (in git plugin, anyway) users mix Java 7 master Java 6 agents</technical_language>

Target:
public static VersionNumber getMinJavaLevel() { final VersionNumber version = Jenkins.getVersion(); if (version == null) { return JAVA_LEVEL_7; } return version.isOlderThan(JAVA_8_MINIMAL_SINCE) ? JAVA_LEVEL_7 : JAVA_LEVEL_8; }
Source:
<code><START> private void wasCreated() throws Exception <END> { refreshData(); refreshChildren(); }</code><technical_language>I wasReconnected() called for of wasCreated(). Right</technical_language>

Target:
void wasCreated() throws Exception { refresh(); }
Source:
<code>public void testReadFileJournaltype() throws IOException { if (!container.isStarted(DEFAULT_FULL_JBOSSAS)) { container.start(DEFAULT_FULL_JBOSSAS); } ManagementClient managementClient = createManagementClient(); assertEquals("ASYNCIO", readJournalType(managementClient)); assertNotNull(readRuntimeJournalType(managementClient)); <START> ModelNode op = Operations.createAddOperation(Operations.createAddress("system-property", "org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory.DISABLED")); <END> op.get(VALUE).set(true); execute(managementClient, op, true); managementClient.close(); container.stop(DEFAULT_FULL_JBOSSAS); container.start(DEFAULT_FULL_JBOSSAS); managementClient = createManagementClient(); assertEquals("ASYNCIO", readJournalType(managementClient)); assertEquals("NIO", readRuntimeJournalType(managementClient)); container.stop(DEFAULT_FULL_JBOSSAS); }</code><technical_language>Is a reason check this is null? assertEquals("ASYNCIO", readRuntimeJournalType(managementClient)); instead ? falling NIO, attributes same, right</technical_language>

Target:
public void testReadFileJournaltype() throws IOException { if (!container.isStarted(DEFAULT_FULL_JBOSSAS)) { container.start(DEFAULT_FULL_JBOSSAS); } ManagementClient managementClient = createManagementClient(); assertEquals("ASYNCIO", readJournalType(managementClient)); assertNotNull(readRuntimeJournalType(managementClient)); ModelNode op = Operations.createAddOperation(AIO_DISABLED_ADDRESS); op.get(VALUE).set(true); execute(managementClient, op, true); managementClient.close(); container.stop(DEFAULT_FULL_JBOSSAS); container.start(DEFAULT_FULL_JBOSSAS); managementClient = createManagementClient(); assertEquals("ASYNCIO", readJournalType(managementClient)); assertEquals("NIO", readRuntimeJournalType(managementClient)); op = Operations.createRemoveOperation(AIO_DISABLED_ADDRESS); execute(managementClient, op, true); container.stop(DEFAULT_FULL_JBOSSAS); }
Source:
<code>private MethodBehavior get(String signature, @Nullable Symbol.MethodSymbol symbol) { MethodBehavior mb = behaviors.get(signature); if(mb != null) { return mb; } if (symbol != null) { MethodTree declaration = symbol.declaration(); <START> if (SymbolicExecutionVisitor.methodCanNotBeOverriden(symbol) && declaration != null) { <END> sev.execute(declaration); return behaviors.get(signature); } } if (!crossFileEnabled && !isknownSignature(WHITELIST, signature)) { return null; } if (!bytecodeBehaviors.containsKey(signature)) { new BytecodeEGWalker(this, semanticModel).getMethodBehavior(signature, classLoader); } return bytecodeBehaviors.get(signature); }</code><technical_language>Removing this lead simplification of isKnownSignature method</technical_language>

Target:
private MethodBehavior get(String signature, @Nullable Symbol.MethodSymbol symbol) { MethodBehavior mb = behaviors.get(signature); if(mb != null) { return mb; } if (symbol != null) { MethodTree declaration = symbol.declaration(); if (SymbolicExecutionVisitor.methodCanNotBeOverriden(symbol) && declaration != null) { sev.execute(declaration); return behaviors.get(signature); } } if (!crossFileEnabled && !isKnownSignature(signature)) { return null; } if (!bytecodeBehaviors.containsKey(signature)) { new BytecodeEGWalker(this, semanticModel).getMethodBehavior(signature, classLoader); } return bytecodeBehaviors.get(signature); }
Source:
<code>public TemplateClassification resetTemplateType() { <START> this.changeTemplateType("Unknown"); <END> return this; }</code><technical_language>Please move literals ("Unknown", "Infobox", "Quote" ) constants</technical_language>

Target:
public TemplateClassification resetTemplateType() { this.changeTemplateType(TemplateTypes.UNKNOWN); return this; }
Source:
<code>public final byte[] getByteArray(final Message message) { <START> <END> DatagramWriter optionsAndPayloadWriter = new DatagramWriter(); serializeOptionsAndPayload(optionsAndPayloadWriter, message.getOptions(), message.getPayload()); optionsAndPayloadWriter.writeCurrentByte(); MessageHeader header = new MessageHeader(CoAP.VERSION, message.getType(), message.getToken(), message.getRawCode(), message.getMID(), optionsAndPayloadWriter.size()); DatagramWriter messageWriter = new DatagramWriter(); serializeHeader(messageWriter, header); messageWriter.writeCurrentByte(); messageWriter.write(optionsAndPayloadWriter); return messageWriter.toByteArray(); }</code><technical_language>null check</technical_language>

Target:
public final byte[] getByteArray(final Message message) { if (message == null) { throw new NullPointerException("message must not be null!"); } DatagramWriter optionsAndPayloadWriter = new DatagramWriter(); serializeOptionsAndPayload(optionsAndPayloadWriter, message.getOptions(), message.getPayload()); optionsAndPayloadWriter.writeCurrentByte(); MessageHeader header = new MessageHeader(CoAP.VERSION, message.getType(), message.getToken(), message.getRawCode(), message.getMID(), optionsAndPayloadWriter.size()); DatagramWriter messageWriter = new DatagramWriter(); serializeHeader(messageWriter, header); messageWriter.writeCurrentByte(); messageWriter.write(optionsAndPayloadWriter); return messageWriter.toByteArray(); }
Source:
<code>protected void switchToNewWindow() { <START> Wait<WebDriver> wait = Locator.getFluentWait(); <END> wait.until((new Function<WebDriver, Boolean>() { @Override public Boolean apply(WebDriver driver) { try { return driver.getWindowHandles().size() > 1; } catch (StaleElementReferenceException e) { return null; } } })); String handle = null; Iterator<String> handleIt = driver.getWindowHandles().iterator(); while (handleIt.hasNext()) { handle = handleIt.next(); } System.err.println(driver.getWindowHandles()); driver.switchTo().window(handle); }</code><technical_language>a lambda here</technical_language>

Target:
protected void switchToNewWindow() { Wait<WebDriver> wait = Locator.getFluentWait(); wait.until((new Function<WebDriver, Boolean>() { @Override public Boolean apply(WebDriver driver) { try { return driver.getWindowHandles().size() > 1; } catch (StaleElementReferenceException e) { return null; } } })); String handle = null; for (String h : driver.getWindowHandles()) { handle = h; } driver.switchTo().window(handle); }
Source:
<code>private void invalidate() { final long currentTime = System.currentTimeMillis(); for (Map.Entry<String, Long> workspaceExpireEntry : activeWorkspaces.entrySet()) { if (workspaceExpireEntry.getValue() <= currentTime) { try { String workspaceId = workspaceExpireEntry.getKey(); Workspace workspace = workspaceManager.getWorkspace(workspaceId); workspace.getAttributes().put(WORKSPACE_STOPPED_BY, ACTIVITY_CHECKER); workspaceManager.updateWorkspace(workspaceId, workspace); workspaceManager.stopWorkspace(workspaceId); } catch (NotFoundException e) { <START> LOG.info("Workspace already stopped"); <END> } catch (ConflictException e) { LOG.warn(e.getLocalizedMessage()); } catch (Exception ex) { LOG.error(ex.getLocalizedMessage()); LOG.debug(ex.getLocalizedMessage(), ex); } finally { activeWorkspaces.remove(workspaceExpireEntry.getKey()); } } } }</code><technical_language>Please ignore this exception - is need log</technical_language>

Target:
private void invalidate() { final long currentTime = System.currentTimeMillis(); for (Map.Entry<String, Long> workspaceExpireEntry : activeWorkspaces.entrySet()) { if (workspaceExpireEntry.getValue() <= currentTime) { try { String workspaceId = workspaceExpireEntry.getKey(); Workspace workspace = workspaceManager.getWorkspace(workspaceId); workspace.getAttributes().put(WORKSPACE_STOPPED_BY, ACTIVITY_CHECKER); workspaceManager.updateWorkspace(workspaceId, workspace); workspaceManager.stopWorkspace(workspaceId); } catch (NotFoundException ignored) { } catch (ConflictException e) { LOG.warn(e.getLocalizedMessage()); } catch (Exception ex) { LOG.error(ex.getLocalizedMessage()); LOG.debug(ex.getLocalizedMessage(), ex); } finally { activeWorkspaces.remove(workspaceExpireEntry.getKey()); } } } }
Source:
<code>static void addFeatures() { List nonHunterCampBiomeCategories = Lists.newArrayList(Biome.Category.OCEAN, Biome.Category.THEEND, Biome.Category.NETHER, Biome.Category.ICY, Biome.Category.BEACH, Biome.Category.RIVER); for (Biome biome : ForgeRegistries.BIOMES.getValues()) { if (nonHunterCampBiomeCategories.contains(biome.getCategory())) continue; <START> if (biome instanceof IFactionBiome && VReference.VAMPIRE_FACTION.equals(((IFactionBiome) biome).getFaction())) <END> continue; VampirismBiomeFeatures.addHunterTent(biome); } }</code><technical_language>I do !HUNTER.equals(biome.getFaction)</technical_language>

Target:
static void addFeatures() { for (Biome biome : ForgeRegistries.BIOMES.getValues()) { if (!VampirismAPI.worldGenRegistry().canStructureBeGeneratedInBiome(ModFeatures.hunter_camp.getRegistryName(), biome)) continue; if (biome instanceof IFactionBiome && !VReference.HUNTER_FACTION.equals(((IFactionBiome) biome).getFaction())) continue; VampirismBiomeFeatures.addHunterTent(biome); } }
Source:
<code>public ByteBuffer encode(@Nullable T value, @NonNull ProtocolVersion protocolVersion) { if (value == null) return null; try { return ByteBuffer.wrap(objectMapper.writeValueAsBytes(value)); } catch (JsonProcessingException e) { <START> throw new InvalidTypeException(e.getMessage(), e); <END> } }</code><technical_language>I in #1208 : In driver 4.0 specific exception for codecs CodecNotFoundException. a codec serialize deserialize something, IllegalArgumentException. I need introduce a special exception in examples</technical_language>

Target:
public ByteBuffer encode(@Nullable T value, @NonNull ProtocolVersion protocolVersion) { if (value == null) { return null; } try { return ByteBuffer.wrap(objectMapper.writeValueAsBytes(value)); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
Source:
<code>private void launchUserBrickScriptActivity(Context context, UserBrick userBrick) { <START> ((ScriptActivity) context).removeFormulaEditorFragment(); <END> Intent intent = new Intent(context, UserBrickScriptActivity.class); ProjectManager.getInstance().setCurrentUserBrick(userBrick); context.startActivity(intent); }</code><technical_language>context is a ScriptActivity</technical_language>

Target:
private void launchUserBrickScriptActivity(Context context, UserBrick userBrick) { if (context instanceof ScriptActivity) { ((ScriptActivity) context).removeFormulaEditorFragment(); } Intent intent = new Intent(context, UserBrickScriptActivity.class); ProjectManager.getInstance().setCurrentUserBrick(userBrick); context.startActivity(intent); }
Source:
<code>private void setServiceListPath(WebApplication webApplication) { String serviceListPathParamName = "service-list-path"; String serviceListPathParam = webApplication.getContext().getServletContext().getInitParameter(serviceListPathParamName); if ("".equals(serviceListPathParam) || serviceListPathParam == null) { Map<String, ? extends ServletRegistration> servletRegs = webApplication.getContext().getServletContext().getServletRegistrations(); for (ServletRegistration servletReg : servletRegs.values()) { serviceListPathParam = servletReg.getInitParameter(serviceListPathParamName); if (!"".equals(serviceListPathParam) || serviceListPathParam != null) { break; } } } <START> if ("".equals(serviceListPathParam) || serviceListPathParam == null) { <END> serviceListPathParam = "/services"; } else { serviceListPathParam = ""; } webApplication.setServiceListPath(serviceListPathParam); }</code><technical_language>null check condition checked empty string</technical_language>

Target:
private void setServiceListPath(WebApplication webApplication) { String serviceListPathParamName = "service-list-path"; String serviceListPathParam = webApplication.getContext().getServletContext().getInitParameter(serviceListPathParamName); if (serviceListPathParam == null || "".equals(serviceListPathParam)) { Map<String, ? extends ServletRegistration> servletRegs = webApplication.getContext().getServletContext().getServletRegistrations(); for (ServletRegistration servletReg : servletRegs.values()) { serviceListPathParam = servletReg.getInitParameter(serviceListPathParamName); if (serviceListPathParam != null || !"".equals(serviceListPathParam) ) { break; } } } if (serviceListPathParam == null || "".equals(serviceListPathParam)) { serviceListPathParam = "/services"; } else { serviceListPathParam = ""; } webApplication.setServiceListPath(serviceListPathParam); }
Source:
<code>public void abrirArquivosCodigoFonte(final List<File> arquivos) { if (arquivos != null && !arquivos.isEmpty()) { Lancador.getInstance().focarJanela(); SwingUtilities.invokeLater(() -> { TelaPrincipal.this.setEnabled(false); for (File arquivo : arquivos) { if (arquivoJaEstaAberto(arquivo)) { AbaCodigoFonte aba = obterAbaArquivo(arquivo); aba.selecionar(); } else { try { final String conteudo = FileHandle.open(arquivo); final AbaCodigoFonte abaCodigoFonte = AbaCodigoFonte.novaAba(); <START> if(arquivo.getName().endsWith(".recuperado")) <END> { abaCodigoFonte.setCodigoFonte(conteudo, null, true); } else{ PortugolStudio.getInstancia().salvarComoRecente(arquivo); abaCodigoFonte.setCodigoFonte(conteudo, arquivo, true); } getPainelTabulado().add(abaCodigoFonte); } catch (Exception excecao) { PortugolStudio.getInstancia().getTratadorExcecoes().exibirExcecao(excecao); } } } TelaPrincipal.this.setEnabled(true); }); } }</code><technical_language>)</technical_language>

Target:
public void abrirArquivosCodigoFonte(final List<File> arquivos) { if (arquivos != null && !arquivos.isEmpty()) { Lancador.getInstance().focarJanela(); SwingUtilities.invokeLater(() -> { TelaPrincipal.this.setEnabled(false); for (File arquivo : arquivos) { if (arquivoJaEstaAberto(arquivo)) { AbaCodigoFonte aba = obterAbaArquivo(arquivo); aba.selecionar(); } else { try { final String conteudo = FileHandle.open(arquivo); final AbaCodigoFonte abaCodigoFonte = AbaCodigoFonte.novaAba(); if(PortugolStudio.getInstancia().isArquivoRecuperado(arquivo)) { abaCodigoFonte.setCodigoFonte(conteudo, null, true); } else{ PortugolStudio.getInstancia().salvarComoRecente(arquivo); abaCodigoFonte.setCodigoFonte(conteudo, arquivo, true); } getPainelTabulado().add(abaCodigoFonte); } catch (Exception excecao) { PortugolStudio.getInstancia().getTratadorExcecoes().exibirExcecao(excecao); } } } TelaPrincipal.this.setEnabled(true); }); } }
Source:
<code>private void unregisterInstances(Collection<String> instances) { synchronized (_instanceMonitorMap) { for (String instanceName : instances) { <START> _instanceMonitorMap.get(instanceName).unregister(); <END> _instanceMonitorMap.remove(instanceName); } } }</code><technical_language>Add a null check here</technical_language>

Target:
private void unregisterInstances(Collection<String> instances) { synchronized (_instanceMonitorMap) { for (String instanceName : instances) { InstanceMonitor monitor = _instanceMonitorMap.remove(instanceName); if (monitor != null) { monitor.unregister(); } } } }
Source:
<code>protected ArchiveOutputStream applyFormatOptions(ArchiveOutputStream s, Map<String, Object> o) throws IOException { for (Map.Entry<String, Object> p : o.entrySet()) { try { <START> Field field = s.getClass().getDeclaredField(p.getKey()); <END> field.setAccessible(true); field.set(s, p.getValue()); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { throw new IOException("cannot set option: " + p.getKey(), e); } } return s; }</code><technical_language>This is pretty intrusive allows setting field, some fields options, e.g. byte[] buf; in class ZipArchiveOutputStream, setting is harmful I java.bean.Statement enable setting options correspond a setter method in output stream class</technical_language>

Target:
protected ArchiveOutputStream applyFormatOptions(ArchiveOutputStream s, Map<String, Object> o) throws IOException { for (Map.Entry<String, Object> p : o.entrySet()) { try { new Statement(s, "set" + StringUtils.capitalize(p.getKey()), new Object[]{p.getValue()}).execute(); } catch (Exception e) { throw new IOException("cannot set option: " + p.getKey(), e); } } return s; }
Source:
<code>private byte[] getReadmeContent() { String filename = "README.blank"; try { <START> return Resources.toByteArray(getClass().getClassLoader().getResource(filename)); <END> } catch (IOException e) { LOG.warn("File %s not found so content of %s will be empty.", filename, README_FILE_NAME); return new byte[0]; } }</code><technical_language>Resources.toByteArray(Resources.getResource("README.blank")); wdyt</technical_language>

Target:
private byte[] getReadmeContent() { String filename = "README.blank"; try { return toByteArray(getResource(filename)); } catch (IOException e) { LOG.warn("File %s not found so content of %s will be empty.", filename, README_FILE_NAME); return new byte[0]; } }
Source:
<code>public String generateAPIFromSwagger(String swaggerJsonString) throws APIException { if (swaggerJsonString == null || swaggerJsonString.isEmpty()) { if (log.isDebugEnabled()) { log.debug("Swagger provided is empty, hence returning empty API"); } <START> return ""; <END> } JsonParser jsonParser = new JsonParser(); JsonElement swaggerJson = jsonParser.parse(swaggerJsonString); if (swaggerJson.isJsonObject()) { APIGenerator apiGenerator = new APIGenerator(swaggerJson.getAsJsonObject()); try { API api = apiGenerator.generateSynapseAPI(); return APISerializer.serializeAPI(api).toString(); } catch (SwaggerGenException e) { String errorMsg = "Error occurred while generating API"; log.error(errorMsg, e); throw new APIException(errorMsg, e); } } else { String errorMsg = "Error in swagger definition format: should be a json object"; log.error(errorMsg); throw new APIException(errorMsg); } }</code><technical_language>AFAIR StringUtils.isEmpty()</technical_language>

Target:
public String generateAPIFromSwagger(String swaggerJsonString) throws APIException { if (swaggerJsonString == null || swaggerJsonString.isEmpty()) { handleException(log, "Swagger provided is empty, hence unable to generate API", null); } JsonParser jsonParser = new JsonParser(); JsonElement swaggerJson = jsonParser.parse(swaggerJsonString); if (swaggerJson.isJsonObject()) { APIGenerator apiGenerator = new APIGenerator(swaggerJson.getAsJsonObject()); try { API api = apiGenerator.generateSynapseAPI(); return APISerializer.serializeAPI(api).toString(); } catch (APIGenException e) { handleException(log, "Error occurred while generating API", e); } } else { handleException(log, "Error in swagger definition format: should be a json object", null); } return ""; }
Source:
<code>public Connection build() { try { <START> setupLogger(); <END> if (url == null) { throw new RuntimeException("The 'url' parameter is mandatory"); } if (!insecure && keyStorePath == null) { throw new RuntimeException("The 'keyStorePath' is mandatory in secure mode"); } if (keyStorePath != null && !new File(keyStorePath).exists()) { throw new RuntimeException( String.format("The keystore file '%s' doesn't exist'", keyStorePath) ); } urlobj = new URL(url); HttpConnection connection = new HttpConnection(); connection.setClient(createDefaultHttpClient()); connection.setUrl(url); connection.setUser(user); connection.setPassword(password); connection.setInsecure(insecure); connection.setDebug(debug); connection.setKerberos(kerberos); return connection; } catch (Exception e) { throw new RuntimeException(e); } }</code><technical_language>I remove parameter 'log' 'debug'</technical_language>

Target:
public Connection build() { try { if (url == null) { throw new RuntimeException("The 'url' parameter is mandatory"); } if (!insecure && keyStorePath == null) { throw new RuntimeException("The 'keyStorePath' is mandatory in secure mode"); } if (keyStorePath != null && !new File(keyStorePath).exists()) { throw new RuntimeException( String.format("The keystore file '%s' doesn't exist'", keyStorePath) ); } urlobj = new URL(url); HttpConnection connection = new HttpConnection(); connection.setClient(createDefaultHttpClient()); connection.setUrl(url); connection.setUser(user); connection.setPassword(password); connection.setInsecure(insecure); connection.setDebug(debug); connection.setKerberos(kerberos); return connection; } catch (Exception e) { throw new RuntimeException(e); } }
Source:
<code>public void tryBecomeLeader() { leaseId.getAndSet(leaseBlobManager.acquireLease(LEASE_TIME_IN_SEC, leaseId.get())); if (leaseId.get() != null) { LOG.info("Became leader!"); isLeader.set(true); <START> leaderElectorListener.onBecomingLeader(); <END> } }</code><technical_language>Null check for leaderElectorListener</technical_language>

Target:
public void tryBecomeLeader() { try { leaseId.getAndSet(leaseBlobManager.acquireLease(LEASE_TIME_IN_SEC, leaseId.get())); if (leaseId.get() != null) { LOG.info("Became leader with lease ID {}.", leaseId.get()); isLeader.set(true); if (leaderElectorListener != null) { leaderElectorListener.onBecomingLeader(); } } } catch (AzureException e) { LOG.error("Error while trying to acquire lease.", e); } }
Source:
<code>public void getPrefixProvider_shouldDefaultProperly() { SequentialIdentifierGenerator gen = new SequentialIdentifierGenerator(); Assert.assertEquals("pre-", gen.getPrefixProvider("pre-").getValue()); Assert.assertEquals(" -", gen.getPrefixProvider(" -").getValue()); Assert.assertEquals("", gen.getPrefixProvider(null).getValue()); <START> Assert.assertEquals("", gen.getPrefixProvider("").getValue()); <END> Assert.assertEquals("", gen.getPrefixProvider(" ").getValue()); when(Context.getRegisteredComponent(eq(""), eq(PrefixProvider.class))).thenThrow(new APIException("Something went wrong with that bean.")); Assert.assertEquals("provider:", gen.getPrefixProvider("provider:").getValue()); when(Context.getRegisteredComponent(eq(" "), eq(PrefixProvider.class))).thenThrow(new APIException("Something went wrong with that bean.")); Assert.assertEquals("provider: ", gen.getPrefixProvider("provider: ").getValue()); when(Context.getRegisteredComponent(eq("fooBarBean"), eq(PrefixProvider.class))).thenThrow(new APIException("Something went wrong with that bean.")); Assert.assertEquals("provider:fooBarBean", gen.getPrefixProvider("provider:fooBarBean").getValue()); }</code><technical_language>@mseaton good this</technical_language>

Target:
public void getPrefixProvider_shouldDefaultProperly() { SequentialIdentifierGenerator gen = new SequentialIdentifierGenerator(); Assert.assertEquals("pre-", gen.getPrefixProvider("pre-").getValue()); Assert.assertEquals(" -", gen.getPrefixProvider(" -").getValue()); Assert.assertEquals("", gen.getPrefixProvider(null).getValue()); Assert.assertEquals("", gen.getPrefixProvider("").getValue()); Assert.assertEquals("", gen.getPrefixProvider(" ").getValue()); }
Source:
<code>protected HandlerAdapter configureListenerAdapter(MessagingMessageListenerAdapter messageListener) { List<InvocableHandlerMethod> invocableHandlerMethods = new ArrayList<InvocableHandlerMethod>(); for (Method method : this.methods) { invocableHandlerMethods.add(getMessageHandlerMethodFactory() <START> .createInvocableHandlerMethod(getBean(), method)); <END> } this.delegatingHandler = new DelegatingInvocableHandler(invocableHandlerMethods, this.bean, getResolver(), getBeanExpressionContext()); return new HandlerAdapter(this.delegatingHandler); }</code><technical_language>I if end some issue, bean a field setter for in super class... for MultiMethodRabbitListenerEndpoint setters model. for methods</technical_language>

Target:
protected HandlerAdapter configureListenerAdapter(MessagingMessageListenerAdapter messageListener) { List<InvocableHandlerMethod> invocableHandlerMethods = new ArrayList<InvocableHandlerMethod>(); for (Method method : this.methods) { invocableHandlerMethods.add(getMessageHandlerMethodFactory() .createInvocableHandlerMethod(getBean(), method)); } this.delegatingHandler = new DelegatingInvocableHandler(invocableHandlerMethods, getBean(), getResolver(), getBeanExpressionContext()); return new HandlerAdapter(this.delegatingHandler); }
Source:
<code>public static Object fallback(InlineCache callSite, Object[] args) throws Throwable { MethodHandle target = (MethodHandle) args[0]; MethodHandle invoker = MethodHandles.dropArguments(target, 0, MethodHandle.class); MethodType type = invoker.type(); if (type.parameterType(type.parameterCount() - 1) == Object[].class) { if (target.isVarargsCollector() && isLastArgumentAnArray(type.parameterCount(), args)) { invoker = invoker.asFixedArity().asType(callSite.type()); } else { invoker = invoker.asCollector(Object[].class, callSite.type().parameterCount() - target.type().parameterCount()); } } <START> if (callSite.contstant) { <END> Object constantValue = invoker.invokeWithArguments(args); MethodHandle constant = MethodHandles.constant(constantValue.getClass(), constantValue); constant = MethodHandles.dropArguments(constant, 0, type.parameterArray()); callSite.setTarget(constant.asType(type)); return constantValue; } else { MethodHandle guard = GUARD.bindTo(target); MethodHandle root = guardWithTest(guard, invoker, callSite.fallback); callSite.setTarget(root); return invoker.invokeWithArguments(args); } }</code><technical_language>Typo! constant contstant :beers:</technical_language>

Target:
public static Object fallback(InlineCache callSite, Object[] args) throws Throwable { MethodHandle target = (MethodHandle) args[0]; MethodHandle invoker = MethodHandles.dropArguments(target, 0, MethodHandle.class); MethodType type = invoker.type(); if (type.parameterType(type.parameterCount() - 1) == Object[].class) { if (target.isVarargsCollector() && isLastArgumentAnArray(type.parameterCount(), args)) { invoker = invoker.asFixedArity().asType(callSite.type()); } else { invoker = invoker.asCollector(Object[].class, callSite.type().parameterCount() - target.type().parameterCount()); } } if (callSite.constant) { Object constantValue = invoker.invokeWithArguments(args); MethodHandle constant; if (constantValue == null) { constant = MethodHandles.constant(Object.class, constantValue); } else { constant = MethodHandles.constant(constantValue.getClass(), constantValue); } constant = MethodHandles.dropArguments(constant, 0, type.parameterArray()); callSite.setTarget(constant.asType(type)); return constantValue; } else { MethodHandle guard = GUARD.bindTo(target); MethodHandle root = guardWithTest(guard, invoker, callSite.fallback); callSite.setTarget(root); return invoker.invokeWithArguments(args); } }
Source:
<code>private void setupEmoji() { try { final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class); if (dao.queryForAll().size() != 0) return; final String emojis[] = getAssets().list("emoji"); TransactionManager.callInTransaction(getDatabaseHelper() .getConnectionSource(), new Callable<Void>() { public Void call() throws Exception { for (String newEmoji : emojis) { <START> if (newEmoji.endsWith(".png")) { <END> newEmoji = newEmoji.substring(0, newEmoji.length() - 4); } dao.create(new Emoji(newEmoji)); } return null; } }); } catch (SQLException | IOException e) { ZLog.logException(e); } }</code><technical_language>simply newEmoji.replace(target, replacement)</technical_language>

Target:
private void setupEmoji() { try { final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class); if (dao.queryForAll().size() != 0) return; final String emojis[] = getAssets().list("emoji"); TransactionManager.callInTransaction(getDatabaseHelper() .getConnectionSource(), new Callable<Void>() { public Void call() throws Exception { for (String newEmoji : emojis) { newEmoji = newEmoji.replace(".png", ""); dao.create(new Emoji(newEmoji)); } return null; } }); } catch (SQLException | IOException e) { ZLog.logException(e); } }
Source:
<code>private static System.LoggerFinder getSLF4JSystemLoggerFinder() { <START> var loggerFinders = new ArrayList<System.LoggerFinder>(); ServiceLoader.load(System.LoggerFinder.class).forEach(loggerFinders::add); assertEquals("There should be exactly one `LoggerFinder`.", 1, loggerFinders.size()); var loggerFinder = loggerFinders.get(0); assertEquals("The `LoggerFinder` should be of type `SLF4JSystemLoggerFinder`.", SLF4JSystemLoggerFinder.class, loggerFinder.getClass()); return loggerFinder; <END> }</code><technical_language>Maybe: suggestion // this fails test is executed module path // module declaration declare // System.LoggerFinder return ServiceLoader.load(System.LoggerFinder.class).stream() .filter(finder -> finder instanceof SLF4JSystemLoggerFinder) .findAny() .orElseThrow(); Note: this orElseThrow requires JDK 10</technical_language>

Target:
private static System.LoggerFinder getSLF4JSystemLoggerFinder() { return ServiceLoader.load(System.LoggerFinder.class).stream() .filter(finderProvider -> SLF4JSystemLoggerFinder.class.isAssignableFrom(finderProvider.type())) .findAny() .map(ServiceLoader.Provider::get) .orElseThrow(); }
Source:
<code>public void addProcessVariable(String variable, Object variableValue) { if (this.processVariables == null) { <START> this.processVariables = new HashMap<String, Object>(); <END> } this.processVariables.put(variable, variableValue); }</code><technical_language><String, Object> needed</technical_language>

Target:
public void addProcessVariable(String variable, Object variableValue) { if (this.processVariables == null) { this.processVariables = new HashMap<>(); } this.processVariables.put(variable, variableValue); }
Source:
<code>public void forceValue(MonitoringBaseElement element, String value) throws DeploymentException{ String request = <START> MessageFormat.format(FORECE_VALUE, <END> this.id++, value, element.getQualifiedString(), "true"); try { sendREQ(element.getResourceString(), request); } catch (IOException e) { throw new DeploymentException(MessageFormat.format(Messages.DeploymentExecutor_ForceValueFailed, element.getQualifiedString(), value), e); } }</code><technical_language>typo</technical_language>

Target:
public void forceValue(MonitoringBaseElement element, String value) throws DeploymentException{ String request = MessageFormat.format(FORCE_VALUE, this.id++, value, element.getQualifiedString(), "true"); try { sendREQ(element.getResourceString(), request); } catch (IOException e) { throw new DeploymentException(MessageFormat.format(Messages.DeploymentExecutor_ForceValueFailed, element.getQualifiedString(), value), e); } }
Source:
<code>protected void assertObjectsEqual(final Object expected, final Object actual) { if (expected == null) { assertNull(actual); } else { assertNotNull("Should not be null", actual); if (actual.getClass().isArray()) { assertArrayEquals(expected, actual); } else { if (!expected.equals(actual)) { <START> assertEquals(xstream.toXML(expected) + " vs. " + xstream.toXML(actual), expected, actual); <END> } } } }</code><technical_language>CI build shows 90+ failing tests, caused this change. some of other converters lossy well, some of failures for objects do hashCode equals methods defined, comparison fails distinct references deserialization: junit.framework.AssertionFailedError: <camera name="Rebel 350"> <n> <name>foo</name> </n> </camera> vs. <camera name="Rebel 350"> <n> <name>foo</name> </n> </camera> expected:<com.thoughtworks.acceptance.AttributeTest$Camera@50d640dd> was:<com.thoughtworks.acceptance.AttributeTest$Camera@447bf09d> small nit, I change spacing failure messages a bit easier read: suggestion assertEquals(xstream.toXML(expected) + "\n vs.\n" + xstream.toXML(actual), expected, actual);</technical_language>

Target:
protected void assertObjectsEqual(final Object expected, final Object actual) { if (expected == null) { assertNull(actual); } else { assertNotNull("Should not be null", actual); if (actual.getClass().isArray()) { assertArrayEquals(expected, actual); } else { if (!expected.equals(actual)) { assertEquals("Object deserialization failed", "DESERIALIZED OBJECT\n" + xstream.toXML(expected), "DESERIALIZED OBJECT\n" + xstream.toXML(actual)); } } } }