auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Filter getFilter() { return new Filter() { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); ArrayList<Label> filteredArrayList = new ArrayList<>(); if (labels == null) { labels = new ArrayList<>(displayedLabels); } if (constraint == null || constraint.length() == 0) { <START> Collections.swap(labels, 0 , labels.indexOf(Label.fromText("BOOKMARK"))); <END> results.count = labels.size(); results.values = labels; } else { constraint = constraint.toString().toLowerCase(); for (Label label : labels) { String data = label.toString(); if (data.toLowerCase().startsWith(constraint.toString())) { filteredArrayList.add(Label.fromText(label.getText())); } } results.count = filteredArrayList.size(); results.values = filteredArrayList; } return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { displayedLabels = (ArrayList<Label>) results.values; notifyDataSetChanged(); } }; }</code><technical_language>this completely unnecessary, enums inherently ordered. This is culprit in Label, mucking ordering public static final Map<String, Label> TEXT_TO_DESCRIPTION = new HashMap<>(Label.values().length); static { for (Label label : values()) { TEXT_TO_DESCRIPTION.put(label.text, label); } } This map need exist, usage is constructing this class. A list created out of Label.values() referenced bookmark labels.indexOf(Label.BOOKMARK)</technical_language>

Target:
public Filter getFilter() { return new Filter() { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); ArrayList<Label> filteredArrayList = new ArrayList<>(); if (labels == null) { labels = new ArrayList<>(displayedLabels); } if (constraint == null || constraint.length() == 0) { results.count = labels.size(); results.values = labels; } else { constraint = constraint.toString().toLowerCase(); for (Label label : labels) { String data = label.toString(); if (data.toLowerCase().startsWith(constraint.toString())) { filteredArrayList.add(Label.fromText(label.getText())); } } results.count = filteredArrayList.size(); results.values = filteredArrayList; } return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { displayedLabels = (ArrayList<Label>) results.values; notifyDataSetChanged(); } }; }
Source:
<code>public static HelloExtension fromExtensionDataReader(DatagramReader extensionDataReader) { List<SupportedGroup> groups = new ArrayList<>(); int listLength = extensionDataReader.read(LIST_LENGTH_BITS); DatagramReader rangeReader = extensionDataReader.createRangeReader(listLength); while (rangeReader.bytesAvailable()) { int id = rangeReader.read(CURVE_BITS); SupportedGroup group = SupportedGroup.fromId(id); <START> if (group != null && group.isUsable()) { <END> groups.add(group); } } return new SupportedEllipticCurvesExtension(Collections.unmodifiableList(groups)); }</code><technical_language>This is extension deserialization ? I expect check group is usable</technical_language>

Target:
public static HelloExtension fromExtensionDataReader(DatagramReader extensionDataReader) { List<SupportedGroup> groups = new ArrayList<>(); int listLength = extensionDataReader.read(LIST_LENGTH_BITS); DatagramReader rangeReader = extensionDataReader.createRangeReader(listLength); while (rangeReader.bytesAvailable()) { int id = rangeReader.read(CURVE_BITS); SupportedGroup group = SupportedGroup.fromId(id); if (group != null) { groups.add(group); } } return new SupportedEllipticCurvesExtension(Collections.unmodifiableList(groups)); }
Source:
<code>public ConnectionPolicy(GatewayConnectionConfig gatewayConnectionConfig) { this(ConnectionMode.GATEWAY); <START> this.enableTcpConnectionEndpointRediscovery = false; <END> this.idleHttpConnectionTimeout = gatewayConnectionConfig.getIdleConnectionTimeout(); this.maxConnectionPoolSize = gatewayConnectionConfig.getMaxConnectionPoolSize(); this.requestTimeout = BridgeInternal.getRequestTimeoutFromGatewayConnectionConfig(gatewayConnectionConfig); this.proxy = gatewayConnectionConfig.getProxy(); }</code><technical_language>Changeing default considered breaking. enabled default</technical_language>

Target:
public ConnectionPolicy(GatewayConnectionConfig gatewayConnectionConfig) { this(ConnectionMode.GATEWAY); this.tcpConnectionEndpointRediscoveryEnabled = true; this.idleHttpConnectionTimeout = gatewayConnectionConfig.getIdleConnectionTimeout(); this.maxConnectionPoolSize = gatewayConnectionConfig.getMaxConnectionPoolSize(); this.requestTimeout = BridgeInternal.getRequestTimeoutFromGatewayConnectionConfig(gatewayConnectionConfig); this.proxy = gatewayConnectionConfig.getProxy(); }
Source:
<code>public List<DiagnosticReport> getFHIRDiagnosticReportBySubjectName(String name) { log.debug("In Radiology Handler : getFHIRDiagnosticReportBySubjectName : " + name); <START> ArrayList<DiagnosticReport> diagnosticReports = new ArrayList<DiagnosticReport>(); <END> String serverBase = FHIRUtils.getDiagnosticReportRadiologyBaseServerURL(); ICriterion<ReferenceClientParam> diagnosticReportBySubject = DiagnosticReport.SUBJECT.hasChainedProperty( Patient.GIVEN.matches().value(name)); ICriterion<TokenClientParam> diagnosticReportByService = DiagnosticReport.SERVICE.exactly().code("RAD"); Bundle bundle = FHIRRESTfulGenericClient.search(serverBase, DiagnosticReport.class, diagnosticReportBySubject, diagnosticReportByService); log.debug("Bundle size : " + bundle.size()); for (BundleEntry entry : bundle.getEntries()) { IResource resource = entry.getResource(); log.debug("Resource Type : " + resource.getResourceName()); if (resource.getResourceName().equals("DiagnosticReport")) { DiagnosticReport diagnosticReport = (DiagnosticReport) resource; diagnosticReports.add(diagnosticReport); } } return diagnosticReports; }</code><technical_language>abstract classes List<DiagnosticReport> diagnosticReports = new ArrayList<DiagnosticReport>();</technical_language>

Target:
public List<DiagnosticReport> getFHIRDiagnosticReportBySubjectName(String name) { if (log.isDebugEnabled()) { log.debug("In Radiology Handler : getFHIRDiagnosticReportBySubjectName : " + name); } List<DiagnosticReport> diagnosticReports = new ArrayList<DiagnosticReport>(); String serverBase = FHIRUtils.getDiagnosticReportRadiologyBaseServerURL(); ICriterion<ReferenceClientParam> diagnosticReportBySubject = DiagnosticReport.SUBJECT.hasChainedProperty( Patient.GIVEN.matches().value(name)); ICriterion<TokenClientParam> diagnosticReportByService = DiagnosticReport.SERVICE.exactly().code("RAD"); Bundle bundle = FHIRRESTfulGenericClient.searchWhereReferenceAndToken(serverBase, DiagnosticReport.class, diagnosticReportBySubject, diagnosticReportByService); if (log.isDebugEnabled()) { log.debug("Bundle size : " + bundle.size()); } for (BundleEntry entry : bundle.getEntries()) { IResource resource = entry.getResource(); if (log.isDebugEnabled()) { log.debug("Resource Type : " + resource.getResourceName()); } if (resource.getResourceName().equals("DiagnosticReport")) { DiagnosticReport diagnosticReport = (DiagnosticReport) resource; diagnosticReports.add(diagnosticReport); } } return diagnosticReports; }
Source:
<code>public EhcacheEntityMessage decode(byte[] payload) { ByteBuffer message = ByteBuffer.wrap(payload); byte[] encodedMsg = new byte[message.capacity() - 1]; <START> message.get(); <END> message.get(encodedMsg, 0, encodedMsg.length); EhcacheEntityMessage entityMessage = (EhcacheEntityMessage) Util.unmarshall(encodedMsg); return entityMessage; }</code><technical_language>weird. opcode there, I double check is correct instead of dropping it</technical_language>

Target:
public EhcacheEntityMessage decode(byte[] payload) { ByteBuffer message = ByteBuffer.wrap(payload); byte[] encodedMsg = new byte[message.capacity() - OPCODE_SIZE]; byte opCode = message.get(); if (opCode == LifecycleMessage.LIFECYCLE_MSG_OP_CODE) { message.get(encodedMsg, 0, encodedMsg.length); EhcacheEntityMessage entityMessage = (EhcacheEntityMessage) Util.unmarshall(encodedMsg); return entityMessage; } else { throw new IllegalArgumentException("LifeCycleMessage operation not defined for : " + opCode); } }
Source:
<code>public static void registerEndpoints(AppConfiguration cfg) { Beans beans = new Beans(cfg.websitePath()); ResponseTransformer transformer = beans.getResponseTransformer(); registerPostHandler("/begin", openTransaction(beans), transformer); registerPostHandler("/publish", addFiles(beans), transformer); registerPostHandler("/commit", commitTransaction(beans), transformer); registerPostHandler("/CommitManifest", sendManifest(beans), transformer); registerPostHandler("/rollback", rollbackTransaction(beans), transformer); registerGetHandler("/transaction", getTransaction(beans), beans.getResponseTransformer()); <START> registerGetHandler("/contentHash", getContentHash(beans, cfg.isVerifyPublishEnabled()), transformer); <END> registerGetHandler("*", getNotFoundHadler(), transformer); }</code><technical_language>worth updating line transformer instead of beans.getResponseTransformer()) for consistency</technical_language>

Target:
public static void registerEndpoints(AppConfiguration cfg) { Beans beans = new Beans(cfg.websitePath()); ResponseTransformer transformer = beans.getResponseTransformer(); registerPostHandler("/begin", openTransaction(beans), transformer); registerPostHandler("/publish", addFiles(beans), transformer); registerPostHandler("/commit", commitTransaction(beans), transformer); registerPostHandler("/CommitManifest", sendManifest(beans), transformer); registerPostHandler("/rollback", rollbackTransaction(beans), transformer); registerGetHandler("/transaction", getTransaction(beans), transformer); registerGetHandler("/contentHash", getContentHash(beans, cfg.isVerifyPublishEnabled()), transformer); registerGetHandler("*", getNotFoundHandler(), transformer); }
Source:
<code>private Set<Object> collectParentTestInstances(final ExtensionContext context) { Set<Object> testInstances = new LinkedHashSet<>(); Optional<ExtensionContext> current = Optional.of(context); while (current.isPresent()) { ExtensionContext ctx = current.get(); List<Object> contextTestInstances = ctx.getTestInstances() .map(TestInstances::getAllInstances) .orElseGet(Collections::emptyList); for (int i = contextTestInstances.size() - 1; i >= 0; --i) { testInstances.add(contextTestInstances.get(i)); } current = ctx.getParent(); } <START> return testInstances; <END> }</code><technical_language>Assuming order is important, I this method body replaced with: java List<Object> allInstances = new ArrayList<>(ctx.getRequiredTestInstances().getAllInstances()); Collections.reverse(allInstances); return new LinkedHashSet<>(allInstances);</technical_language>

Target:
private Set<Object> collectParentTestInstances(final ExtensionContext context) { List<Object> allInstances = new ArrayList<>(context.getRequiredTestInstances().getAllInstances()); Collections.reverse(allInstances); return new LinkedHashSet<>(allInstances); }
Source:
<code>public TmfConstantTransform(@NonNull ITmfTimestamp offset) { <START> fOffset = offset.getValue(); <END> }</code><technical_language>= new TmfNanoTimestamp(offset).getValue() else wrong scale</technical_language>

Target:
public TmfConstantTransform(@NonNull ITmfTimestamp offset) { this(new TmfNanoTimestamp(offset).getValue()); }
Source:
<code>public void controller(FragmentConfiguration config) throws Exception { if (config.getAttribute("conceptSet") != null) { List < Map < String, Object >> options = (List<Map<String, Object>>) config.getAttribute("options"); if (options == null) { options = new ArrayList < Map < String, Object >> (); } String conceptSetUuid = (String) config.getAttribute("conceptSet"); Concept conceptSet = Context.getConceptService().getConceptByUuid(conceptSetUuid); for (Concept concept: conceptSet.getSetMembers()) { Map < String, Object > option = new HashMap < String, Object > (); option = new HashMap < String, Object > (); option.put("value", concept.getId().toString()); option.put(OPTION_LABEL, concept.getName(Context.getUserContext().getLocale()).getName()); options.add(option); } <START> Collections.sort(options, mapComparator); <END> config.addAttribute("options", options); } }</code><technical_language>a one-off thing, inline it: java Collections.sort(options, new Comparator<Map<String, Object>>() { public int compare(Map<String, Object> m1, Map<String, Object> m2) { return ((String) m1.get(OPTION_LABEL)).compareTo((String) m2.get(OPTION_LABEL)); } });</technical_language>

Target:
public void controller(FragmentConfiguration config) throws Exception { if (config.getAttribute("conceptSet") != null) { List < Map < String, Object >> options = (List<Map<String, Object>>) config.getAttribute("options"); if (options == null) { options = new ArrayList < Map < String, Object >> (); } String conceptSetUuid = (String) config.getAttribute("conceptSet"); Concept conceptSet = Context.getConceptService().getConceptByUuid(conceptSetUuid); for (Concept concept: conceptSet.getSetMembers()) { Map < String, Object > option = new HashMap < String, Object > (); option = new HashMap < String, Object > (); option.put("value", concept.getId().toString()); option.put(OPTION_LABEL, concept.getName(Context.getUserContext().getLocale()).getName()); options.add(option); } Collections.sort(options, new Comparator<Map<String, Object>>() { public int compare(Map<String, Object> m1, Map<String, Object> m2) { return ((String) m1.get(OPTION_LABEL)).compareTo((String) m2.get(OPTION_LABEL)); } }); config.addAttribute("options", options); } }
Source:
<code>void property(Property prop) { boolean depr = prop.isDeprecated(); doc.print("| <a name=\"" + prop.getKey().replace(".", "_") + "\" class=\"prop\"></a> " + prop.getKey() + " | "); doc.print((depr ? "**Deprecated.** " : "") + strike(sanitize(prop.getDescription()), depr) + "<br>"); doc.print(strike("**type:** " + prop.getType().name(), depr) + ", "); doc.print(strike("**zk mutable:** " + isZooKeeperMutable(prop), depr) + ", "); String defaultValue = sanitize(prop.getRawDefaultValue()).trim(); if (defaultValue.length() == 0) { defaultValue = strike("**default value:** empty", depr); } else if (defaultValue.contains("\n")) { defaultValue = strike("**default value:** ", depr) + "\n```\n" + defaultValue + "\n```\n"; } else { if (prop.getType() == PropertyType.CLASSNAME <START> && defaultValue.startsWith("org.apache.accumulo.core")) { <END> defaultValue = strike("**default value:** " + "{% jlink -f " + defaultValue + " %}", depr); } else { defaultValue = strike("**default value:** " + "`" + defaultValue + "`", depr); } } doc.println(defaultValue + " |"); }</code><technical_language>I this startsWith("org.apache.accumulo"). update jlink tag handle package prefeixes</technical_language>

Target:
void property(Property prop) { boolean depr = prop.isDeprecated(); doc.print("| <a name=\"" + prop.getKey().replace(".", "_") + "\" class=\"prop\"></a> " + prop.getKey() + " | "); doc.print((depr ? "**Deprecated.** " : "") + strike(sanitize(prop.getDescription()), depr) + "<br>"); doc.print(strike("**type:** " + prop.getType().name(), depr) + ", "); doc.print(strike("**zk mutable:** " + isZooKeeperMutable(prop), depr) + ", "); String defaultValue = sanitize(prop.getRawDefaultValue()).trim(); if (defaultValue.length() == 0) { defaultValue = strike("**default value:** empty", depr); } else if (defaultValue.contains("\n")) { defaultValue = strike("**default value:** ", depr) + "\n```\n" + defaultValue + "\n```\n"; } else { if (prop.getType() == PropertyType.CLASSNAME && defaultValue.startsWith("org.apache.accumulo")) { defaultValue = strike("**default value:** " + "{% jlink -f " + defaultValue + " %}", depr); } else { defaultValue = strike("**default value:** " + "`" + defaultValue + "`", depr); } } doc.println(defaultValue + " |"); }
Source:
<code>public void applyChunk(JSONObject sech) throws UnknownHttpResponseException { <START> parseDict(_run("applyChunk", sech)); <END> }</code><technical_language>return <LINK_0></technical_language>

Target:
public void applyChunk(JSONObject sech) throws UnknownHttpResponseException { _run("applyChunk", sech); }
Source:
<code>private static void configureHttpProxy() throws MalformedURLException { for (String protocol : new String[] { "http", "https" }) { final String s = System.getenv(protocol + "_proxy"); if (s == null || s.equals("")) return; final URL u = new URL( (s.indexOf("://") == -1) ? protocol + "://" + s : s); <START> if (!protocol.equals(u.getProtocol())) END> throw new MalformedURLException(MessageFormat.format( CLIText.get().invalidHttpProxyOnlyHttpSupported, s)); final String proxyHost = u.getHost(); final int proxyPort = u.getPort(); System.setProperty(protocol + ".proxyHost", proxyHost); if (proxyPort > 0) System.setProperty(protocol + ".proxyPort", String.valueOf(proxyPort)); final String userpass = u.getUserInfo(); if (userpass != null && userpass.contains(":")) { final int c = userpass.indexOf(':'); final String user = userpass.substring(0, c); final String pass = userpass.substring(c + 1); CachedAuthenticator.add( new CachedAuthenticator.CachedAuthentication(proxyHost, proxyPort, user, pass)); } } }</code><technical_language>note a proxy for https is a advertised http URL... i change this if (!u.getProtocol.startsWith("http"))</technical_language>

Target:
private static void configureHttpProxy() throws MalformedURLException { for (String protocol : new String[] { "http", "https" }) { final String s = System.getenv(protocol + "_proxy"); if (s == null || s.equals("")) return; final URL u = new URL( (s.indexOf("://") == -1) ? protocol + "://" + s : s); if (!u.getProtocol().startsWith("http")) throw new MalformedURLException(MessageFormat.format( CLIText.get().invalidHttpProxyOnlyHttpSupported, s)); final String proxyHost = u.getHost(); final int proxyPort = u.getPort(); System.setProperty(protocol + ".proxyHost", proxyHost); if (proxyPort > 0) System.setProperty(protocol + ".proxyPort", String.valueOf(proxyPort)); final String userpass = u.getUserInfo(); if (userpass != null && userpass.contains(":")) { final int c = userpass.indexOf(':'); final String user = userpass.substring(0, c); final String pass = userpass.substring(c + 1); CachedAuthenticator.add( new CachedAuthenticator.CachedAuthentication(proxyHost, proxyPort, user, pass)); } } }
Source:
<code>public GeoEntry createGeoEntry(final String line, String entryResource) { final String[] fields = line.split("\\t", -1); Optional<CountryCode> optionalCountryCode = isoStandard .getStandardEntries() .stream() .filter(c -> c.getAsFormat("alpha2").equals(fields[8])) .findFirst(); String countryCode = fields[8]; <START> if (optionalCountryCode.isPresent()) { <END> countryCode = optionalCountryCode.get().getAsFormat("alpha3"); } return new GeoEntry.Builder() .name(fields[1]) .latitude(Double.parseDouble(fields[4])) .longitude(Double.parseDouble(fields[5])) .featureCode(fields[7]) .population(Long.parseLong(fields[14])) .alternateNames(fields[3]) .countryCode(countryCode) .importLocation(entryResource) .build(); }</code><technical_language>do this if want get rid of isPresent check java String countryCode = optionalCountryCode .map(cc -> cc.getAsFormat("alpha3") .orElse(fields[8]); (in fact skip storing optionalCountryCode var if wish)</technical_language>

Target:
public GeoEntry createGeoEntry(final String line, String entryResource) { final String[] fields = line.split("\\t", -1); final String countryCodeAlpha2 = fields[8]; String countryCodeAlpha3 = isoStandard .getStandardEntries() .stream() .filter(c -> c.getAsFormat("alpha2").equals(countryCodeAlpha2)) .findFirst() .map(cc -> cc.getAsFormat("alpha3")) .orElse(countryCodeAlpha2); return new GeoEntry.Builder() .name(fields[1]) .latitude(Double.parseDouble(fields[4])) .longitude(Double.parseDouble(fields[5])) .featureCode(fields[7]) .population(Long.parseLong(fields[14])) .alternateNames(fields[3]) .countryCode(countryCodeAlpha3) .importLocation(entryResource) .build(); }
Source:
<code>protected File computeCorruptedFileDumpDir(File persistDir, DataSchema schema) { return new File( persistDir.getAbsolutePath() <START> .replace(schema.getDataSource(), "corrupted/" + schema.getDataSource()) <END> ); }</code><technical_language>Path build path assume "/" is proper delimiter</technical_language>

Target:
protected File computeCorruptedFileDumpDir(File persistDir, DataSchema schema) { return new File( persistDir.getAbsolutePath() .replace(schema.getDataSource(), "corrupted" + File.pathSeparator + schema.getDataSource()) ); }
Source:
<code>public PersistedCassandraFrameworkConfiguration( @NotNull final State state, @NotNull final String frameworkName, @NotNull final CassandraFrameworkProtos.CassandraConfigRole defaultConfigRole, final long healthCheckIntervalSeconds, final long bootstrapGraceTimeSec ) { super( "CassandraFrameworkConfiguration", state, new Supplier<CassandraFrameworkConfiguration>() { @Override public CassandraFrameworkConfiguration get() { return CassandraFrameworkConfiguration.newBuilder() .setFrameworkName(frameworkName) <START> .setDefaultConfigRole(defaultConfigRole) <END> .setHealthCheckIntervalSeconds(healthCheckIntervalSeconds) .setBootstrapGraceTimeSeconds(bootstrapGraceTimeSec) .build(); } }, new Function<byte[], CassandraFrameworkConfiguration>() { @Override public CassandraFrameworkConfiguration apply(final byte[] input) { try { return CassandraFrameworkConfiguration.parseFrom(input); } catch (InvalidProtocolBufferException e) { throw new ProtoUtils.RuntimeInvalidProtocolBufferException(e); } } }, new Function<CassandraFrameworkConfiguration, byte[]>() { @Override public byte[] apply(final CassandraFrameworkConfiguration input) { return input.toByteArray(); } } ); }</code><technical_language>Move building of default config role here</technical_language>

Target:
public PersistedCassandraFrameworkConfiguration( @NotNull final State state, @NotNull final String frameworkName, @NotNull final CassandraFrameworkProtos.CassandraConfigRole defaultConfigRole, final long healthCheckIntervalSeconds, final long bootstrapGraceTimeSec ) { super( "CassandraFrameworkConfiguration", state, new Supplier<CassandraFrameworkConfiguration>() { @Override public CassandraFrameworkConfiguration get() { return CassandraFrameworkConfiguration.newBuilder() .setFrameworkName(frameworkName) .setDefaultConfigRole(fillConfigRoleGaps(defaultConfigRole)) .setHealthCheckIntervalSeconds(healthCheckIntervalSeconds) .setBootstrapGraceTimeSeconds(bootstrapGraceTimeSec) .build(); } }, new Function<byte[], CassandraFrameworkConfiguration>() { @Override public CassandraFrameworkConfiguration apply(final byte[] input) { try { return CassandraFrameworkConfiguration.parseFrom(input); } catch (InvalidProtocolBufferException e) { throw new ProtoUtils.RuntimeInvalidProtocolBufferException(e); } } }, new Function<CassandraFrameworkConfiguration, byte[]>() { @Override public byte[] apply(final CassandraFrameworkConfiguration input) { return input.toByteArray(); } } ); }
Source:
<code>public String getSessionIdBySeqId(long sessionSequenceId) { return findFirstSessionByData(sessionSequenceId, ENGINE_SESSION_SEQ_ID); <START> } <END></code><technical_language>I simpler adding session id session entry constructing. loop sessionInfoMap.values() time called function findFirstSessionByData is needed in this case, if yes, squashed here. critical</technical_language>

Target:
public String getSessionIdBySeqId(long sessionSequenceId) { String sessionId = null; for (SessionInfo sessionInfo : sessionInfoMap.values()) { if (sessionInfo.contentOfSession.get(ENGINE_SESSION_SEQ_ID) == sessionSequenceId) { sessionId = (String) sessionInfo.contentOfSession.get(ENGINE_SESSION_ID); break; } } return sessionId; }
Source:
<code>public MarketHistory(Market m) { super(); <START> this.m = market; <END> history = new HashMap<String, List<Double>>(); }</code><technical_language>This changed to: this.market = m;</technical_language>

Target:
public MarketHistory(Market m) { super(); this.market = m; history = new HashMap<String, List<Double>>(); }
Source:
<code>public void testDomainWithEnoughSpaceForRequest() { validator = new StorageDomainValidator(mockStorageDomain(16, 748, StorageType.NFS)); <START> assertTrue("Domain should have more space then threshold", validator.isDomainWithinThresholds().isValid()); <END> }</code><technical_language>check test is named for -)</technical_language>

Target:
public void testDomainWithEnoughSpaceForRequest() { validator = new StorageDomainValidator(mockStorageDomain(16, 748, StorageType.NFS)); assertTrue("Domain should have more space then threshold", validator.isDomainHasSpaceForRequest(10).isValid()); }
Source:
<code>protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiPowerJunction.TEXTURE); int j = guiLeft; int k = guiTop; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); int level = 100 - junction.getChargeState(); drawTexturedModalRect(j + 10, k + 11 + (level * 59 / 100), 176, level * 59 / 100, 5, 59 - (level * 59 / 100)); mc.fontRenderer.drawString(StringUtils.translate(GuiPowerJunction.PREFIX + "LogisticsPowerJunction"), guiLeft + 30, guiTop + 8, 0x404040); mc.fontRenderer.drawString(StringUtils.translate(GuiPowerJunction.PREFIX + "StoredEnergy") + ":", guiLeft + 40, guiTop + 23, 0x404040); mc.fontRenderer.drawString(StringUtils.getStringWithSpacesFromInteger(junction.getPowerLevel()) + " LP", guiLeft + 40, guiTop + 33, 0x404040); mc.fontRenderer.drawString("/ " + StringUtils.getStringWithSpacesFromInteger(LogisticsPowerJunctionTileEntity.MAX_STORAGE) + " LP", guiLeft + 40, guiTop + 43, 0x404040); <START> mc.fontRenderer.drawString("2 MJ = 5 EU = 20 RF = 10 LP", guiLeft + 24, guiTop + 58, 0x404040); <END> }</code><technical_language>change up? I that, for readable</technical_language>

Target:
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiPowerJunction.TEXTURE); int j = guiLeft; int k = guiTop; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); int level = 100 - junction.getChargeState(); drawTexturedModalRect(j + 10, k + 11 + (level * 59 / 100), 176, level * 59 / 100, 5, 59 - (level * 59 / 100)); mc.fontRenderer.drawString(StringUtils.translate(GuiPowerJunction.PREFIX + "LogisticsPowerJunction"), guiLeft + 30, guiTop + 8, 0x404040); mc.fontRenderer.drawString(StringUtils.translate(GuiPowerJunction.PREFIX + "StoredEnergy") + ":", guiLeft + 40, guiTop + 23, 0x404040); mc.fontRenderer.drawString(StringUtils.getStringWithSpacesFromInteger(junction.getPowerLevel()) + " LP", guiLeft + 40, guiTop + 33, 0x404040); mc.fontRenderer.drawString("/ " + StringUtils.getStringWithSpacesFromInteger(LogisticsPowerJunctionTileEntity.MAX_STORAGE) + " LP", guiLeft + 40, guiTop + 43, 0x404040); mc.fontRenderer.drawString("1 MJ = 5 LP", guiLeft + 30, guiTop + 58, 0x404040); mc.fontRenderer.drawString("1 EU = 2 LP", guiLeft + 100, guiTop + 58, 0x404040); mc.fontRenderer.drawString("10 RF = 5 LP", guiLeft + 24, guiTop + 68, 0x404040); }
Source:
<code>public ConsistencyLevel getDefaultConsistencyLevel() { if (this.cachedConsistencyLevel == null) { ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL; String consistencyLevelString = super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL); try { result = ConsistencyLevel <START> .valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, consistencyLevelString)); <END> } catch (IllegalArgumentException e) { this.getLogger().warn("Unknown consistency level {}, value ignored.", consistencyLevelString); } this.cachedConsistencyLevel = result; } return cachedConsistencyLevel; }</code><technical_language>please instead: ConsistencyLevel.fromServiceSerializedFormat(.) if method is accessible this package use: BridgeInternal.fromServiceSerializedFormat()</technical_language>

Target:
public ConsistencyLevel getDefaultConsistencyLevel() { if (this.consistencyLevel == null) { ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL; String consistencyLevelString = super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL); try { result = BridgeInternal.fromServiceSerializedFormat(consistencyLevelString); } catch (IllegalArgumentException e) { this.getLogger().warn("Unknown consistency level {}, value ignored.", consistencyLevelString); } this.consistencyLevel = result; } return consistencyLevel; }
Source:
<code>private static boolean isUserInBed(final long startMillis, final long endMillis, final List<AmplitudeData> alignedMotion){ if(endMillis - startMillis <= ACCEPTABLE_QUIET_PERIOD_MILLIS) { return true; } int motionCount = 0; int quietLength = 0; int maxQuietLength = 0; for(int i = 0; i< alignedMotion.size(); i++) { final AmplitudeData motion = alignedMotion.get(i); if(motion.timestamp >= startMillis + 10 * DateTimeConstants.MILLIS_PER_MINUTE && motion.timestamp <= endMillis - 10 * DateTimeConstants.MILLIS_PER_MINUTE) { if(motion.amplitude > 0) { motionCount += 1; quietLength = 0; }else{ quietLength++; if(quietLength > maxQuietLength){ maxQuietLength = quietLength; } } } } if(maxQuietLength > 90) { if (motionCount / (double) maxQuietLength <= 1d / 90) { <START> return false; <END> } } return true; }</code><technical_language>"90" constant is related ACCEPTABLE_QUIET_PERIOD_MILLIS, a static variable</technical_language>

Target:
private static boolean isUserInBed(final long startMillis, final long endMillis, final List<AmplitudeData> alignedMotion){ if(endMillis - startMillis <= ACCEPTABLE_QUIET_PERIOD_MILLIS) { return true; } int motionCount = 0; int quietLength = 0; int maxQuietLength = 0; for(int i = 0; i< alignedMotion.size(); i++) { final AmplitudeData motion = alignedMotion.get(i); if(motion.timestamp >= startMillis + 10 * DateTimeConstants.MILLIS_PER_MINUTE && motion.timestamp <= endMillis - 10 * DateTimeConstants.MILLIS_PER_MINUTE) { if(motion.amplitude > 0) { motionCount += 1; quietLength = 0; }else{ quietLength++; if(quietLength > maxQuietLength){ maxQuietLength = quietLength; } } } } if(maxQuietLength > ACCEPTABLE_MAX_QUIET_PERIOD_MILLIS) { if (motionCount / (double) maxQuietLength <= 1d / ACCEPTABLE_MAX_QUIET_PERIOD_MILLIS) { return false; } } return true; }
Source:
<code>public IdeGeneralPreferencesPresenter( IdeGeneralPreferencesView view, CoreLocalizationConstant constant, ThemeAgent themeAgent, PreferencesManager preferencesManager) { super(constant.generalTitle(), constant.generalCategory()); this.view = view; this.themeAgent = themeAgent; this.preferencesManager = preferencesManager; view.setDelegate(this); <START> revertChanges(); <END> }</code><technical_language>weird</technical_language>

Target:
public IdeGeneralPreferencesPresenter( IdeGeneralPreferencesView view, CoreLocalizationConstant constant, ThemeAgent themeAgent, PreferencesManager preferencesManager) { super(constant.generalTitle(), constant.generalCategory()); this.view = view; this.themeAgent = themeAgent; this.preferencesManager = preferencesManager; view.setDelegate(this); themeId = getStoredThemeId(); isAskBeforeClosingTab = getStoredAskBeforeClosingTab(); }
Source:
<code><START> public static AutoCompletionCandidates autoComplete(@Nullable String label) { <END> AutoCompletionCandidates c = new AutoCompletionCandidates(); Set<Label> labels = Jenkins.get().getLabels(); List<String> queries = new AutoCompleteSeeder(label).getSeeds(); for (String term : queries) { for (Label l : labels) { if (l.getName().startsWith(term)) { c.add(l.getName()); } } } return c; }</code><technical_language>suggestion @NonNull public static AutoCompletionCandidates autoComplete(@Nullable String label) {</technical_language>

Target:
public static AutoCompletionCandidates autoComplete(@Nullable String label) { AutoCompletionCandidates c = new AutoCompletionCandidates(); Set<Label> labels = Jenkins.get().getLabels(); List<String> queries = new LabelAutoCompleteSeeder(Util.fixNull(label)).getSeeds(); for (String term : queries) { for (Label l : labels) { if (l.getName().startsWith(term)) { c.add(l.getName()); } } } return c; }
Source:
<code>private static void checkIfSessionIsAssociatedWithProject(SessionId sessionId, ProjectId projectId) throws AccessControlException { final EList<Adapter> eAdapters = sessionId.eAdapters(); for (final Adapter adapter : eAdapters) { if (ShareProjectAdapter.class.isInstance(adapter)) { final ShareProjectAdapter shareAdapter = (ShareProjectAdapter) adapter; final boolean didRemove = shareAdapter.removeProject(projectId); if (!didRemove) { <START> throw new AccessControlException(Messages.AdminEmfStoreImpl_IllegalRequestToAddInitialRole); <END> } return; } } throw new AccessControlException(Messages.AdminEmfStoreImpl_IllegalRequestToAddInitialRole); }</code><technical_language>Logic is weird here, I change to: if (didRemove) { return }</technical_language>

Target:
private static void checkIfSessionIsAssociatedWithProject(SessionId sessionId, ProjectId projectId) throws AccessControlException { final EList<Adapter> eAdapters = sessionId.eAdapters(); for (final Adapter adapter : eAdapters) { if (ShareProjectAdapter.class.isInstance(adapter)) { final ShareProjectAdapter shareAdapter = (ShareProjectAdapter) adapter; final boolean didRemove = shareAdapter.removeProject(projectId); if (didRemove) { return; } throw new AccessControlException(Messages.AdminEmfStoreImpl_IllegalRequestToAddInitialRole); } } throw new AccessControlException(Messages.AdminEmfStoreImpl_IllegalRequestToAddInitialRole); }
Source:
<code>public void testMarshallDateObject() { String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<date-object>\n" + " <localDate>2017-01-01</localDate>\n" + " <localDateTime>2017-01-01T10:10:10</localDateTime>\n" + " <localTime>10:10:10</localTime>\n" + "</date-object>\n"; Set<Class<?>> extraClasses = new HashSet<Class<?>>(); extraClasses.add(DateObject.class); Marshaller marshaller = MarshallerFactory.getMarshaller( extraClasses, MarshallingFormat.JAXB, getClass().getClassLoader() ); DateObject dateObject = new DateObject(); <START> dateObject.setLocalDate( LocalDate.parse( "2017-01-01" ) ); <END> dateObject.setLocalDateTime( LocalDateTime.parse("2017-01-01T10:10:10") ); dateObject.setLocalTime( LocalTime.parse( "10:10:10" ) ); String dateObjectString = marshaller.marshall( dateObject ); assertNotNull( dateObjectString ); assertEquals( expectedString, dateObjectString ); }</code><technical_language>Instead of parse(...) of(...): LocalDate.of(2017, 1, 1) faster, String parsing</technical_language>

Target:
public void testMarshallDateObject() { String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<date-object>\n" + " <localDate>2017-01-01</localDate>\n" + " <localDateTime>2017-01-01T10:10:10</localDateTime>\n" + " <localTime>10:10:10</localTime>\n" + " <offsetDateTime>2017-01-01T10:10:10+01:00</offsetDateTime>\n" + "</date-object>\n"; Set<Class<?>> extraClasses = new HashSet<Class<?>>(); extraClasses.add(DateObject.class); Marshaller marshaller = MarshallerFactory.getMarshaller( extraClasses, MarshallingFormat.JAXB, getClass().getClassLoader() ); DateObject dateObject = new DateObject(); dateObject.setLocalDate( LocalDate.of( 2017, 1, 1 ) ); dateObject.setLocalDateTime( LocalDateTime.of( 2017, 1, 1, 10, 10, 10 ) ); dateObject.setLocalTime( LocalTime.of( 10, 10, 10 ) ); dateObject.setOffsetDateTime( OffsetDateTime.of( LocalDateTime.of( 2017, 1, 1, 10, 10, 10 ), ZoneOffset.ofHours( 1 ) ) ); String dateObjectString = marshaller.marshall( dateObject ); assertNotNull( dateObjectString ); assertEquals( expectedString, dateObjectString ); }
Source:
<code>@Override public <T> T serviceProxy(ClusterGroup prj, String name, Class<? super T> srvcCls, boolean sticky, long timeout) throws IgniteException { ctx.security().authorize(name, SecurityPermission.SERVICE_INVOKE); if (hasLocalNode(prj)) { ServiceContextImpl ctx = serviceContext(name); if (ctx != null) { Service svc = ctx.service(); if (svc != null) { if (srvcCls.isAssignableFrom(svc.getClass())) return (T)svc; <START> else if (!PlatformService.class.isAssignableFrom(svc.getClass())) <END> throw new IgniteException("Service does not implement specified interface [svcItf=" + srvcCls.getName() + ", svcCls=" + svc.getClass().getName() + ']'); } } } return new GridServiceProxy<T>(prj, name, srvcCls, sticky, timeout, ctx).proxy(); }</code><technical_language>{ } for statement</technical_language>

Target:
@Override public <T> T serviceProxy(ClusterGroup prj, String name, Class<? super T> srvcCls, boolean sticky, long timeout) throws IgniteException { ctx.security().authorize(name, SecurityPermission.SERVICE_INVOKE); if (hasLocalNode(prj)) { ServiceContextImpl ctx = serviceContext(name); if (ctx != null) { Service svc = ctx.service(); if (svc != null) { if (srvcCls.isAssignableFrom(svc.getClass())) return (T)svc; else if (!PlatformService.class.isAssignableFrom(svc.getClass())) { throw new IgniteException("Service does not implement specified interface [svcItf=" + srvcCls.getName() + ", svcCls=" + svc.getClass().getName() + ']'); } } } } return new GridServiceProxy<T>(prj, name, srvcCls, sticky, timeout, ctx).proxy(); }
Source:
<code>public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); if (processType == null) { return ExecutionResult.NOTHING_TO_DO; } List<String> impactedComponents = Arrays.asList("tFileOutputParquet", "tHiveOutput", "tRedshiftOutput", "tSqlRow", "tMatchPairing", "tMatchPredict", "tMatchModel", "tDataShuffling"); <START> IComponentConversion AdaptSchemaForDateType = new AdaptSchemaForDateType(); <END> try { for (String componentName : impactedComponents) { ModifyComponentsAction.searchAndModify(item, processType, new NameComponentFilter(componentName), Arrays.<IComponentConversion> asList(AdaptSchemaForDateType)); } return ExecutionResult.SUCCESS_NO_ALERT; } catch (Exception e) { return ExecutionResult.FAILURE; } }</code><technical_language>variable name start case character</technical_language>

Target:
public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); if (processType == null) { return ExecutionResult.NOTHING_TO_DO; } IComponentConversion adaptSchemaForDateType = new AdaptSchemaForDateType(); try { for (String componentName : IMPACTED_COMPONENTS) { ModifyComponentsAction.searchAndModify(item, processType, new NameComponentFilter(componentName), java.util.Collections.singletonList(adaptSchemaForDateType)); } return ExecutionResult.SUCCESS_NO_ALERT; } catch (Exception e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } }
Source:
<code>public Object perform(String name, Object obj, ApiRequest request) { if (obj instanceof MachineDriverRecord) { MachineDriverErrorInput machineDriverErrorInput = request.proxyRequestObject(MachineDriverErrorInput.class); if (StringUtils.isNotBlank(machineDriverErrorInput.getErrorMessage())) { DataAccessor.fields(obj).withKey(ERROR_MESSAGE).set(machineDriverErrorInput.getErrorMessage()); <START> ((MachineDriverRecord) obj).setState(CommonStatesConstants.ERROR); <END> } objectManager.persist(obj); return objectManager.reload(obj); } throw new ClientVisibleException(ResponseCodes.INTERNAL_SERVER_ERROR, "NotMachineDriver"); }</code><technical_language>cast interface, impl</technical_language>

Target:
public Object perform(String name, Object obj, ApiRequest request) { if (obj instanceof MachineDriver) { MachineDriverErrorInput machineDriverErrorInput = request.proxyRequestObject(MachineDriverErrorInput.class); if (StringUtils.isNotBlank(machineDriverErrorInput.getErrorMessage())) { DataAccessor.fields(obj).withKey(ERROR_MESSAGE).set(machineDriverErrorInput.getErrorMessage()); ((MachineDriver) obj).setState(CommonStatesConstants.ERROR); } objectManager.persist(obj); return objectManager.reload(obj); } throw new ClientVisibleException(ResponseCodes.INTERNAL_SERVER_ERROR, "NotMachineDriver"); }
Source:
<code>private String resolveUrlSource(String base, Object... format) { if (format.length != 0) { base = String.format(base, format); } try { return new URI(base).normalize().toURL().toString(); } catch (Exception e) { <START> log.error("Variable selenide.reportsUrl is incorrect: " + base, e); <END> return null; } }</code><technical_language>Format</technical_language>

Target:
private String resolveUrlSource(String base, Object... format) { if (format.length != 0) { base = String.format(base, format); } try { return new URI(base).normalize().toURL().toString(); } catch (Exception e) { log.error("Variable selenide.reportsUrl is incorrect: {}", base, e); return null; } }
Source:
<code>public void initConfig(Config config) { config.addKey("filenet.contentEngineUrl", null); config.addKey("filenet.username", null); config.addKey("filenet.password", null); config.addKey("filenet.objectStore", null); <START> config.addKey("filenet.objectFactory", null); <END> config.addKey("filenet.displayUrl", null); config.addKey("filenet.isPublic", "false"); config.addKey("filenet.pushAcls", "true"); config.addKey("filenet.additionalWhereClause", ""); config.addKey("filenet.deleteAdditionalWhereClause", ""); config.addKey("filenet.excludedMetadata", ""); config.addKey("filenet.includedMetadata", ""); config.addKey("adaptor.namespace", Principal.DEFAULT_NAMESPACE); }</code><technical_language>ObjectFactory class name is internal, default FileNetObjectFactory</technical_language>

Target:
public void initConfig(Config config) { config.addKey("filenet.contentEngineUrl", null); config.addKey("filenet.username", null); config.addKey("filenet.password", null); config.addKey("filenet.objectStore", null); config.addKey("filenet.objectFactory", FileNetObjectFactory.class.getName()); config.addKey("filenet.displayUrl", null); config.addKey("filenet.additionalWhereClause", ""); config.addKey("filenet.deleteAdditionalWhereClause", ""); config.addKey("filenet.excludedMetadata", ""); config.addKey("filenet.includedMetadata", ""); config.addKey("adaptor.namespace", DEFAULT_NAMESPACE); }
Source:
<code>public static SegmentLineage fromZNRecord(ZNRecord record) { String tableNameWithType = record.getId(); Map<String, LineageEntry> lineageEntries = new HashMap<>(); Map<String, List<String>> listFields = record.getListFields(); for (Map.Entry<String, List<String>> listField : listFields.entrySet()) { String lineageId = listField.getKey(); List<String> value = listField.getValue(); Preconditions.checkState(value.size() == 4); <START> String segmentsFromStr = value.get(0); List<String> segmentsFrom = (segmentsFromStr == null || segmentsFromStr.length() == 0) ? new ArrayList<>() : Arrays.asList(value.get(0).split(COMMA_SEPARATOR)); List<String> segmentsTo = Arrays.asList(value.get(1).split(COMMA_SEPARATOR)); <END> LineageEntryState state = LineageEntryState.valueOf(value.get(2)); long timestamp = Long.parseLong(value.get(3)); lineageEntries.put(lineageId, new LineageEntry(segmentsFrom, segmentsTo, state, timestamp)); } return new SegmentLineage(tableNameWithType, lineageEntries); }</code><technical_language>segmentsFromStr null? avoid regex split suggestion List<String> segmentsFrom = Arrays.asList(StringUtils.split(value.get(0), ',')); List<String> segmentsTo = Arrays.asList(StringUtils.split(value.get(1), ','));</technical_language>

Target:
public static SegmentLineage fromZNRecord(ZNRecord record) { String tableNameWithType = record.getId(); Map<String, LineageEntry> lineageEntries = new HashMap<>(); Map<String, List<String>> listFields = record.getListFields(); for (Map.Entry<String, List<String>> listField : listFields.entrySet()) { String lineageId = listField.getKey(); List<String> value = listField.getValue(); Preconditions.checkState(value.size() == 4); List<String> segmentsFrom = Arrays.asList(StringUtils.split(value.get(0), COMMA_SEPARATOR)); List<String> segmentsTo = Arrays.asList(StringUtils.split(value.get(1), COMMA_SEPARATOR)); LineageEntryState state = LineageEntryState.valueOf(value.get(2)); long timestamp = Long.parseLong(value.get(3)); lineageEntries.put(lineageId, new LineageEntry(segmentsFrom, segmentsTo, state, timestamp)); } return new SegmentLineage(tableNameWithType, lineageEntries); }
Source:
<code>public void setConfigurationManager(String name, Map<String, String> properties) { SessionPropertyConfigurationManagerFactory factory = sessionPropertyConfigurationManagerFactories.get(name); <START> checkState(factory != null, format("Session property configuration manager '%s' is not registered", name)); <END> SessionPropertyConfigurationManager manager = factory.create(properties, configurationManagerContext); checkState(sessionPropertyConfigurationManager.compareAndSet(null, manager), "sessionPropertyConfigurationManager is already set"); }</code><technical_language>pretty sure, checkState format built in, need explicit format call</technical_language>

Target:
public void setConfigurationManager(String name, Map<String, String> properties) { SessionPropertyConfigurationManagerFactory factory = sessionPropertyConfigurationManagerFactories.get(name); checkState(factory != null, "Session property configuration manager '%s' is not registered", name); SessionPropertyConfigurationManager manager = factory.create(properties, configurationManagerContext); checkState(sessionPropertyConfigurationManager.compareAndSet(null, manager), "sessionPropertyConfigurationManager is already set"); }
Source:
<code>protected Set<X509Certificate> loadUpstreamCACertificates(String path) { Set<X509Certificate> result = new HashSet<>(); File dir = new File(path); if (!dir.exists()) { return result; } <START> for (File file : dir.listFiles()) { <END> try ( InputStream inStream = new FileInputStream(file.getAbsolutePath()); ) { X509Certificate cert = (X509Certificate) this.certFactory .generateCertificate(inStream); inStream.close(); result.add(cert); } catch (Exception e) { throw new RuntimeException(e); } } return result; }</code><technical_language>dir.listFiles() return null if path is a directory... handle existence check I suppose</technical_language>

Target:
protected Set<X509Certificate> loadUpstreamCACertificates(String path) { Set<X509Certificate> result = new HashSet<>(); File dir = new File(path); if (!dir.exists()) { return result; } File[] files = dir.listFiles(); if (files == null) { throw new RuntimeException("Could not read files in " + path); } for (File file : files) { try ( InputStream inStream = new FileInputStream(file.getAbsolutePath()); ) { X509Certificate cert = (X509Certificate) this.certFactory.generateCertificate(inStream); result.add(cert); } catch (Exception e) { throw new RuntimeException(e); } } return result; }