auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException { Matcher statementMatcher = SQLParser.matchDropAggregateFunction(ddlStatement.statement); if (! statementMatcher.matches()) { return false; } String functionName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement).toLowerCase(); boolean ifExists = statementMatcher.group(2) != null; if ( ! removeUDAFInSchema(functionName)) { <START> if ( ! ifExists ) { <END> throw m_compiler.new VoltCompilerException(String.format( "Function name \"%s\" in DROP AGGREGATE FUNCTION statement does not exist.", functionName)); } } FunctionForVoltDB.deregisterUserDefinedFunction(functionName); return true; }</code><technical_language>combine checks if (!(removeUDAFInSchema(function) || ifExists)) {</technical_language>

Target:
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException { Matcher statementMatcher = SQLParser.matchDropAggregateFunction(ddlStatement.statement); if (!statementMatcher.matches()) { return false; } String functionName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement).toLowerCase(); boolean ifExists = statementMatcher.group(2) != null; if (!removeUDAFInSchema(functionName) && !ifExists) { throw m_compiler.new VoltCompilerException(String.format( "Function name \"%s\" in DROP AGGREGATE FUNCTION statement does not exist.", functionName)); } FunctionForVoltDB.deregisterUserDefinedFunction(functionName); return true; }
Source:
<code><START> protected boolean isExpired(IndexValue value){ <END> if (value.getTimeToLiveInMs() != Utils.Infinite_Time && time.milliseconds() > value.getTimeToLiveInMs()) { return true; } return false; }</code><technical_language>move this method Utils</technical_language>

Target:
private boolean isExpired(IndexValue value){ return value.getTimeToLiveInMs() != Utils.Infinite_Time && time.milliseconds() > value.getTimeToLiveInMs(); }
Source:
<code>protected void initialize() { if (fields != null) { Iterator<FieldEditor> e = fields.iterator(); IPreferenceStore pagePreferenceStore = getPreferenceStore(); while (e.hasNext()) { FieldEditor pe = e.next(); pe.setPage(this); pe.setPropertyChangeListener(this); if (pe.getPreferenceStore() == null) { <START> pe.setPreferenceStore(pagePreferenceStore); <END> } pe.load(); } } }</code><technical_language>I intention is clearer avoid pagePreferenceStore variable write here: pe.setPreferenceStore(this.getPreferenceStore());</technical_language>

Target:
protected void initialize() { if (fields != null) { Iterator<FieldEditor> e = fields.iterator(); while (e.hasNext()) { FieldEditor pe = e.next(); pe.setPage(this); pe.setPropertyChangeListener(this); if (pe.getPreferenceStore() == null) { pe.setPreferenceStore(getPreferenceStore()); } pe.load(); } } }
Source:
<code>private static final List<NamedElement> getNamedElements(final List<String> nameFragments, final Namespace scope, final EClass clazz) { final List<NamedElement> resolvedNamedElements = new ArrayList<NamedElement>(); Iterator<NamedElement> members = <START> scope.getMembers().iterator(); <END> while(members.hasNext()) { final NamedElement member = members.next(); final List<String> memberNames = scope.getNamesOfMember(member); final String firstNameFragment = nameFragments.get(0); for (final String memberName : memberNames) { if (memberName.equals(firstNameFragment)) { if (nameFragments.size() == 1) { if (clazz != null) { if (clazz.isSuperTypeOf(member.eClass())) { resolvedNamedElements.add(member); } } else { resolvedNamedElements.add(member); } } else { if (member instanceof Namespace) { final List<String> remainingNameFragments = nameFragments.subList(1, nameFragments.size()); resolvedNamedElements.addAll(NameResolutionUtils.getNamedElements(remainingNameFragments, (Namespace) member, clazz)); } } } } } return resolvedNamedElements; }</code><technical_language>this change</technical_language>

Target:
private static final List<NamedElement> getNamedElements(final List<String> nameFragments, final Namespace scope, final EClass clazz) { final List<NamedElement> resolvedNamedElements = new ArrayList<NamedElement>(); for (final NamedElement member : scope.getMembers()) { final List<String> memberNames = scope.getNamesOfMember(member); final String firstNameFragment = nameFragments.get(0); for (final String memberName : memberNames) { if (memberName.equals(firstNameFragment)) { if (nameFragments.size() == 1) { if (clazz != null) { if (clazz.isSuperTypeOf(member.eClass())) { resolvedNamedElements.add(member); } } else { resolvedNamedElements.add(member); } } else { if (member instanceof Namespace) { final List<String> remainingNameFragments = nameFragments.subList(1, nameFragments.size()); resolvedNamedElements.addAll(NameResolutionUtils.getNamedElements(remainingNameFragments, (Namespace) member, clazz)); } } } } } return resolvedNamedElements; }
Source:
<code>@Override public Pair<RelTraitSet, List<RelTraitSet>> deriveTraits( final RelTraitSet childTraits, final int childId) { <START> if (childId > 0) { <END> return null; } RelCollation collation = childTraits.getCollation(); if (collation == null || collation == RelCollations.EMPTY || joinType == JoinRelType.FULL || joinType == JoinRelType.RIGHT) { return null; } final int colCount = collation.getFieldCollations().size(); final int keyCount = joinInfo.leftKeys.size(); if (colCount < keyCount || keyCount == 0) { return null; } if (colCount > keyCount) { collation = RelCollations.of(collation.getFieldCollations().subList(0, keyCount)); } ImmutableBitSet childCollationKeys = ImmutableBitSet.of( RelCollations.ordinals(collation)); ImmutableBitSet keySet = ImmutableBitSet.of(joinInfo.leftKeys); if (!childCollationKeys.equals(keySet)) { return null; } return Pair.of( getTraitSet().replace(collation), ImmutableList.of(childTraits, right.getTraitSet())); }</code><technical_language>assert childId == 0, is illegal greater 0</technical_language>

Target:
@Override public Pair<RelTraitSet, List<RelTraitSet>> deriveTraits( final RelTraitSet childTraits, final int childId) { assert childId == 0; RelCollation collation = childTraits.getCollation(); if (collation == null || collation == RelCollations.EMPTY) { return null; } RelTraitSet derivedTraits = getTraitSet().replace(collation); return Pair.of( derivedTraits, ImmutableList.of(derivedTraits, right.getTraitSet())); }
Source:
<code>protected void recoverCssStyle(StyleInfo si) { if (si == null) { return; } try { Styles.handler("css"); } catch (Exception e) { return; } long favorSLDIfNewerByMS = 600000; <START> if (!"css".equalsIgnoreCase(si.getFormat())) { <END> String filename = si.getFilename(); String filenameCss = filename.substring(0, filename.lastIndexOf('.')) + ".css"; GeoServerDataDirectory g = new GeoServerDataDirectory(getCatalog().getResourceLoader()); Resource cssResource = g.get(si, filenameCss); if (!cssResource.getType().equals(Resource.Type.UNDEFINED)) { Resource sldResource = g.get(si, filename); long sldNewerByMs = sldResource.lastmodified() - cssResource.lastmodified(); if (sldNewerByMs > favorSLDIfNewerByMS) { LOGGER.log(Level.WARNING, "A CSS version of this style has been recovered (" + filenameCss + "), but the SLD is more recent by " + sldNewerByMs + " ms. The style will be left as an SLD."); } else { LOGGER.log(Level.WARNING, "A CSS version of this style has been recovered (" + filenameCss + "). The style will be converted to CSS."); si.setFilename(filenameCss); si.setFormat("css"); getCatalog().save(si); } } } }</code><technical_language>modify this check styles format is sld get updated? If a YSLD style want convert CSS</technical_language>

Target:
protected void recoverCssStyle(StyleInfo si) { if (si == null) { return; } try { Styles.handler("css"); } catch (Exception e) { return; } long favorSLDIfNewerByMS = 600000; if ("sld".equalsIgnoreCase(si.getFormat())) { String filename = si.getFilename(); String filenameCss = filename.substring(0, filename.lastIndexOf('.')) + ".css"; GeoServerDataDirectory dataDir = new GeoServerDataDirectory( getCatalog().getResourceLoader()); Resource cssResource = dataDir.get(si, filenameCss); if (!cssResource.getType().equals(Resource.Type.UNDEFINED)) { Resource sldResource = dataDir.get(si, filename); long sldNewerByMs = sldResource.lastmodified() - cssResource.lastmodified(); if (sldNewerByMs > favorSLDIfNewerByMS) { LOGGER.log(Level.WARNING, "A CSS version of " + si.getName() + " has been recovered (" + filenameCss + "), but the SLD is more recent by " + sldNewerByMs + " ms. The style will be left as an SLD."); } else { LOGGER.log(Level.WARNING, "A CSS version of " + si.getName() + " has been recovered (" + filenameCss + "). The style will be converted to CSS."); si.setFilename(filenameCss); si.setFormat("css"); getCatalog().save(si); } } } }
Source:
<code>public DefaultExecutionSlotAllocator( final SlotProviderStrategy slotProviderStrategy, <START> final PreferredLocationsRetriever preferredLocationsRetriever) { <END> super(preferredLocationsRetriever); this.slotProviderStrategy = checkNotNull(slotProviderStrategy); }</code><technical_language>nit: constructor package-private</technical_language>

Target:
DefaultExecutionSlotAllocator( final SlotProviderStrategy slotProviderStrategy, final PreferredLocationsRetriever preferredLocationsRetriever) { super(preferredLocationsRetriever); this.slotProviderStrategy = checkNotNull(slotProviderStrategy); }
Source:
<code>private JsonObject toJSONObject(ServerConsumer consumer) throws Exception { JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", consumer.getID()) .add("connectionID", consumer.getConnectionID().toString()) <START> .add("sessionID", consumer.getSessionID()) <END> .add("queueName", consumer.getQueue().getName().toString()) .add("browseOnly", consumer.isBrowseOnly()) .add("creationTime", consumer.getCreationTime()) .add("deliveringCount", consumer.getDeliveringMessages().size()); if (consumer.getFilter() != null) { obj.add("filter", consumer.getFilter().getFilterString().toString()); } String coreAddress = consumer.getQueue().getAddress().toString(); String[] result = new String[2]; if (coreAddress.startsWith("jms.queue.")) { result[0] = coreAddress.substring("jms.queue.".length()); result[1] = "queue"; } else if (coreAddress.startsWith("jms.tempqueue.")) { result[0] = coreAddress.substring("jms.tempqueue.".length()); result[1] = "tempqueue"; } else if (coreAddress.startsWith("jms.topic.")) { result[0] = coreAddress.substring("jms.topic.".length()); result[1] = "topic"; } else if (coreAddress.startsWith("jms.temptopic.")) { result[0] = coreAddress.substring("jms.temptopic.".length()); result[1] = "temptopic"; } else { logger.debug("Unable to determine the JMS destination of " + coreAddress); result[0] = ""; result[1] = ""; } obj.add("destinationName", result[0]) .add("destinationType", result[1]) .add("durable", consumer.getQueue().isDurable()); return obj.build(); }</code><technical_language>Please avoid reformatting this, code change</technical_language>

Target:
private JsonObject toJSONObject(ServerConsumer consumer) throws Exception { JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", consumer.getID()).add("connectionID", consumer.getConnectionID().toString()).add("sessionID", consumer.getSessionID()).add("queueName", consumer.getQueue().getName().toString()).add("browseOnly", consumer.isBrowseOnly()).add("creationTime", consumer.getCreationTime()).add("deliveringCount", consumer.getDeliveringMessages().size()); if (consumer.getFilter() != null) { obj.add("filter", consumer.getFilter().getFilterString().toString()); } obj.add("destinationName", consumer.getQueue().getAddress().toString()); if (consumer.getQueueType().getType() == 0) { obj.add("destinationType", "topic"); } else if (consumer.getQueueType().getType() == 1) { obj.add("destinationType", "queue"); } else { obj.add("destinationType", ""); } obj.add("durable", consumer.getQueue().isDurable()); return obj.build(); }
Source:
<code>private boolean showSubmergeDialog( final String message, final AtomicReference<Territory> retreatTo) { final String ok = "Submerge"; final String cancel = "Remain"; final String wait = "Ask Me Later"; final String[] options = {ok, cancel, wait}; final int choice = JOptionPane.showOptionDialog( BattleDisplay.this, message, "Submerge Subs?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, cancel); if (choice == JOptionPane.CLOSED_OPTION) { return false; } <START> if (choice == JOptionPane.CANCEL_OPTION) { <END> return false; } if (choice == JOptionPane.NO_OPTION) { return true; } retreatTo.set(battleLocation); return true; }</code><technical_language>merged if cases</technical_language>

Target:
private boolean showSubmergeDialog( final String message, final AtomicReference<Territory> retreatTo) { final String ok = "Submerge"; final String cancel = "Remain"; final String wait = "Ask Me Later"; final String[] options = {ok, cancel, wait}; final int choice = JOptionPane.showOptionDialog( BattleDisplay.this, message, "Submerge Subs?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, cancel); if (choice == JOptionPane.CLOSED_OPTION || choice == JOptionPane.CANCEL_OPTION) { return false; } if (choice == JOptionPane.NO_OPTION) { return true; } retreatTo.set(battleLocation); return true; }
Source:
<code>public ResponseEntity<?> getInvoiceInfo( @ApiParam(required = true, value = "metasfreshId of the invoice") @PathVariable("invoiceId") final int invoiceRecordId) { final InvoiceId invoiceId = InvoiceId.ofRepoIdOrNull(invoiceRecordId); if (invoiceId == null) { return ResponseEntity.notFound().build(); } <START> final JSONInvoiceInfoResponse invoiceInfo = invoiceService.getInvoiceInfo(invoiceId, Env.getAD_Language()); <END> return ResponseEntity.ok(invoiceInfo); }</code><technical_language>try/catch, return ResponseEntity.badRequestSomething(JsonError.of...)</technical_language>

Target:
public ResponseEntity<?> getInvoiceInfo( @ApiParam(required = true, value = "metasfreshId of the invoice") @PathVariable("invoiceId") final int invoiceRecordId) { final InvoiceId invoiceId = InvoiceId.ofRepoIdOrNull(invoiceRecordId); if (invoiceId == null) { return ResponseEntity.notFound().build(); } final String ad_language = Env.getAD_Language(); try { final JSONInvoiceInfoResponse invoiceInfo = invoiceService.getInvoiceInfo(invoiceId, ad_language); return ResponseEntity.ok(invoiceInfo); } catch (final Exception ex) { final JsonError error = JsonError.ofSingleItem(JsonErrors.ofThrowable(ex, ad_language)); return ResponseEntity.unprocessableEntity().body(error); } }
Source:
<code>public List<T> subList(final int fridx, final int toidx) { try { return this.origin.subList(fridx, toidx); } catch (final IndexOutOfBoundsException ex) { <START> throw new IllegalArgumentException(this.message, ex); <END> } }</code><technical_language>@Happy-Neko here, IndexOutOfBoundsException custom message</technical_language>

Target:
public List<T> subList(final int fridx, final int toidx) { try { return this.origin.subList(fridx, toidx); } catch (final IndexOutOfBoundsException ex) { throw this.wrapException(ex); } }
Source:
<code>public String getActionInfo() { String style = ""; if (message.toLowerCase(Locale.ENGLISH).contains(Const.ACTION_RESULT_FAILURE.toLowerCase(Locale.ENGLISH)) || message.toLowerCase(Locale.ENGLISH).contains( <START> Const.ACTION_RESULT_SYSTEM_ERROR_REPORT.toLowerCase(Locale.ENGLISH))) { <END> style = "text-danger"; } else { style = "text-success bold"; } return "<a href=\"" + getUrlToShow() + "\" class=\"" + style + "\" target=\"_blank\">" + servletName + "</a>"; }</code><technical_language>message.toLowerCase(Locale.ENGLISH) .contains(Const.ACTION_RESULT_SYSTEM_ERROR_REPORT.toLowerCase(Locale.ENGLISH))) {</technical_language>

Target:
public String getActionInfo() { String style = ""; if (message.toLowerCase().contains(Const.ACTION_RESULT_FAILURE.toLowerCase()) || message.toLowerCase().contains(Const.ACTION_RESULT_SYSTEM_ERROR_REPORT.toLowerCase())) { style = "text-danger"; } else { style = "text-success bold"; } return "<a href=\"" + getUrlToShow() + "\" class=\"" + style + "\" target=\"_blank\">" + servletName + "</a>"; }
Source:
<code>public QueryManager() { this.queries = Multimaps.synchronizedSetMultimap( HashMultimap.<String, ListenableFuture>create() ); <START> this.queryDatasources = Maps.newHashMap(); <END> }</code><technical_language>this needs a concurrent hashmap</technical_language>

Target:
public QueryManager() { this.queries = Multimaps.synchronizedSetMultimap( HashMultimap.<String, ListenableFuture>create() ); this.queryDatasources = Multimaps.synchronizedSetMultimap( HashMultimap.<String, String>create() ); }
Source:
<code>public void addServiceTypes(Editable mServiceNameText, Editable mServiceDiscriptionText, Editable mServiceDurationText) { Services services=new Services(); services.setName(String.valueOf(mServiceNameText)); services.setDuration(Integer.valueOf(String.valueOf(mServiceDurationText))); services.setDescription(String.valueOf(mServiceDiscriptionText)); RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.newServiceTypes(services); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { <START> if (response.isSuccessful()) { <END> mFormAddEditServiceView.endActivity(); } } @Override public void onFailure(Call<Services> call, Throwable t) { Log.e("jaasvk", String.valueOf(t)); } }); }</code><technical_language>this code slightly more readable, try mServiceNameText.toString() String.valueOf(mServiceNameText). This especially next line seperate valueOf statements</technical_language>

Target:
public void addServiceTypes(Editable mServiceNameText, Editable mServiceDiscriptionText, Editable mServiceDurationText) { Services services=new Services(); services.setName(String.valueOf(mServiceNameText)); services.setDuration(Integer.valueOf(mServiceDurationText.toString())); services.setDescription(String.valueOf(mServiceDiscriptionText)); RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.newServiceTypes(services); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { if (response.isSuccessful()) { mFormAddEditServiceView.endActivity(); } } @Override public void onFailure(Call<Services> call, Throwable t) { } }); }
Source:
<code>public void update() throws BankChoiceException, BankException, LoginException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } urlopen = login(); try { Account account = new Account(res.getText(R.string.balance).toString(), Helpers.parseBalance(userInfo.getString("balance")), "1"); accounts.add(account); <START> balance = balance.add(account.getBalance()); <END> } catch (JSONException e) { e.printStackTrace(); throw new BankException(res.getText(R.string.no_accounts_found).toString()); } super.updateComplete(); }</code><technical_language>need set balance, automatically calculated. overridden if STATIC_BALANCE is true</technical_language>

Target:
public void update() throws BankChoiceException, BankException, LoginException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } urlopen = login(); try { Account account = new Account(res.getText(R.string.balance).toString(), Helpers.parseBalance(userInfo.getString("balance")), "1"); accounts.add(account); } catch (JSONException e) { e.printStackTrace(); throw new BankException(res.getText(R.string.no_accounts_found).toString()); } super.updateComplete(); }
Source:
<code>protected void runImpl() throws IOException, Failure { final Set<AccountGroup.Id> receiveGroup = getServerCommandConfig().getReceiveGroup(); if (receiveGroup != null && !receiveGroup.isEmpty()) { if (!CollectionsUtil.isAnyIncludedIn(currentUser.getEffectiveGroups(), receiveGroup)) { <START> throw new Failure(1, "User: " + currentUser.getUserName() <END> + " not allowed to execute this command on this server"); } } final ReceiveCommits receive = factory.create(projectControl, repo); ReceiveCommits.Capable r = receive.canUpload(); if (r != ReceiveCommits.Capable.OK) { throw new UnloggedFailure(1, "\nfatal: " + r.getMessage()); } verifyProjectVisible("reviewer", reviewerId); verifyProjectVisible("CC", ccId); receive.addReviewers(reviewerId); receive.addExtraCC(ccId); final ReceivePack rp = receive.getReceivePack(); rp.setRefLogIdent(currentUser.newRefLogIdent()); rp.setTimeout(config.getTimeout()); try { rp.receive(in, out, err); } catch (InterruptedIOException err) { throw new Failure(128, "fatal: client IO read/write timeout", err); } }</code><technical_language>I bother including username in error. automatically part of server error log, end-user logging anyway. instead use: throw new Failure(1, "fatal: receive-pack permitted this server");</technical_language>

Target:
protected void runImpl() throws IOException, Failure { if (!projectControl.canPerformPackAction(receiveGroup)) { throw new Failure(1, "fatal: receive-pack not permitted on this server"); } final ReceiveCommits receive = factory.create(projectControl, repo); ReceiveCommits.Capable r = receive.canUpload(); if (r != ReceiveCommits.Capable.OK) { throw new UnloggedFailure(1, "\nfatal: " + r.getMessage()); } verifyProjectVisible("reviewer", reviewerId); verifyProjectVisible("CC", ccId); receive.addReviewers(reviewerId); receive.addExtraCC(ccId); final ReceivePack rp = receive.getReceivePack(); rp.setRefLogIdent(currentUser.newRefLogIdent()); rp.setTimeout(config.getTimeout()); try { rp.receive(in, out, err); } catch (InterruptedIOException err) { throw new Failure(128, "fatal: client IO read/write timeout", err); } }
Source:
<code>public VcsChangeMarkerRender getVcsChangeMarkersRender() { OrionTextViewOverlay textView = editorWidget.getTextView(); if (vcsChangeMarkerRender == null) { stream(textView.getRulers()) <START> .filter(ruler -> "ruler folding".equals(ruler.getStyle().getStyleClass())) <END> .findAny() .ifPresent( ruler -> vcsChangeMarkerRender = vcsChangeMarkerRenderFactory.create( new OrionVcsChangeMarkersRuler(ruler, editorWidget.getEditor()))); } return vcsChangeMarkerRender; }</code><technical_language>Do reuse folding ruler? If check case a ruler disabled</technical_language>

Target:
public VcsChangeMarkerRender getVcsChangeMarkersRender() { return this.vcsChangeMarkerRender; }
Source:
<code>private void run(final int addEvalNum, final int addThreadNum) { final String[] args = { "-split", "1", "-local", "true", "-input", ClassLoader.getSystemResource("data").getPath() + "/sample", "-output", ClassLoader.getSystemResource("data").getPath() + "/result", "-maxNumEvalLocal", Integer.toString(addEvalNum + 2), "-timeout", "120000" }; LauncherStatus status; try { status = DolphinLauncher.run( Configurations.merge( DolphinConfiguration.getConfiguration(args), Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(JobIdentifier.class, "EM Add Integration Test") .bindImplementation(UserJobInfo.class, SimpleJobInfo.class) .build()), Tang.Factory.getTang().newConfigurationBuilder() .bindSetEntry(DriverStartHandler.class, AddTestHandlers.AddTestStartHandler.class) .bindSetEntry(EvaluatorAllocatedHandlers.class, AddTestHandlers.AddTestEvaluatorAllocatedHandler.class) .bindSetEntry(Clock.StopHandler.class, AddTestHandlers.AddTestDriverStopHandler.class) .bindNamedParameter(AddEvalNumber.class, Integer.toString(addEvalNum)) .bindNamedParameter(AddThreadNumber.class, Integer.toString(addThreadNum)) .build()); <START> } catch (IOException e) { <END> status = LauncherStatus.failed(e); } assertEquals(LauncherStatus.COMPLETED, status); }</code><technical_language>IOException e final</technical_language>

Target:
private void run(final int addEvalNum, final int addThreadNum) { final String[] args = { "-split", "1", "-local", "true", "-input", ClassLoader.getSystemResource("data").getPath() + "/sample", "-output", ClassLoader.getSystemResource("data").getPath() + "/result", "-maxNumEvalLocal", Integer.toString(addEvalNum + 2), "-timeout", "120000" }; LauncherStatus status; try { status = DolphinLauncher.run( Configurations.merge( DolphinConfiguration.getConfiguration(args), Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(JobIdentifier.class, "EM Add Integration Test") .bindImplementation(UserJobInfo.class, SimpleJobInfo.class) .build()), Tang.Factory.getTang().newConfigurationBuilder() .bindSetEntry(DriverStartHandler.class, AddTestHandlers.AddTestStartHandler.class) .bindSetEntry(EvaluatorAllocatedHandlers.class, AddTestHandlers.AddTestEvaluatorAllocatedHandler.class) .bindSetEntry(Clock.StopHandler.class, AddTestHandlers.AddTestStopHandler.class) .bindNamedParameter(AddEvalNumber.class, Integer.toString(addEvalNum)) .bindNamedParameter(AddThreadNumber.class, Integer.toString(addThreadNum)) .build()); } catch (final IOException e) { status = LauncherStatus.failed(e); } assertEquals(LauncherStatus.COMPLETED, status); }
Source:
<code><START> public boolean updateClientCustomField(String clientId, String customFieldId, String fieldValue) <END> throws MambuApiException { ParamsMap params = ServiceHelper.makeParamsForUpdateCustomField(clientId, customFieldId, fieldValue); return serviceExecutor.execute(updateClientCustomField, clientId, customFieldId, params); }</code><technical_language>next refactoring inheritance composition pattern extract updateCustomField deleteCustomField methods e.g. abstract class implemented in service</technical_language>

Target:
public boolean updateClientCustomField(String clientId, String customFieldId, String fieldValue) throws MambuApiException { ParamsMap params = ServiceHelper.makeParamsForUpdateCustomField(customFieldId, fieldValue); return serviceExecutor.execute(updateClientCustomField, clientId, customFieldId, params); }
Source:
<code>public TmfXmlPatternSegmentField(Element element) { fName = element.getAttribute(TmfXmlStrings.NAME); fType = element.getAttribute(TmfXmlStrings.TYPE); String constantValue = element.getAttribute(TmfXmlStrings.VALUE); if (constantValue.isEmpty() && !fType.equals(TmfXmlStrings.TYPE_NULL)) { fStateValue = null; Element elementFieldStateValue = (Element) element.getElementsByTagName(TmfXmlStrings.STATE_VALUE).item(0); if (elementFieldStateValue == null) { throw new IllegalArgumentException(); } fXmlStateValue = fModelFactory.createStateValue(elementFieldStateValue, fContainer, new ArrayList<>()); } else { switch (fType) { case TmfXmlStrings.TYPE_INT: fStateValue = TmfStateValue.newValueInt(Integer.parseInt(constantValue)); break; case TmfXmlStrings.TYPE_LONG: fStateValue = TmfStateValue.newValueLong(Long.parseLong(constantValue)); break; case TmfXmlStrings.TYPE_STRING: fStateValue = TmfStateValue.newValueString(constantValue); break; case TmfXmlStrings.TYPE_NULL: fStateValue = TmfStateValue.nullValue(); break; default: <START> throw new IllegalArgumentException("pattern segment field : invalid type of field"); END> } fXmlStateValue = null; } }</code><technical_language>mention field type</technical_language>

Target:
public TmfXmlPatternSegmentField(Element element) { fName = element.getAttribute(TmfXmlStrings.NAME); fType = element.getAttribute(TmfXmlStrings.TYPE); String constantValue = element.getAttribute(TmfXmlStrings.VALUE); if (constantValue.isEmpty() && !fType.equals(TmfXmlStrings.TYPE_NULL)) { fStateValue = null; Element elementFieldStateValue = (Element) element.getElementsByTagName(TmfXmlStrings.STATE_VALUE).item(0); if (elementFieldStateValue == null) { throw new IllegalArgumentException("The value of the field " + fName + " is missing"); } fXmlStateValue = fModelFactory.createStateValue(elementFieldStateValue, fContainer, new ArrayList<>()); } else { fStateValue = getStateValueFromConstant(constantValue, fType); fXmlStateValue = null; } }
Source:
<code>public URL getURL(DocumentReference reference) throws XWikiRestException { try { Locale locale = reference.getLocale(); if (locale != null && !locale.toString().isEmpty()) { return Utils.createURI(getBaseURI(), PageTranslationResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName(), reference.getLocale()).toURL(); <START> } <END> return Utils.createURI(getBaseURI(), PageResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName()).toURL(); } catch (MalformedURLException e) { throw new XWikiRestException( String.format("Failed to generate a REST URL for the document [%s].", reference), e); } }</code><technical_language>Small detail: introduce some variable methods a single "return" statement? simpler read error prone. Thx</technical_language>

Target:
public URL getURL(DocumentReference reference) throws XWikiRestException { try { Locale locale = reference.getLocale(); URL url; if (locale != null && !locale.toString().isEmpty()) { url = Utils.createURI(getBaseURI(), PageTranslationResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName(), reference.getLocale()).toURL(); } else { url = Utils.createURI(getBaseURI(), PageResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName()).toURL(); } return url; } catch (MalformedURLException e) { throw new XWikiRestException( String.format("Failed to generate a REST URL for the document [%s].", reference), e); } }
Source:
<code>private int createInternal(String path, long mode, FuseFileInfo fi) { final AlluxioURI uri = mPathResolverCache.getUnchecked(path); if (uri.getName().length() > MAX_NAME_LENGTH) { LOG.error("Failed to create {}: file name longer than characters", path, MAX_NAME_LENGTH); return -ErrorCodes.ENAMETOOLONG(); } try { FileOutStream os = mFileSystem.createFile(uri, CreateFilePOptions.newBuilder() .setMode(new Mode((short) mode).toProto()) .build()); long fid = mNextOpenFileId.getAndIncrement(); mCreateFileEntries.put(fid, os); fi.fh.set(fid); setUserGroupIfNeeded(uri); } catch (Throwable e) { <START> LOG.error("Failed to getattr {}: ", path, e); <END> return -ErrorCodes.EIO(); } return 0; }</code><technical_language>is this message correct</technical_language>

Target:
private int createInternal(String path, long mode, FuseFileInfo fi) { final AlluxioURI uri = mPathResolverCache.getUnchecked(path); if (uri.getName().length() > MAX_NAME_LENGTH) { LOG.error("Failed to create {}: file name longer than characters", path, MAX_NAME_LENGTH); return -ErrorCodes.ENAMETOOLONG(); } try { FileOutStream os = mFileSystem.createFile(uri, CreateFilePOptions.newBuilder() .setMode(new Mode((short) mode).toProto()) .build()); long fid = mNextOpenFileId.getAndIncrement(); mCreateFileEntries.put(fid, os); fi.fh.set(fid); setUserGroupIfNeeded(uri); } catch (Throwable e) { LOG.error("Failed to create {}: ", path, e); return -ErrorCodes.EIO(); } return 0; }
Source:
<code>private void _setLastLoginAddress(String address) { lastLoginAddress = address; <START> if (ess.getSettings().storeIPAddressPlainText()) { config.setProperty("ipAddress", address); } else { config.setProperty("ipAddress", "hidden"); } <END> }</code><technical_language>a fan of this method setting IP "hidden" set empty string null</technical_language>

Target:
private void _setLastLoginAddress(String address) { lastLoginAddress = address; if (ess.getSettings().storeUserIPAddress()) { config.setProperty("ipAddress", address); } else { config.setProperty("ipAddress", "hidden"); } }
Source:
<code>private ArrayList<Map<String, Object>> resultSetToArrayList(ResultSet rs) throws SQLException { ResultSetMetaData md = rs.getMetaData(); int columns = md.getColumnCount(); ArrayList<Map<String, Object>> arraylist = new ArrayList<>(); while (rs.next()) { Map<String, Object> row = new LinkedHashMap<>(columns); for (int i = 1; i <= columns; ++i) { if (rs.getObject(i) == null) { row.put(md.getColumnName(i), ""); } else { if (md.getColumnTypeName(i).compareToIgnoreCase("blob") == 0) { <START> row.put(md.getColumnName(i), "BLOB Data not shown..."); <END> } else { row.put(md.getColumnName(i), rs.getObject(i)); } } } arraylist.add(row); } return arraylist; }</code><technical_language>if message BLOB data implemented NbBundle.Messages instead of hard-coded. This easier/less expensive for localization. Also, I message "BLOB data shown", lower-casing "data" omitting ellipsis is generally user invoke a dialog. I personally find of ellipsis slightly unusual here</technical_language>

Target:
private ArrayList<Map<String, Object>> resultSetToArrayList(ResultSet rs) throws SQLException { ResultSetMetaData metaData = rs.getMetaData(); int columns = metaData.getColumnCount(); ArrayList<Map<String, Object>> rowlist = new ArrayList<>(); while (rs.next()) { Map<String, Object> row = new LinkedHashMap<>(columns); for (int i = 1; i <= columns; ++i) { if (rs.getObject(i) == null) { row.put(metaData.getColumnName(i), ""); } else { if (metaData.getColumnTypeName(i).compareToIgnoreCase("blob") == 0) { row.put(metaData.getColumnName(i), Bundle.SQLiteViewer_BlobNotShown_message()); } else { row.put(metaData.getColumnName(i), rs.getObject(i)); } } } rowlist.add(row); } return rowlist; }
Source:
<code>public void testExecuteQueryWithNotExistingIscsiBond() { IscsiBond iscsiBond = new IscsiBond(); <START> iscsiBond.setId(Guid.newGuid()); <END> when(getQueryParameters().getId()).thenReturn(iscsiBondId); getQuery().executeQueryCommand(); IscsiBond result = getQuery().getQueryReturnValue().getReturnValue(); assertNull(result); }</code><technical_language>I remove this removed line 87</technical_language>

Target:
public void testExecuteQueryWithNotExistingIscsiBond() { when(getQueryParameters().getId()).thenReturn(iscsiBondId); getQuery().executeQueryCommand(); IscsiBond result = getQuery().getQueryReturnValue().getReturnValue(); assertNull(result); }
Source:
<code>public List<Migration> getMigrations() { <START> var descriptors = getDescriptors(XP_CONFIG); return descriptors.stream().map(d -> getMigration(d.getId())).collect(Collectors.toList()); <END> }</code><technical_language>suggestion return getDescriptors(XP_CONFIG).stream().map(Descriptor::getId).map(this::getMigration).collect(toList());</technical_language>

Target:
public List<Migration> getMigrations() { return getDescriptors(XP_CONFIG).stream().map(Descriptor::getId).map(this::getMigration).collect(toList()); }
Source:
<code>private void writeGroup(ArrayList<SAMRecord> groupOfReads, HashMap<Integer, SAMFileWriter> writers) { int destination = TARGET_INDEX; boolean unaligned = true; for (SAMRecord rec: groupOfReads) { if (!(rec.getReadUnmappedFlag())) { if (( INVERT_TARGET) ^ (!(SUBSET.contains(rec.getReferenceName())))) { destination = EXCLUDED_INDEX; break; } else { unaligned = false; } } else { <START> if ((EXCLUDE_UNALIGNED) && (SUBSET.contains(rec.getReferenceName()))) { <END> destination = EXCLUDED_INDEX; } } } if (unaligned && EXCLUDE_UNALIGNED && destination==TARGET_INDEX) { destination = EXCLUDED_INDEX; } for (SAMRecord rec: groupOfReads) { writers.get(destination).addAlignment(rec); } }</code><technical_language>logic depend ReferenceName of unaligned record</technical_language>

Target:
private void writeGroup(ArrayList<SAMRecord> groupOfReads, HashMap<Integer, SAMFileWriter> writers) { int destination = TARGET_INDEX; boolean unaligned = true; for (SAMRecord rec: groupOfReads) { if (!(rec.getReadUnmappedFlag())) { if (( INVERT_TARGET) ^ (!(SUBSET.contains(rec.getReferenceName())))) { destination = EXCLUDED_INDEX; break; } else { unaligned = false; } } } if (unaligned && EXCLUDE_UNALIGNED && destination==TARGET_INDEX) { destination = EXCLUDED_INDEX; } for (SAMRecord rec: groupOfReads) { writers.get(destination).addAlignment(rec); } }
Source:
<code>protected boolean validateImages() { <START> List<DiskImage> imagesToValidate = getDiskImagesToValidate(); List<DiskImage> allDiskImagesInSrcAndDstToValidate = getAllDiskImagesInSrcAndDstToValidate(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(imagesToValidate); DiskImagesValidator allDiskImagesInChainValidator = new DiskImagesValidator(allDiskImagesInSrcAndDstToValidate); <END> return validateImagesNotLocked(diskImagesValidator) && (getVm().isQualifiedForLiveSnapshotMerge() || validate(allDiskImagesInChainValidator.diskImagesNotIllegal())) && (!getVm().isQualifiedForLiveSnapshotMerge() || validateSnapshotDisksArePlugged()); }</code><technical_language>Please replace line #481 line #482</technical_language>

Target:
protected boolean validateImages() { List<DiskImage> imagesToValidate = getDiskImagesToValidate(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(imagesToValidate); List<DiskImage> allDiskImagesInSrcAndDstToValidate = getAllDiskImagesInSrcAndDstToValidate(); DiskImagesValidator allDiskImagesInChainValidator = new DiskImagesValidator(allDiskImagesInSrcAndDstToValidate); return validateImagesNotLocked(diskImagesValidator) && (getVm().isQualifiedForLiveSnapshotMerge() || validate(allDiskImagesInChainValidator.diskImagesNotIllegal())) && (!getVm().isQualifiedForLiveSnapshotMerge() || validateSnapshotDisksArePlugged()); }
Source:
<code>public long lastModified() { try { return p4.getHead(base + "/..."); } catch (Exception e) { <START> logger.warning("Unable to check changes: " + e.getMessage()); <END> } return 0; }</code><technical_language>I put return 0L here. This is place do propagate exception</technical_language>

Target:
public long lastModified() { long last = 0L; try { last = p4.getHead(base + "/..."); } catch (Exception e) { logger.warning("Unable to check changes: " + e.getMessage()); } return last; }
Source:
<code>public synchronized void onComplete(Result result) { Throwable throwable = result.getFailure(); if (throwable != null) { future.failed(throwable); } else { <START> currentBuffer = null; <END> currentBufferPosition = 0; future.completed(result.getResponse(), new GatheringByteArrayInputStream(buffers, size)); } }</code><technical_language>Set currentBuffer new byte[0] currentBuffer is null. This is a common trick consolidate checks size checks (without nulls), careful add zero byte array outputs :)</technical_language>

Target:
public synchronized void onComplete(Result result) { Throwable throwable = result.getFailure(); if (throwable != null) { future.failed(throwable); } else { currentBuffer = new byte[0]; currentBufferPosition = 0; future.completed(result.getResponse(), new GatheringByteArrayInputStream(buffers, size)); buffers = new ArrayList<>(); size = 0; } }
Source:
<code>public void customize(RestTemplate restTemplate) { restTemplate.setRequestFactory(new DefaultZipkinConnectionFactory(this.zipkinProperties)); if (this.zipkinProperties.isBasicAuthenticated()) { <START> restTemplate.getInterceptors().add( <END> new BasicAuthorizationInterceptor(this.zipkinProperties.getUsername(), this.zipkinProperties.getPassword())); } }</code><technical_language>a new type? code manage users add Interceptors? Ex basic auth is necessarily a normal case apis (ex AWS password auth for good reasons). I goal is basic auth _possible_, standard</technical_language>

Target:
public void customize(RestTemplate restTemplate) { if (this.zipkinProperties.getCompression().isEnabled()) { restTemplate.getInterceptors().add(0, new GZipInterceptor()); } }
Source:
<code>public Map<String, Gauge> getTaskGauges(int taskId) { Map<String, Gauge> taskGaugeMap = new HashMap<>(); Collection<Gauge> gauges = registry.getGauges().values(); Map<String, Metric> taskMetrics = taskIdMetrics.getOrDefault(taskId, Collections.emptyMap()); for (Map.Entry<String, Metric> entry : taskMetrics.entrySet()) { <START> if (gauges.contains(entry.getValue())) { <END> taskGaugeMap.put(entry.getKey(), (Gauge) entry.getValue()); } } return taskGaugeMap; }</code><technical_language>instead of metric check if a gauge, I need separate maps for metric types</technical_language>

Target:
public Map<String, Gauge> getTaskGauges(int taskId) { return getMetricNameMap(taskId, taskIdGauges); }
Source:
<code>public OfLong getListOfEntriesOfLedger(long ledgerId) throws IOException { Iterator<LedgerCache.PageEntries> pageEntriesIteratorNonFinal = null; try { pageEntriesIteratorNonFinal = ledgerCache.listEntries(ledgerId).iterator(); } catch (Bookie.NoLedgerException noLedgerException) { pageEntriesIteratorNonFinal = Collections.emptyIterator(); } final Iterator<LedgerCache.PageEntries> pageEntriesIterator = pageEntriesIteratorNonFinal; <START> return new OfLong() { <END> long[] entriesInCurrentLedgerPage = new long[entriesPerLedgerEntryPage]; final MutableInt indOfArrayOfCurrentLedgerPage = new MutableInt(0); { Arrays.fill(entriesInCurrentLedgerPage, INVALID_ENTRYID); } @Override public boolean hasNext() { try { if ((indOfArrayOfCurrentLedgerPage.intValue() == entriesPerLedgerEntryPage) || entriesInCurrentLedgerPage[indOfArrayOfCurrentLedgerPage .intValue()] == INVALID_ENTRYID) { if (pageEntriesIterator.hasNext()) { Arrays.fill(entriesInCurrentLedgerPage, INVALID_ENTRYID); MutableInt tempIndOfArray = new MutableInt(0); PageEntries pageEntry = pageEntriesIterator.next(); LedgerEntryPage lep = pageEntry.getLEP(); lep.getEntries((entryId, position) -> { entriesInCurrentLedgerPage[tempIndOfArray.getAndIncrement()] = entryId; return true; }); indOfArrayOfCurrentLedgerPage.setValue(0); } } return ((!(indOfArrayOfCurrentLedgerPage.intValue() == entriesPerLedgerEntryPage)) && (entriesInCurrentLedgerPage[indOfArrayOfCurrentLedgerPage .intValue()] != INVALID_ENTRYID)); } catch (Exception exc) { throw new RuntimeException( "Received exception in InterleavedLedgerStorage getEntriesOfLedger hasNext call", exc); } } @Override public long nextLong() { if (!hasNext()) { throw new NoSuchElementException(); } return entriesInCurrentLedgerPage[indOfArrayOfCurrentLedgerPage.getAndIncrement()]; } }; }</code><technical_language>worth moving this class a separate class is easy write tests for it</technical_language>

Target:
public OfLong getListOfEntriesOfLedger(long ledgerId) throws IOException { return ledgerCache.getEntriesIterator(ledgerId); }
Source:
<code>public CompletableFuture<Optional<Endpoint>> getRestEndpoint(String clusterId) { final int restPort = this.flinkConfig.getInteger(RestOptions.PORT); final KubernetesConfigOptions.ServiceExposedType serviceExposedType = flinkConfig.get(KubernetesConfigOptions.REST_SERVICE_EXPOSED_TYPE); if (serviceExposedType == KubernetesConfigOptions.ServiceExposedType.ClusterIP) { return CompletableFuture.completedFuture( Optional.of(new Endpoint(KubernetesUtils.getInternalServiceName(clusterId) + "." + nameSpace, restPort))); } return getRestService(clusterId).thenApply(restService -> { if (!restService.isPresent()) { return Optional.empty(); } Service service = restService.get().getInternalResource(); <START> String address = null; int endpointPort = restPort; if (service.getStatus() != null && (service.getStatus().getLoadBalancer() != null || service.getStatus().getLoadBalancer().getIngress() != null)) { if (service.getStatus().getLoadBalancer().getIngress().size() > 0) { address = service.getStatus().getLoadBalancer().getIngress().get(0).getIp(); if (address == null || address.isEmpty()) { address = service.getStatus().getLoadBalancer().getIngress().get(0).getHostname(); } } else { address = this.internalClient.getMasterUrl().getHost(); endpointPort = getServiceNodePort(service, RestOptions.PORT); } } else if (service.getSpec().getExternalIPs() != null && service.getSpec().getExternalIPs().size() > 0) { address = service.getSpec().getExternalIPs().get(0); } if (address == null || address.isEmpty()) { return Optional.empty(); } return Optional.of(new Endpoint(address, endpointPort)); <END> }); }</code><technical_language>I factor this out a method, e.g. getRestEndpointFromService(service, port)</technical_language>

Target:
public Optional<Endpoint> getRestEndpoint(String clusterId) { Optional<KubernetesService> restService = getRestService(clusterId); if (!restService.isPresent()) { return Optional.empty(); } final Service service = restService.get().getInternalResource(); final int restPort = getRestPortFromExternalService(service); final KubernetesConfigOptions.ServiceExposedType serviceExposedType = KubernetesConfigOptions.ServiceExposedType.valueOf(service.getSpec().getType()); if (serviceExposedType == KubernetesConfigOptions.ServiceExposedType.ClusterIP) { return Optional.of( new Endpoint(KubernetesUtils.getInternalServiceName(clusterId) + "." + nameSpace, restPort)); } return getRestEndPointFromService(service, restPort); }
Source:
<code>public IRetryAnalyzer getRetryAnalyzer() { <START> if (this.m_retryAnalyzerClass != null && IRetryAnalyzer.class.isAssignableFrom(this.m_retryAnalyzerClass)) { <END> try { return (IRetryAnalyzer) this.m_retryAnalyzerClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { } } return null; }</code><technical_language>I catch change here: a new instance created for get. set throw exception if provided class is a retry analyzer</technical_language>

Target:
public IRetryAnalyzer getRetryAnalyzer() { return m_retryAnalyzer; }
Source:
<code>public Response validate(ConcurEventNotificationDTO concurEventNotificationDTO) { ConcurEventNotification concurEventNotification = null; try { concurEventNotification = getConcurEventNotificationConversionService().convertConcurEventNotification(concurEventNotificationDTO); } catch (ParseException e) { <START> LOG.error(e.getMessage()); <END> throw new BadRequestException(); } getConcurEventNotificationService().saveConcurEventNotification(concurEventNotification); return Response.ok().build(); }</code><technical_language>This include function name in error message. Also, error logged message</technical_language>

Target:
public Response validate(ConcurEventNotificationDTO concurEventNotificationDTO) { ConcurEventNotification concurEventNotification = null; try { concurEventNotification = getConcurEventNotificationConversionService().convertConcurEventNotification(concurEventNotificationDTO); } catch (ParseException e) { LOG.error("validate():" + e.getMessage(), e); throw new BadRequestException(); } getConcurEventNotificationService().saveConcurEventNotification(concurEventNotification); return Response.ok().build(); }