auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testGetAllLoadBalancers() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/loadbalancer/loadbalancers.xml"))); ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); LoadBalancerApi api = pbApi.loadBalancerApi(); try { List<LoadBalancer> loadBalancerList = api.getAllLoadBalancers(); <START> assertRequestHasCommonProperties(server.takeRequest()); <END> assertNotNull(loadBalancerList); assertTrue(loadBalancerList.size() == 2); } finally { pbApi.close(); server.shutdown(); } }</code><technical_language>Verify body of request too</technical_language>

Target:
public void testGetAllLoadBalancers() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/loadbalancer/loadbalancers.xml"))); ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); LoadBalancerApi api = pbApi.loadBalancerApi(); try { List<LoadBalancer> loadBalancerList = api.getAllLoadBalancers(); assertRequestHasCommonProperties(server.takeRequest(), "<ws:getAllLoadBalancers/>"); assertNotNull(loadBalancerList); assertTrue(loadBalancerList.size() == 2); } finally { pbApi.close(); server.shutdown(); } }
Source:
<code>public void scikitLearnExample() { Map<Integer, double[]> data = new HashMap<>(); double one = 1.; double two = 2.; data.put(0, new double[] {one, -1, 1}); data.put(2, new double[] {one, -2, -1}); data.put(3, new double[] {one, -3, -2}); data.put(4, new double[] {two, 1, 1}); data.put(5, new double[] {two, 2, 1}); data.put(6, new double[] {two, 3, 2}); GaussianNaiveBayesTrainer trainer = new GaussianNaiveBayesTrainer(); GaussianNaiveBayesModel model = trainer.fit( new LocalDatasetBuilder<>(data, 2), (k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 1, v.length)), (k, v) -> v[0] ); <START> Vector observation = new DenseVector(new double[] {-0.8, -1}); <END> Assert.assertEquals(one, model.apply(observation), PRECISION); }</code><technical_language>Lets VectorUtils.of(...)</technical_language>

Target:
public void scikitLearnExample() { Map<Integer, double[]> data = new HashMap<>(); double one = 1.; double two = 2.; data.put(0, new double[] {one, -1, 1}); data.put(2, new double[] {one, -2, -1}); data.put(3, new double[] {one, -3, -2}); data.put(4, new double[] {two, 1, 1}); data.put(5, new double[] {two, 2, 1}); data.put(6, new double[] {two, 3, 2}); GaussianNaiveBayesTrainer trainer = new GaussianNaiveBayesTrainer(); GaussianNaiveBayesModel model = trainer.fit( new LocalDatasetBuilder<>(data, 2), (k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 1, v.length)), (k, v) -> v[0] ); Vector observation = VectorUtils.of(-0.8, -1); Assert.assertEquals(one, model.apply(observation), PRECISION); }
Source:
<code>public AccountService getAccountService() { logger.info("Starting an InMemoryUnknownAccountService."); long startTime = System.currentTimeMillis(); <START> AccountService res = new InMemoryUnknownAccountService(); <END> logger.info("InMemoryUnknownAccountService started, took ms", System.currentTimeMillis() - startTime); return res; }</code><technical_language>call this variable accountService</technical_language>

Target:
public AccountService getAccountService() { logger.info("Starting an InMemoryUnknownAccountService."); return new InMemoryUnknownAccountService(); }
Source:
<code>public static IsolationMethod getIsolationMethod(String prfx) { IsolationMethod rc = null; for (IsolationMethod method: registeredIsolationMethods) { <START> if (method.provider.equals(prfx)) { <END> rc = method; if(! rc.getProvider().equals(UNKNOWN_PROVIDER)) { break; } } } return rc; }</code><technical_language>This method.methodPrefix.equals(prfx) Test Scenario: @Test public void getIsolationMethodTest() throws Exception { PhysicalNetwork.IsolationMethod method = new PhysicalNetwork.IsolationMethod("bla"); final PhysicalNetwork.IsolationMethod isolationMethod = PhysicalNetwork.IsolationMethod.getIsolationMethod("bla"); assertEquals(method, isolationMethod); }</technical_language>

Target:
public static IsolationMethod getIsolationMethod(String prfx) throws IsolationMethodNotRegistered { IsolationMethod rc = null; for (IsolationMethod method: registeredIsolationMethods) { if (method.methodPrefix.equals(prfx)) { rc = method; if(! rc.getProvider().equals(UNKNOWN_PROVIDER)) { break; } } } if (rc == null) { throw new IsolationMethodNotRegistered("No registration of prefix '" + prfx + "' found."); } return rc; }
Source:
<code>private void setShareIntent() { if (mShareActionProvider != null) { Intent shareIntent = new Intent(Intent.ACTION_SEND); <START> shareIntent.setType("text/plain"); <END> shareIntent.putExtra(Intent.EXTRA_TEXT, mlogs); mShareActionProvider.setShareIntent(shareIntent); } }</code><technical_language>I notice/think of this review, I realized I envisioning sharing/sending file itself, sending log contents body of a plain text message. In event logs long, I cleaner. switch sense well, another reason decided do this way</technical_language>

Target:
private void setShareIntent() { if (mShareActionProvider != null) { Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_STREAM, DataChangeLogger.getLogFilesUri()); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.commcare_logs)); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mShareActionProvider.setShareIntent(shareIntent); } }
Source:
<code>public boolean allowedRequest(ReconnectRequest req) { boolean allowed = false; if (req instanceof ReconnectRequest) { ReconnectRequest reconnectRequest = (ReconnectRequest) req; Object element = ((View) <START> reconnectRequest.getConnectionEditPart().getModel()).getElement(); <END> if (element instanceof Message) { MessageEnd oppositeMessageEnd = null; Message messageElement = (Message) element; MessageEnd sendEvent = messageElement.getSendEvent(); MessageEnd recvEvent = messageElement.getReceiveEvent(); if (RECONNECTION_TARGET_TYPE.equals(reconnectRequest.getType())) { oppositeMessageEnd = sendEvent; } else if (RECONNECTION_SOURCE_TYPE.equals(reconnectRequest.getType())) { oppositeMessageEnd = recvEvent; } InteractionFragment targetContainer = SequenceUtil.findInteractionFragmentContainerAt(reconnectRequest.getLocation(), getHost().getParent()); if (null != oppositeMessageEnd) { allowed = (targetContainer == oppositeMessageEnd.eContainer()); } } } return allowed; }</code><technical_language>Check null edit part, model Checl View type for element casting</technical_language>

Target:
public boolean allowedRequest(ReconnectRequest req) { boolean allowed = false; if (req instanceof ReconnectRequest) { ReconnectRequest reconnectRequest = (ReconnectRequest) req; Object element = null; if (null != reconnectRequest.getConnectionEditPart() && reconnectRequest.getConnectionEditPart().getModel() instanceof View) { element = ((View) reconnectRequest.getConnectionEditPart().getModel()).getElement(); } if (element instanceof Message) { MessageEnd oppositeMessageEnd = null; Message messageElement = (Message) element; MessageEnd sendEvent = messageElement.getSendEvent(); MessageEnd recvEvent = messageElement.getReceiveEvent(); if (RECONNECTION_TARGET_TYPE.equals(reconnectRequest.getType())) { oppositeMessageEnd = sendEvent; } else if (RECONNECTION_SOURCE_TYPE.equals(reconnectRequest.getType())) { oppositeMessageEnd = recvEvent; } InteractionFragment targetContainer = SequenceUtil.findInteractionFragmentContainerAt(reconnectRequest.getLocation(), getHost().getParent()); if (null != oppositeMessageEnd) { allowed = (targetContainer == oppositeMessageEnd.eContainer()); } } } return allowed; }
Source:
<code>public CifsWinRmConnection(String type, ConnectionOptions options, AddressPortMapper mapper) { super(type, options, mapper, true); <START> ConnectionValidator.assertIsWindowsHost(os, CIFS_PROTOCOL, cifsConnectionType); <END> ConnectionValidator.assertNotOldStyleWindowsDomain(username, CIFS_PROTOCOL, cifsConnectionType); }</code><technical_language>static imports</technical_language>

Target:
public CifsWinRmConnection(String type, ConnectionOptions options, AddressPortMapper mapper) { super(type, options, mapper); }
Source:
<code>public List<String> getNames() { <START> List<String> names = Lists.newArrayList(name); <END> names.addAll(alternativeNames); return names; }</code><technical_language>I guess allocate ArrayList fixed capacity (alternativeNames.size() +1) add names. This prevent potential reallocation</technical_language>

Target:
public List<String> getNames() { List<String> names = Lists.newArrayListWithCapacity(alternativeNames.size() +1); names.add(name); names.addAll(alternativeNames); return names; }
Source:
<code>private void visitParameterDef(DetailAST parameterDef) { final DetailAST grandParentAST = parameterDef.getParent().getParent(); if (grandParentAST.getType() == TokenTypes.METHOD_DEF && isCheckedMethod(grandParentAST) && isVerifiable(grandParentAST) <START> && !AnnotationUtil.containsAnnotation(grandParentAST, "Override")) { <END> checkClassName(parameterDef); } }</code><technical_language>discussed in main issue, this in check for entire method. this moved isCheckedMethod method</technical_language>

Target:
private void visitParameterDef(DetailAST parameterDef) { final DetailAST grandParentAST = parameterDef.getParent().getParent(); if (grandParentAST.getType() == TokenTypes.METHOD_DEF && isCheckedMethod(grandParentAST)) { checkClassName(parameterDef); } }
Source:
<code>private Object createObjectFromMap(String name) { final String packageName = SHORT_TO_FULL_MODULE_NAMES.get(name); Object instance = null; if (packageName == null) { final String nameCheck = name + CHECK_SUFFIX; <START> final String packageNameWithSuffix = SHORT_TO_FULL_MODULE_NAMES.get(nameCheck); <END> if (packageNameWithSuffix != null) { instance = createObject(packageNameWithSuffix); } } else { instance = createObject(packageName); } return instance; }</code><technical_language>please fix 'packageNameWithSuffix' name</technical_language>

Target:
private Object createObjectFromMap(String name) { final String fullModuleName = NAME_TO_FULL_MODULE_NAME.get(name); Object instance = null; if (fullModuleName == null) { final String fullCheckModuleName = NAME_TO_FULL_MODULE_NAME.get(name + CHECK_SUFFIX); if (fullCheckModuleName != null) { instance = createObject(fullCheckModuleName); } } else { instance = createObject(fullModuleName); } return instance; }
Source:
<code>private SelectionListener downloadButtonListener(Composite parent) { return new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { MenuManager mgr = new MenuManager(); mgr.add(new CherryPickRevision(fChangeInfo.getUserSelectedRevision(), fGerritClient)); mgr.add(new CheckoutRevision(fChangeInfo.getUserSelectedRevision(), fGerritClient)); mgr.createContextMenu(parent).setVisible(true); <START> ActiveWorkspaceRevision.getInstance().enableQuickDiff(getSite(), fGerritClient, fChangeInfo); <END> } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; }</code><technical_language>need this here. adding this part of activation logic, worry it</technical_language>

Target:
private SelectionListener downloadButtonListener(Composite parent) { return new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { MenuManager mgr = new MenuManager(); mgr.add(new CherryPickRevision(fChangeInfo.getUserSelectedRevision(), fGerritClient)); mgr.add(new CheckoutRevision(fChangeInfo.getUserSelectedRevision(), fGerritClient)); mgr.createContextMenu(parent).setVisible(true); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; }
Source:
<code>private static boolean isJavaIdentifier(String s) { <START> if (s.length() == 0) { <END> return false; } int start = s.codePointAt(0); if (!Character.isJavaIdentifierStart(start)) { return false; } int charCount = Character.charCount(start); for (int i = charCount; i < s.length(); i += charCount) { int codePoint = s.codePointAt(i); if (!Character.isJavaIdentifierPart(codePoint)) { return false; } } return true; }</code><technical_language>suggestion if (s.isEmpty()) {</technical_language>

Target:
private static boolean isJavaIdentifier(String s) { if (s.isEmpty()) { return false; } int start = s.codePointAt(0); if (!Character.isJavaIdentifierStart(start)) { return false; } int charCount = Character.charCount(start); for (int i = charCount; i < s.length(); i += charCount) { int codePoint = s.codePointAt(i); if (!Character.isJavaIdentifierPart(codePoint)) { return false; } } return true; }
Source:
<code>public void testSerDes() throws Exception { <START> if (version == BLOB_ID_V3) { <END> return; } BlobId blobId = new BlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId, referencePartitionId, referenceIsEncrypted); deserializeBlobIdAndAssert(version, blobId.getID(), referenceIsEncrypted); BlobId blobIdSerDed = new BlobId(new DataInputStream(new ByteArrayInputStream(blobId.toBytes())), referenceClusterMap); assertTrue(blobId.equals(blobIdSerDed)); assertTrue(blobIdSerDed.equals(blobId)); assertEquals(blobId.hashCode(), blobIdSerDed.hashCode()); assertEquals(0, blobId.compareTo(blobIdSerDed)); assertEquals(0, blobIdSerDed.compareTo(blobId)); }</code><technical_language>combine test below</technical_language>

Target:
public void testSerDes() throws Exception { BlobId blobId = new BlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId, referencePartitionId, referenceIsEncrypted); deserializeBlobIdAndAssert(version, blobId.getID()); BlobId blobIdSerDed = new BlobId(new DataInputStream(new ByteArrayInputStream(blobId.toBytes())), referenceClusterMap); assertTrue(blobId.equals(blobIdSerDed)); assertTrue(blobIdSerDed.equals(blobId)); assertEquals(blobId.hashCode(), blobIdSerDed.hashCode()); assertEquals(0, blobId.compareTo(blobIdSerDed)); assertEquals(0, blobIdSerDed.compareTo(blobId)); }
Source:
<code>private GlusterGeoRepSession getGeoRepSession() { if (getParameters().getGeoRepSessionId() != null) { return geoRepDao.getById(getParameters().getGeoRepSessionId()); } <START> return null; <END> }</code><technical_language>I need this check this method. simply call geoRepDao.getById(getParameters().getGeoRepSessionId()) needed, if getParameters().getGeoRepSessionId() simply get result</technical_language>

Target:
private GlusterGeoRepSession getGeoRepSession() { return geoRepDao.getById(getParameters().getGeoRepSessionId()); }
Source:
<code><START> private String getPluginKeyAndResourcePath(HttpServletRequest request) { <END> return StringUtils.substringAfter(request.getRequestURI(), request.getContextPath() + request.getServletPath() + "/"); }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') "getPluginKeyAndResourcePath" a "static" method. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
private static String getPluginKeyAndResourcePath(HttpServletRequest request) { return StringUtils.substringAfter(request.getRequestURI(), request.getContextPath() + request.getServletPath() + "/"); }
Source:
<code>public Integer findVersionNumber(ArticleIdentity article, int revisionNumber) { String articleKey = article.getIdentifier(); String uuid = findRevisionUuid(articleKey, revisionNumber); if (uuid == null) { throw entityNotFound("Revision doesn't exist: " + article); <START> } <END> RepoCollectionMetadata collectionMetadata; try { collectionMetadata = contentRepoService.getCollection(RepoVersion.create(articleKey, uuid)); } catch(NotFoundException nfe) { throw entityNotFound(nfe.getMessage() + ": " + articleKey); } return collectionMetadata.getVersionNumber().getNumber(); }</code><technical_language>this method longer returns null, change return type int</technical_language>

Target:
public int findVersionNumber(ArticleIdentity article, int revisionNumber) { String articleKey = article.getIdentifier(); String uuid = findRevisionUuid(articleKey, revisionNumber); if (uuid == null) { throw reportNotFound(article, "article revision UUID"); } try { return contentRepoService.getCollection(RepoVersion.create(articleKey, uuid)).getVersionNumber().getNumber(); } catch(NotFoundException nfe) { throw reportNotFound(article, "collection", nfe); } }
Source:
<code>public ArchiveContentEncodingDetector(String extension) { <START> Assert.isLegal(extension != null && !extension.isEmpty(), "extension can't be empty"); <END> this.extension = extension; }</code><technical_language>need check end "/", a folder</technical_language>

Target:
public ArchiveContentEncodingDetector(String extension) { Assert.isLegal(extension != null && !extension.isEmpty() && !extension.endsWith("/"), "extension can't be empty or /"); this.extension = extension; }
Source:
<code>protected void addProcesses(IProcess[] processes) { if (processes != null) { for (IProcess <START> processe : <END> processes) { addProcess(processe); fireChanged(); } } }</code><technical_language>typo</technical_language>

Target:
protected void addProcesses(IProcess[] processes) { if (processes != null) { for (IProcess process : processes) { addProcess(process); fireChanged(); } } }
Source:
<code>public void reopenAccount(String newPassword) { clearDisableFlagButton.click(); waitForTextToBePresentInElementByElement( statusMessage, <START> "Successfully removed disabled bit for account" <END> ); newPasswordRadio.click(); newPasswordField.sendKeys(newPassword); newPasswordField.submit(); }</code><technical_language>is community language? If this text in some kind of FINAL in this class</technical_language>

Target:
public void reopenAccount(String newPassword) { newPasswordRadio.click(); newPasswordField.sendKeys(newPassword); newPasswordField.submit(); clearDisableFlagButton.click(); PageObjectLogging.log( "reopenAccount", "account reopened", true ); }
Source:
<code>public Pair<Integer, Boolean> getFormDefIdForRecord(SqlStorage<FormDefRecord> formDefRecordStorage, int formRecordId, FormEntryInstanceState instanceState) throws FormEntryActivity.FormQueryException { Boolean isInstanceReadOnly = false; FormRecord formRecord = FormRecord.getFormRecord(formRecordStorage, formRecordId); mFormRecordPath = formRecord.getFilePath(); if (FormRecord.STATUS_COMPLETE.equals(formRecord.getStatus())) { if (!Boolean.parseBoolean(formRecord.getCanEditWhenComplete())) { isInstanceReadOnly = true; } } Vector<FormDefRecord> formDefRecords = FormDefRecord.getFormDefsByJrFormId(formDefRecordStorage, formRecord.getXmlns()); if (formDefRecords.size() == 1) { FormDefRecord formDefRecord = formDefRecords.get(0); instanceState.setFormDefPath(formDefRecord.getFilePath()); return new Pair<>(formDefRecord.getID(), isInstanceReadOnly); } else if (formDefRecords.size() < 1) { <START> throw new FormEntryActivity.FormQueryException("Parent form does not exist"); <END> } else { throw new FormEntryActivity.FormQueryException("More than one possible parent form"); } }</code><technical_language>I "Parent" is a confusing word is reading this error. more helpful describe "There XForm definition defined" list XMLNS of form (although more useful in a notification technobabble people)</technical_language>

Target:
public Pair<Integer, Boolean> getFormDefIdForRecord(SqlStorage<FormDefRecord> formDefRecordStorage, int formRecordId, FormEntryInstanceState instanceState) throws FormEntryActivity.FormQueryException { Boolean isInstanceReadOnly = false; FormRecord formRecord = FormRecord.getFormRecord(formRecordStorage, formRecordId); mFormRecordPath = formRecord.getFilePath(); if (FormRecord.STATUS_COMPLETE.equals(formRecord.getStatus())) { if (!Boolean.parseBoolean(formRecord.getCanEditWhenComplete())) { isInstanceReadOnly = true; } } Vector<FormDefRecord> formDefRecords = FormDefRecord.getFormDefsByJrFormId(formDefRecordStorage, formRecord.getXmlns()); if (formDefRecords.size() == 1) { FormDefRecord formDefRecord = formDefRecords.get(0); instanceState.setFormDefPath(formDefRecord.getFilePath()); return new Pair<>(formDefRecord.getID(), isInstanceReadOnly); } else if (formDefRecords.size() < 1) { String error = "No XForm definition defined for this form with namespace " + formRecord.getXmlns(); Logger.log(LogTypes.SOFT_ASSERT, error); throw new FormEntryActivity.FormQueryException(error); } else { String error = "More than one XForm definition present for this form with namespace " + formRecord.getXmlns(); Logger.log(LogTypes.SOFT_ASSERT, error); throw new FormEntryActivity.FormQueryException(error); } }
Source:
<code>public void fulfill() { ConfigureMavenRepositoriesWizard mr = openRepositoriesWizard(); for (ToRemoveMavenRepository r : repo.toRemoveRepositories()) { String id = r.ID() + "-" + r.url(); <START> if (r.hasToExists()) { <END> mr.removeRepo(id); } else if (new DefaultTable(new DefaultGroup("Repositories")).containsItem(id)) { mr.removeRepo(id); } } if (repo.toRemoveRepositories().length == 0) mr.removeAllRepos(); closeRepositoriesWizard(); }</code><technical_language>This specific if(){} else if(){} branches code. is reason for that</technical_language>

Target:
public void fulfill() { ConfigureMavenRepositoriesWizard mr = openRepositoriesWizard(); DefaultTable repoTable = new DefaultTable(new DefaultGroup("Repositories")); for (ToRemoveMavenRepository r : repo.toRemoveRepositories()) { String id = r.ID() + "-" + r.url(); if (r.hasToExists() || repoTable.containsItem(id)) { mr.removeRepo(id); } } if (repo.toRemoveRepositories().length == 0) mr.removeAllRepos(); closeRepositoriesWizard(); }
Source:
<code>public void initialize() throws InternalErrorException { <START> if(perun.isThisPerunReadOnly()) log.debug("Loading authzresolver manager init in readOnly version."); <END> for (Role role: Role.values()) { try { if (0 == jdbc.queryForInt("select count(*) from roles where name=?", role.getRoleName())) { if(perun.isThisPerunReadOnly()) { log.error("One of default role not exists in DB {}.", role); } else { int newId = Utils.getNewId(jdbc, "roles_id_seq"); jdbc.update("insert into roles (id, name) values (?,?)", newId, role.getRoleName()); } } } catch (RuntimeException e) { throw new InternalErrorException(e); } } }</code><technical_language>here, stop startup, roles missing created</technical_language>

Target:
public void initialize() throws InternalErrorException { if(perun.isPerunReadOnly()) log.debug("Loading authzresolver manager init in readOnly version."); for (Role role: Role.values()) { try { if (0 == jdbc.queryForInt("select count(*) from roles where name=?", role.getRoleName())) { if(perun.isPerunReadOnly()) { throw new InternalErrorException("One of deafult roles not exists in DB - " + role); } else { int newId = Utils.getNewId(jdbc, "roles_id_seq"); jdbc.update("insert into roles (id, name) values (?,?)", newId, role.getRoleName()); } } } catch (RuntimeException e) { throw new InternalErrorException(e); } } }
Source:
<code>public Response glusterServiceStart(Action action) { <START> return doAction(VdcActionType.ManageGlusterService, new GlusterServiceParameters(null, <END> guid, ServiceType.valueOf(action.getGlusterServiceType()), "start"), action); }</code><technical_language>Need validate action GlusterServiceType parameter</technical_language>

Target:
public Response glusterServiceStart(Action action) { String srvcTypeParam = action.getGlusterServiceType(); if(!isValidServiceType(srvcTypeParam)) { return null; } return doAction(VdcActionType.ManageGlusterService, new GlusterServiceParameters(null, guid, ServiceType.valueOf(srvcTypeParam), "start"), action); }
Source:
<code>private void executeBuild(final String type, final String subType) { final String caption = "Build"; <START> workbenchContext_.setBuildInProgress(true); <END> terminalHelper_.warnBusyTerminalBeforeCommand(new Command() { @Override public void execute() { sourceBuildHelper_.withSaveFilesBeforeCommand(new Command() { @Override public void execute() { server_.startBuild(type, subType, new SimpleRequestCallback<Boolean>() { @Override public void onResponseReceived(Boolean response) { } @Override public void onError(ServerError error) { super.onError(error); workbenchContext_.setBuildInProgress(false); } }); } }, caption); } }, caption, "Terminal jobs will be terminated. Are you sure?"); }</code><technical_language>get stuck in "build in progress" state if user decides proceed build busy terminals</technical_language>

Target:
private void executeBuild(final String type, final String subType) { final String caption = "Build"; terminalHelper_.warnBusyTerminalBeforeCommand(new Command() { @Override public void execute() { workbenchContext_.setBuildInProgress(true); sourceBuildHelper_.withSaveFilesBeforeCommand(new Command() { @Override public void execute() { server_.startBuild(type, subType, new SimpleRequestCallback<Boolean>() { @Override public void onResponseReceived(Boolean response) { } @Override public void onError(ServerError error) { super.onError(error); workbenchContext_.setBuildInProgress(false); } }); } }, caption); } }, caption, "Terminal jobs will be terminated. Are you sure?"); }
Source:
<code><START> public BitmapFont generateFont (FreeTypeFontParameter parameter, FreeTypeBitmapFontData data) { <END> generateData(parameter, data); Array<TextureRegion> regions; if (parameter.packer != null) { regions = parameter.packer.getTextureRegions(parameter.minFilter, parameter.magFilter, parameter.genMipMaps); } else { regions = data.regions; } BitmapFont font = new BitmapFont(data, regions, false); font.setOwnsTexture(parameter.packer == null); return font; }</code><technical_language>I this method added in PR, in fact I added FreeTypeBitmapFontData subclassed override methdos, this feels weird. for FreeTypeBitmapFontData a FreeTypeFontGenerator FreeTypeFontGenerator create populate a FreeTypeBitmapFontData. Thoughts? If agree I do this PR is merged</technical_language>

Target:
public BitmapFont generateFont (FreeTypeFontParameter parameter, FreeTypeBitmapFontData data) { generateData(parameter, data); if (data.regions == null && parameter.packer != null) { data.regions = new Array<TextureRegion>(); parameter.packer.updateTextureRegions(data.regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps, false); } BitmapFont font = new BitmapFont(data, data.regions, false); font.setOwnsTexture(parameter.packer == null); return font; }
Source:
<code>public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command) throws Throwable { if (this.statisticsEnabled) prepares.incrementAndGet(); Object result = invokeNextInterceptorAndVerifyTransaction(ctx, command); if (!ctx.isOriginLocal()) { if (command.isOnePhaseCommit()) { <START> txTable.remoteTransactionCommitted(command.getGlobalTransaction(), false); <END> } else { txTable.remoteTransactionPrepared(command.getGlobalTransaction()); } } return result; }</code><technical_language>I is true instead of false</technical_language>

Target:
public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command) throws Throwable { if (this.statisticsEnabled) prepares.incrementAndGet(); Object result = invokeNextInterceptorAndVerifyTransaction(ctx, command); if (!ctx.isOriginLocal()) { if (command.isOnePhaseCommit()) { txTable.remoteTransactionCommitted(command.getGlobalTransaction(), true); } else { txTable.remoteTransactionPrepared(command.getGlobalTransaction()); } } return result; }
Source:
<code>public ReflServerStateProvider(Logger logger) { Object serverObject = null; MethodHandle isRunning = null; Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer"); try { serverObject = nmsClass.getMethod("getServer").invoke(null); isRunning = MethodHandles.lookup().findVirtual(nmsClass, "isRunning", MethodType.methodType(boolean.class)); } catch (Exception e) { <START> logger.severe("Something's gone terribly wrong!"); e.printStackTrace(); logger.severe("Something's gone terribly wrong!"); <END> } nmsServer = serverObject; nmsIsRunning = isRunning; }</code><technical_language>Bit verbose, need stack trace suggestion e.printStackTrace();</technical_language>

Target:
public ReflServerStateProvider(Logger logger) { Object serverObject = null; MethodHandle isRunning = null; Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer"); try { serverObject = nmsClass.getMethod("getServer").invoke(null); isRunning = MethodHandles.lookup().findVirtual(nmsClass, "isRunning", MethodType.methodType(boolean.class)); } catch (Exception e) { e.printStackTrace(); } nmsServer = serverObject; nmsIsRunning = isRunning; }
Source:
<code>public boolean equals(Object obj) { <START> if (obj == null || !(obj instanceof FilterPath)) { <END> return false; } FilterPath other = (FilterPath) obj; if (path == null) { return other.path == null; } return path.equals(other.path); }</code><technical_language>style-nit; braces for simple single stament constructs</technical_language>

Target:
public boolean equals(Object obj) { if (obj == null || !(obj instanceof FilterPath)) return false; FilterPath other = (FilterPath) obj; if (path == null) return other.path == null; return path.equals(other.path); }
Source:
<code><START> protected void initLineModel(KeyValueLineModel keyValueLineModel, String key) { <END> keyValueLineModel.getValue().setIsAvailable(false); keyValueLineModel.getValues().setIsAvailable(false); }</code><technical_language>Actually, I initLineModel() no-op too; semantics of a key is picked, in this case change a key is picked, right? boxes (constrained free text) hidden along. I hide originally, extending createNewLineModel() method, implement this no-op</technical_language>

Target:
protected void initLineModel(KeyValueLineModel keyValueLineModel, String key) { }
Source:
<code>public FEELFnResult<Boolean> invoke(@ParameterName( "list" ) List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } boolean result = true; for ( final Object element : list ) { if (element != null && !(element instanceof Boolean)) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); } else { <START> result &= element != null && element == Boolean.TRUE; <END> } } return FEELFnResult.ofResult( result ); }</code><technical_language>need a small correction here. Spec says: > return false if item is false, else true if items true, else null previous implementation wrong, good opportunity fix</technical_language>

Target:
public FEELFnResult<Boolean> invoke(@ParameterName( "list" ) List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } boolean result = true; boolean containsNull = false; for ( final Object element : list ) { if (element != null && !(element instanceof Boolean)) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); } else { if (element != null) { result &= (Boolean) element; } else if (!containsNull) { containsNull = true; } } } if (containsNull && result) { return FEELFnResult.ofResult( null ); } else { return FEELFnResult.ofResult( result ); } }
Source:
<code>protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { <START> String title = request.getParameter("title"); <END> String description = request.getParameter("description"); Part filePart = request.getPart("file[0]"); String fileName = filePart.getSubmittedFileName(); final UserSession session = UserSessionUtil.resumeSession(request); if (session == null) { return; } FileMetadata fileMetadata = SQLSource.interact(new SQLInteractionInterface<FileMetadata>() { @Override public FileMetadata run(Connection connection) throws ServiceException, SQLException { int classId = Integer.parseInt(request.getParameter("class")); return FileMetadata.create(connection, session.getUser(), classId, new Date()); } }); String filePath = FILEPATH_PREFIX + fileMetadata.getCourse() + fileName; saveFile(filePart.getInputStream(), filePath); }</code><technical_language>Do want this change? If unsure I @hschmack it. If not, open a work item</technical_language>

Target:
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String title = request.getParameter("title"); String description = request.getParameter("description"); Part filePart = request.getPart("file[0]"); String fileName = filePart.getSubmittedFileName(); final UserSession session = UserSessionUtil.resumeSession(request); if (session == null) { throw new ServiceException(ServiceStatus.NOT_AUTHENTICATED); } FileMetadata fileMetadata = SQLSource.interact(new SQLInteractionInterface<FileMetadata>() { @Override public FileMetadata run(Connection connection) throws ServiceException, SQLException { int classId = Integer.parseInt(request.getParameter("class")); return FileMetadata.create(connection, session.getUser(), classId, new Date()); } }); String filePath = FILEPATH_PREFIX + fileMetadata.getCourse() + fileName; if (!saveFile(filePart.getInputStream(), filePath, fileName)) { throw new ServiceException(ServiceStatus.SERVER_UPLOAD_ERROR); } }
Source:
<code>public ThrottlingExceptionRoutePolicy(int threshold, long failureWindow, long halfOpenAfter, List<Class<?>> handledExceptions) { this.throttledExceptions = handledExceptions; this.failureWindow = failureWindow; this.halfOpenAfter = halfOpenAfter; this.failureThreshold = threshold; <START> this.keepOpen.set(false); <END> }</code><technical_language>I replace statements this(handledExceptions,failureWindow,halfOpenAfter,threshold,false)</technical_language>

Target:
public ThrottlingExceptionRoutePolicy(int threshold, long failureWindow, long halfOpenAfter, List<Class<?>> handledExceptions) { this(threshold, failureWindow, halfOpenAfter, handledExceptions, false); }
Source:
<code>protected boolean accepts(final Resource resource) throws RepositoryException { final ValueMap props = resource.getValueMap(); if (!DamConstants.NT_DAM_ASSETCONTENT.equals(props.get(JcrConstants.JCR_PRIMARYTYPE))) { return false; } if (!props.get(RemoteAssets.IS_REMOTE_ASSET, false)) { return false; } final Calendar lastFailure = props.get(RemoteAssets.REMOTE_SYNC_FAILED, (Calendar) null); if (lastFailure != null && System.currentTimeMillis() < (lastFailure.getTimeInMillis() + (config.getRetryDelay() * 60000))) { return false; } <START> final boolean isAllowedUser = isAllowedUser(resource); <END> if (!isAllowedUser) { return false; } final String path = resource.getPath(); for (final String syncPath : config.getDamSyncPaths()) { if (path.startsWith(syncPath)) { return true; } } return false; }</code><technical_language>isAllowedUser purposely put matchesSyncPath logic a more expensive operation. ensure this function is absolutely efficient for resource fetches involving remote assets, this logic executes literally single resource fetch happening in AEM, 99.999999% of for other remote assets</technical_language>

Target:
protected boolean accepts(final Resource resource) throws RepositoryException { final ValueMap props = resource.getValueMap(); if (!DamConstants.NT_DAM_ASSETCONTENT.equals(props.get(JcrConstants.JCR_PRIMARYTYPE))) { return false; } if (!props.get(RemoteAssets.IS_REMOTE_ASSET, false)) { return false; } final Calendar lastFailure = props.get(RemoteAssets.REMOTE_SYNC_FAILED, (Calendar) null); if (lastFailure != null && System.currentTimeMillis() < (lastFailure.getTimeInMillis() + (config.getRetryDelay() * 60000))) { return false; } final String path = resource.getPath(); for (final String syncPath : config.getDamSyncPaths()) { if (path.startsWith(syncPath)) { return isAllowedUser(resource); } } return false; }
Source:
<code>public static void deletePeopleForLocalBlogIdExceptForFirstPage(int localTableBlogId) { int size = getPeopleCountForLocalBlogId(localTableBlogId); int fetchLimit = PeopleUtils.FETCH_USERS_LIMIT; if (size > fetchLimit) { int deleteCount = size - fetchLimit; String[] args = new String[]{Integer.toString(deleteCount), Integer.toString(localTableBlogId)}; <START> getWritableDb().delete(PEOPLE_TABLE, "person_id " + <END> "IN (SELECT person_id FROM people ORDER BY display_name DESC LIMIT ?) AND local_blog_id=?", args); } }</code><technical_language>hard-code "people" here, "person_id IN (SELECT person_id " + PEOPLE_TABLE + "WHERE..."</technical_language>

Target:
public static void deletePeopleForLocalBlogIdExceptForFirstPage(int localTableBlogId) { int size = getPeopleCountForLocalBlogId(localTableBlogId); int fetchLimit = PeopleUtils.FETCH_USERS_LIMIT; if (size > fetchLimit) { int deleteCount = size - fetchLimit; String[] args = new String[] { Integer.toString(localTableBlogId), Integer.toString(deleteCount) }; getWritableDb().delete(PEOPLE_TABLE, "local_blog_id=?1 AND person_id " + "IN (SELECT person_id FROM " + PEOPLE_TABLE + " WHERE local_blog_id=?1 " + "ORDER BY display_name DESC LIMIT ?2)", args); } }
Source:
<code>private static String asText(JsonNode node) { <START> if (node.isNull()) { <END> return null; } if (node.isArray()) { String[] arrayTexts = new String[node.size()]; for (int i = 0; i < node.size(); i++) { arrayTexts[i] = asText(node.get(i)); } return Arrays.toString(arrayTexts); } checkState(node.isValueNode()); return node.asText(); }</code><technical_language>is this logic rendering a json array string in this PR</technical_language>

Target:
private static String asText(JsonNode node) { checkState(node.isValueNode()); return node.isNull() ? null : node.asText(); }
Source:
<code>private static boolean validateTextClause(Object clause, Boolean[] textClauseLimitReached) { Map<String, Object> textClause; if (clause instanceof Map) { textClause = (Map<String, Object>) clause; if (textClause.size() == 1) { String operator = (String) textClause.keySet().toArray()[0]; if (operator.equals(SEARCH)) { Object clauseOperand = textClause.get(operator); if (textClauseLimitReached[0]) { String msg = "Multiple text search clauses not allowed in a query. " + "Rewrite query to contain at most one text search clause."; logger.log(Level.SEVERE, msg); } else { textClauseLimitReached[0] = true; return validatePredicateValue(clauseOperand, operator); } } else { String msg = String.format("Invalid operator %s in text search", operator); logger.log(Level.SEVERE, msg); } } } else { String msg = String.format("Text search expects a Map, found %s instead.", clause); logger.log(Level.SEVERE, msg); <START> } <END> return false; }</code><technical_language>structure this a series of tests a nested if/else clause? easy miss return validatePredicateValue(...) in middle. java if (!(clause instanceof Map)) { String msg = String.format("Text search expects a Map, %s instead.", clause); logger.log(Level.SEVERE, msg); return false; } /* etc. */</technical_language>

Target:
private static boolean validateTextClause(Object clause, Boolean[] textClauseLimitReached) { Map<String, Object> textClause; if (!(clause instanceof Map)) { String msg = String.format("Text search expects a Map, found %s instead.", clause); logger.log(Level.SEVERE, msg); return false; } textClause = (Map<String, Object>) clause; if (textClause.size() != 1) { String msg = String.format("Unexpected content %s in text search.", textClause); logger.log(Level.SEVERE, msg); return false; } String operator = (String) textClause.keySet().toArray()[0]; if (!operator.equals(SEARCH)) { String msg = String.format("Invalid operator %s in text search", operator); logger.log(Level.SEVERE, msg); return false; } if (textClauseLimitReached[0]) { logger.log(Level.SEVERE, "Multiple text search clauses not allowed in a query. " + "Rewrite query to contain at most one text search clause."); return false; } textClauseLimitReached[0] = true; return validatePredicateValue(textClause.get(operator), operator); }
Source:
<code>public void applyAttributeMappings(Metacard metacard) { <START> this.attributeMappings = new TreeMap<>(); <END> for (String attrKey : attributeList) { String readableKey = getHumanReadableAttribute(attrKey); Attribute attr = metacard.getAttribute(attrKey); if (attr == null) { this.attributeMappings.put(readableKey, new HtmlEmptyValueModel()); } else if (attrKey.equals("thumbnail")) { byte[] imageData = (byte[]) attr.getValue(); this.attributeMappings.put(readableKey, new HtmlMediaModel(imageData)); } else { this.attributeMappings.put(readableKey, new HtmlBasicValueModel(attr.getValue())); } } }</code><technical_language>this need instantiated again</technical_language>

Target:
public void applyAttributeMappings(Metacard metacard) { this.attributeMappings = new TreeMap<>(); for (String attrKey : attributes) { String readableKey = getHumanReadableAttribute(attrKey); Attribute attr = metacard.getAttribute(attrKey); HtmlValueModel model; if (attr == null) { model = new HtmlEmptyValueModel(); this.attributeMappings.put(readableKey, model); } else if (attrKey.equals(Core.THUMBNAIL)) { byte[] imageData = (byte[]) attr.getValue(); model = new HtmlMediaModel(imageData); } else { model = new HtmlBasicValueModel(attr.getValue()); } this.attributeMappings.put(readableKey, model); } }
Source:
<code>public Map<String, String> createRecordsOnServer(int count, String objectType) throws Exception { Map<String, String> idToValues = new HashMap<String, String>(); for (int i = 0; i < count; i++) { String fieldValue = ""; Map<String, Object> fields = new HashMap<String, Object>(); switch (objectType) { case Constants.ACCOUNT: <START> fieldValue = createRecordName(objectType); <END> fields.put(Constants.NAME, fieldValue); break; case Constants.OPPORTUNITY: fieldValue = createRecordName(objectType); fields.put(Constants.NAME, fieldValue); fields.put("StageName", "Prospecting"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); fields.put("CloseDate", formatter.format(new Date())); break; default: break; } RestRequest request = RestRequest.getRequestForCreate(ApiVersionStrings.getVersionNumber(targetContext), objectType, fields); RestResponse response = restClient.sendSync(request); String id = response.asJSONObject().getString(LID); idToValues.put(id, fieldValue); } return idToValues; }</code><technical_language>This line pulled in line 158</technical_language>

Target:
protected Map<String, String> createRecordsOnServer(int count, String objectType) throws Exception { Map<String, String> idToValues = new HashMap<String, String>(); for (int i = 0; i < count; i++) { String fieldValue = createRecordName(objectType); Map<String, Object> fields = new HashMap<String, Object>(); switch (objectType) { case Constants.ACCOUNT: fields.put(Constants.NAME, fieldValue); break; case Constants.OPPORTUNITY: fields.put(Constants.NAME, fieldValue); fields.put("StageName", "Prospecting"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); fields.put("CloseDate", formatter.format(new Date())); break; default: break; } RestRequest request = RestRequest.getRequestForCreate(ApiVersionStrings.getVersionNumber(targetContext), objectType, fields); RestResponse response = restClient.sendSync(request); assertNotNull("Response should not be null", response); assertTrue("Response status should be success", response.isSuccess()); String id = response.asJSONObject().getString(LID); idToValues.put(id, fieldValue); } return idToValues; }
Source:
<code>public Set<ServerHolder> getAllServers() { <START> final Set<ServerHolder> servers = new HashSet<>(); <END> for (MinMaxPriorityQueue<ServerHolder> queue : cluster.values()) { servers.addAll(queue); } return servers; }</code><technical_language>Is a reason this is a Set? Set suspicious (vs. List) for reasons. - I DruidCluster is meant a single copy of server - ServerHolder equals includes a call LoadQueuePeon.equals, is based reference equality, unreliable dedupe servers</technical_language>

Target:
public List<ServerHolder> getAllServers() { return cluster.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); }
Source:
<code>private void log(final String message) { <START> System.out.println(message); <END> }</code><technical_language>logging removed / disabled merging</technical_language>

Target:
private void log(final String message) { }
Source:
<code>public Key getTopKey() { if (seenSeek == false) throw new IllegalStateException("never been seeked"); <START> return source.getTopKey(); <END> }</code><technical_language>This possibly break iterators extend WrappingIterator override getSource(). I this change. deprecate WrappingIterator introduce another version for users more efficient. I a lot of wiggle room this more efficient possibly breaking user iterators</technical_language>

Target:
public Key getTopKey() { if (seenSeek == false) throw new IllegalStateException("never been seeked"); return getSource().getTopKey(); }
Source:
<code><START> public static void commit(ResourceResolver resourceResolver) { <END> if (resourceResolver == null || !resourceResolver.isLive()) { LOGGER.error("Resource resolver is null or not live while committing resourceResolver"); return; } Session session = resourceResolver.adaptTo(Session.class); if (session == null || !session.isLive()) { LOGGER.error("Resource resolver is null or not live while committing resourceResolver"); return; } try { resourceResolver.refresh(); session.refresh(true); if (resourceResolver.hasChanges()) { resourceResolver.commit(); } if (session.hasPendingChanges()) { session.save(); } } catch (PersistenceException | RepositoryException e) { LOGGER.error("Error occurred while committing resource resolver", e); } }</code><technical_language>In this method commit ResourceResolver JCR Session wrapped RR. Please stick RR omit for JCR session here, necessary (because RR is internally already)</technical_language>

Target:
public static void commit(ResourceResolver resourceResolver) { if (resourceResolver == null || !resourceResolver.isLive()) { LOGGER.error("Resource resolver is null or not live while committing resourceResolver"); return; } try { resourceResolver.refresh(); if (resourceResolver.hasChanges()) { resourceResolver.commit(); } } catch (PersistenceException e) { LOGGER.error("Error occurred while committing resource resolver", e); } }