auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void waitForDeployments() throws MojoFailureException { if (!application.exists()) { <START> throw new MojoFailureException("Application does not exists: " + application); <END> } log.debug("Checking for application [" + application + "] to be deployed."); String app = getApplicationName(application); try { prober.check(AppDeploymentProbe.isDeployed(mule, app)); } catch (AssertionError e) { log.error("Couldn't deploy application [" + app + "] after [" + timeout + "] miliseconds. Check Mule Runtime log"); throw new MojoFailureException("Application deployment timeout."); } }</code><technical_language>please replace MojoExecutionException for a new generic DeploymentExecutionException</technical_language>

Target:
private void waitForDeployments() throws DeploymentException { if (!application.exists()) { throw new DeploymentException("Application does not exists: " + application); } log.debug("Waiting for application [" + application + "] to be deployed."); String app = FilenameUtils.getBaseName(application.getName()); try { prober.check(AppDeploymentProbe.isDeployed(mule, app)); } catch (AssertionError e) { log.error("Couldn't deploy application [" + app + "] after [" + timeout + "] miliseconds. Check Mule Runtime log"); throw new DeploymentException("Application deployment timeout."); } }
Source:
<code>public void unlock() { synchronized (DiskRepository.this) { int count = readLockCount.getAndDecrement(); assert count >= 0; if (fileLock != null && readLockCount.get() == 0) { try { fileLock.release(); } catch (IOException ioe) { LOGGER.warn(ioe, DiskConnectorI18n.problemReleasingFileLock, getSourceName()); } } } <START> lock.unlock(); <END> }</code><technical_language>this in a try-catch-finally, 'lock.unlock()' in finally</technical_language>

Target:
public void unlock() { try { if (fileLock != null) { synchronized (DiskRepository.this) { int count = readLockCount.getAndDecrement(); assert count >= 0; if (readLockCount.get() == 0) { try { fileLock.release(); } catch (IOException ioe) { LOGGER.warn(ioe, DiskConnectorI18n.problemReleasingFileLock, getSourceName()); } } } } } finally { lock.unlock(); } }
Source:
<code>public final boolean incrementToken() throws IOException, IllegalStateException { if (state != null) { restoreState(state); if (scriptOne.length() > 0) { replayTerm(scriptOne); if (scriptTwo.length() == 0) { state = null; } return true; } if (scriptTwo.length() > 0) { replayTerm(scriptTwo); state = null; return true; } throw new <START> IllegalStateException(); <END> } if (!input.incrementToken()) { return false; } boolean matchesBothScripts = hasChars(TranslationTableDictionaries.LATIN_REG) && hasChars(TranslationTableDictionaries.CYR_REG); if (matchesBothScripts) { scriptOne.setLength(0); scriptOne.append(termAtt); translationTable.replaceScriptOne(scriptOne); scriptTwo.setLength(0); scriptTwo.append(termAtt); translationTable.replaceScriptTwo(scriptTwo); if (!TranslationTableDictionaries.LATIN_REG.matcher(scriptOne).find()) { state = captureState(); } else { scriptOne.setLength(0); } if (!TranslationTableDictionaries.CYR_REG.matcher(scriptTwo).find()) { if (state == null) { state = captureState(); } } else { scriptTwo.setLength(0); } } return true; }</code><technical_language>nice add a message exception (new IllegalStateException("some message")) explaining this happen invariant broken. If I understand correctly, this is if a state, of script is empty (probably needs formulated a bit better)</technical_language>

Target:
public final boolean incrementToken() throws IOException, IllegalStateException { if (state != null) { restoreState(state); if (scriptOne.length() > 0) { replayTerm(scriptOne); if (scriptTwo.length() == 0) { state = null; } return true; } if (scriptTwo.length() > 0) { replayTerm(scriptTwo); state = null; return true; } throw new IllegalStateException("state should be null"); } if (!input.incrementToken()) { return false; } boolean matchesBothScripts = hasChars(translationTable.getScript1Reg()) && hasChars(translationTable.getScript2Reg()); if (matchesBothScripts) { scriptOne.setLength(0); scriptOne.append(termAtt); translationTable.replaceScriptOne(scriptOne); scriptTwo.setLength(0); scriptTwo.append(termAtt); translationTable.replaceScriptTwo(scriptTwo); if (!translationTable.getScript1Reg().matcher(scriptOne).find()) { state = captureState(); } else { scriptOne.setLength(0); } if (!translationTable.getScript2Reg().matcher(scriptTwo).find()) { if (state == null) { state = captureState(); } } else { scriptTwo.setLength(0); } } return true; }
Source:
<code>private void storeGlobalPrincipals(Properties properties) { globalPrincipalToPermissions = properties.entrySet().stream() .filter(p -> p.getKey().toString().startsWith(GLOBAL_PROP_PREFIX)) .map(p -> new SimpleEntry<>((String) p.getValue(), (String) p.getKey())) .collect(Collectors.toMap(SimpleEntry::getKey, p -> { String roleString = p.getValue().substring(GLOBAL_PROP_PREFIX.length()); UserRole role = UserRole.valueOf(roleString); <START> if (role == null) { <END> throw new IllegalArgumentException( "Invalid global role " + p.getValue() + " defined for " + p.getKey()); } return role.getPermissions().stream() .map(q -> q.name()).collect(Collectors.toSet()); })); }</code><technical_language>Do need test explicitly role is valid a patron, null get returned in cases</technical_language>

Target:
private void storeGlobalPrincipals(Properties properties) { globalPrincipalToPermissions = properties.entrySet().stream() .filter(p -> p.getKey().toString().startsWith(GLOBAL_PROP_PREFIX)) .map(p -> new SimpleEntry<>((String) p.getValue(), (String) p.getKey())) .collect(Collectors.toMap(SimpleEntry::getKey, p -> { String roleString = p.getValue().substring(GLOBAL_PROP_PREFIX.length()); UserRole role = UserRole.valueOf(roleString); if (role == null || role.isPatronRole()) { throw new IllegalArgumentException( "Invalid global role " + p.getValue() + " defined for " + p.getKey()); } return role.getPermissions().stream() .map(q -> q.name()).collect(Collectors.toSet()); })); }
Source:
<code>protected Map<String, HashSet<String>> findPackageReferences(Collection<String> packages, IProgressMonitor monitor) { IJavaProject jp = JavaCore.create(fProject); HashMap<String, HashSet<String>> pkgsAndUses = new HashMap<>(); IPackageFragment[] frags = PDEJavaHelper.getPackageFragments(jp, Collections.EMPTY_SET, false); <START> SubMonitor subMonitor = SubMonitor.convert(monitor, "", frags.length * 2); END> for (int i = 0; i < frags.length; i++) { if (subMonitor.isCanceled()) { return pkgsAndUses; } subMonitor.subTask( NLS.bind(PDEUIMessages.CalculateUsesOperation_calculatingDirective, frags[i].getElementName())); if (packages.contains(frags[i].getElementName())) { HashSet<String> pkgs = new HashSet<>(); pkgsAndUses.put(frags[i].getElementName(), pkgs); try { findReferences(frags[i].getCompilationUnits(), pkgs, subMonitor.newChild(1), false); findReferences(frags[i].getClassFiles(), pkgs, subMonitor.newChild(1), true); } catch (JavaModelException e) { } } } return pkgsAndUses; }</code><technical_language>two-argument constructor</technical_language>

Target:
protected Map<String, HashSet<String>> findPackageReferences(Collection<String> packages, IProgressMonitor monitor) { IJavaProject jp = JavaCore.create(fProject); HashMap<String, HashSet<String>> pkgsAndUses = new HashMap<>(); IPackageFragment[] frags = PDEJavaHelper.getPackageFragments(jp, Collections.EMPTY_SET, false); SubMonitor subMonitor = SubMonitor.convert(monitor, frags.length * 2); for (int i = 0; i < frags.length; i++) { SubMonitor iterationMonitor = subMonitor.newChild(2); if (iterationMonitor.isCanceled()) { return pkgsAndUses; } iterationMonitor.subTask( NLS.bind(PDEUIMessages.CalculateUsesOperation_calculatingDirective, frags[i].getElementName())); if (packages.contains(frags[i].getElementName())) { HashSet<String> pkgs = new HashSet<>(); pkgsAndUses.put(frags[i].getElementName(), pkgs); try { findReferences(frags[i].getCompilationUnits(), pkgs, iterationMonitor.newChild(1), false); findReferences(frags[i].getClassFiles(), pkgs, iterationMonitor.newChild(1), true); } catch (JavaModelException e) { } } } return pkgsAndUses; }
Source:
<code>public void testCheckBlobCorrupt() throws CorruptObjectException { checker = new ObjectChecker() { @Override public void checkBlob(byte[] raw) throws CorruptObjectException { String in = decode(raw); if (in.contains("secret_key")) { throw new CorruptObjectException("don't add a secret key"); } } }; checker.check(OBJ_BLOB, encodeASCII("key = \"public_key\"")); <START> try { checker.check(OBJ_BLOB, encodeASCII("key = \"secret_key\"")); fail(); } catch (CorruptObjectException expected) { } <END> }</code><technical_language>org.junit.rules.ExpectedException</technical_language>

Target:
public void testCheckBlobCorrupt() throws CorruptObjectException { checker = new ObjectChecker() { @Override public void checkBlob(byte[] raw) throws CorruptObjectException { String in = decode(raw); if (in.contains("secret_key")) { throw new CorruptObjectException("don't add a secret key"); } } }; thrown.expect(CorruptObjectException.class); checker.check(OBJ_BLOB, encodeASCII("key = \"secret_key\"")); }
Source:
<code><START> synchronized Collection<ClientBuffer> safeGetBuffersSnapshot() <END> { return ImmutableList.copyOf(this.buffers.values()); }</code><technical_language>need this more</technical_language>

Target:
private synchronized Collection<ClientBuffer> safeGetBuffersSnapshot() { return ImmutableList.copyOf(this.buffers.values()); }
Source:
<code>public static Map<String, Set<String>> computeTagListFromVarList(EnvVars envVars, final String varList) { HashMap<String, Set<String>> result = new HashMap<>(); List<String> rawTagList = linesToList(varList); for (String tagLine : rawTagList) { List<String> tagList = DatadogUtilities.cstrToList(tagLine); if (tagList.isEmpty()) { continue; } for (int i = 0; i < tagList.size(); i++) { String tag = tagList.get(i).replaceAll(" ", ""); <START> String[] expanded = envVars.expand(tag).split("="); <END> if (expanded.length == 2) { String name = expanded[0]; String value = expanded[1]; Set<String> values = result.containsKey(name) ? result.get(name) : new HashSet<String>(); values.add(value); result.put(name, values); logger.fine(String.format("Emitted tag %s:%s", name, value)); } else if(expanded.length == 1) { String name = expanded[0]; Set<String> values = result.containsKey(name) ? result.get(name) : new HashSet<String>(); values.add(""); result.put(name, values); } else { logger.fine(String.format("Ignoring the tag %s. It is empty.", tag)); } } } return result; }</code><technical_language>do ? confused this function</technical_language>

Target:
public static Map<String, Set<String>> computeTagListFromVarList(EnvVars envVars, final String varList) { HashMap<String, Set<String>> result = new HashMap<>(); List<String> rawTagList = linesToList(varList); for (String tagLine : rawTagList) { List<String> tagList = DatadogUtilities.cstrToList(tagLine); if (tagList.isEmpty()) { continue; } for (int i = 0; i < tagList.size(); i++) { String tag = tagList.get(i).replaceAll(" ", ""); String[] expanded = envVars.expand(tag).split("=", 2); if (expanded.length == 2) { String name = expanded[0]; String value = expanded[1]; Set<String> values = result.containsKey(name) ? result.get(name) : new HashSet<String>(); values.add(value); result.put(name, values); logger.fine(String.format("Emitted tag %s:%s", name, value)); } else if(expanded.length == 1) { String name = expanded[0]; Set<String> values = result.containsKey(name) ? result.get(name) : new HashSet<String>(); values.add(""); result.put(name, values); } else { logger.fine(String.format("Ignoring the tag %s. It is empty.", tag)); } } } return result; }
Source:
<code>public Optional<QueryType> getQueryType() { if (statement instanceof Query) { return Optional.of(SELECT); } else if (statement instanceof Explain) { return Optional.of(EXPLAIN); } else if (statement instanceof ShowCatalogs || statement instanceof ShowCreate || statement instanceof ShowFunctions || statement instanceof ShowGrants || statement instanceof ShowPartitions || statement instanceof ShowSchemas || statement instanceof ShowSession || statement instanceof ShowStats || statement instanceof ShowTables) { return Optional.of(SHOW); } else if (statement instanceof CreateTableAsSelect) { return Optional.of(CREATE); } else if (statement instanceof Insert) { return Optional.of(INSERT); <START> } <END> else if (statement instanceof Delete) { return Optional.of(DELETE); } else if (statement instanceof ShowColumns || statement instanceof DescribeInput || statement instanceof DescribeOutput) { return Optional.of(DESCRIBE); } return Optional.empty(); }</code><technical_language>If I understand correctly, empty basically means other. However, want OTHER create backward-compatibility issues in future. Is correct</technical_language>

Target:
public Optional<QueryType> getQueryType() { if (statement instanceof Query) { return Optional.of(SELECT); } else if (statement instanceof Explain) { return Optional.of(EXPLAIN); } else if (statement instanceof ShowCatalogs || statement instanceof ShowCreate || statement instanceof ShowFunctions || statement instanceof ShowGrants || statement instanceof ShowPartitions || statement instanceof ShowSchemas || statement instanceof ShowSession || statement instanceof ShowStats || statement instanceof ShowTables || statement instanceof ShowColumns || statement instanceof DescribeInput || statement instanceof DescribeOutput) { return Optional.of(DESCRIBE); } else if (statement instanceof CreateTableAsSelect || statement instanceof Insert) { return Optional.of(INSERT); } else if (statement instanceof Delete) { return Optional.of(DELETE); } return Optional.empty(); }
Source:
<code>public Period parse(String value) { <START> <END> int intValue = Integer.parseInt(value); if (ChronoUnit.DAYS == this.chronoUnit) { return Period.ofDays(intValue); } else if (ChronoUnit.WEEKS == this.chronoUnit) { return Period.ofWeeks(intValue); } else if (ChronoUnit.MONTHS == this.chronoUnit) { return Period.ofMonths(intValue); } else if (ChronoUnit.YEARS == this.chronoUnit) { return Period.ofYears(intValue); } throw new IllegalArgumentException("Unknow unit '" + this.chronoUnit + "'"); }</code><technical_language>remove empty line</technical_language>

Target:
public Period parse(String value) { return parse(value, null); }
Source:
<code>public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { String saml2Response = request.getParameter("SAMLResponse"); byte[] b = Saml2Utils.decode(saml2Response); String responseXml = inflateIfRequired(request, b); RelyingPartyRegistration rp = this.relyingPartyRegistrationRepository.findByRegistrationId(this.matcher.matcher(request).getVariables().get("registrationId")); String localSpEntityId = Saml2Utils.getServiceProviderEntityId(rp, request); final Saml2AuthenticationToken authentication = new Saml2AuthenticationToken( responseXml, request.getRequestURL().toString(), rp.getRemoteIdpEntityId(), localSpEntityId, rp.getCredentials() ); <START> return getAuthenticationManager(request).authenticate(authentication); <END> }</code><technical_language>a nervous instance of this filter AuthenticationManager AuthenticationManagerResolver instance. a source of bugs in future. considered pushing AuthenticationManagerResolver instead parent? possibly parent hold instance of AuthenticationManagerResolver getAuthenticationManager(HttpServletRequest) method</technical_language>

Target:
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { String saml2Response = request.getParameter("SAMLResponse"); byte[] b = Saml2Utils.decode(saml2Response); String responseXml = inflateIfRequired(request, b); RelyingPartyRegistration rp = this.relyingPartyRegistrationRepository.findByRegistrationId(this.matcher.matcher(request).getVariables().get("registrationId")); String localSpEntityId = Saml2Utils.getServiceProviderEntityId(rp, request); final Saml2AuthenticationToken authentication = new Saml2AuthenticationToken( responseXml, request.getRequestURL().toString(), rp.getRemoteIdpEntityId(), localSpEntityId, rp.getCredentials() ); return getAuthenticationManager().authenticate(authentication); }
Source:
<code>public void testCreateAnnotation() throws IOException { DocumentModel file = session.createDocumentModel("/testDomain", "testDoc", "File"); file = session.createDocument(file); fetchInvalidations(); String xpath = "file:content"; Annotation annotation = new AnnotationImpl(); annotation.setParentId(file.getId()); annotation.setXpath(xpath); String jsonAnnotation = MarshallerHelper.objectToJson(annotation, CtxBuilder.get()); try (CloseableClientResponse response = getResponse(RequestType.POST, "id/" + file.getId() + "/@annotation", jsonAnnotation)) { assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus()); JsonNode node = mapper.readTree(response.getEntityInputStream()); assertEquals(file.getId(), node.get("parentId").textValue()); <START> assertEquals(xpath, node.get("xpath").textValue()); <END> } }</code><technical_language>This test introducing constants. do refactoring</technical_language>

Target:
public void testCreateAnnotation() throws IOException { DocumentModel file = session.createDocumentModel("/testDomain", "testDoc", "File"); file = session.createDocument(file); fetchInvalidations(); String xpath = "file:content"; Annotation annotation = new AnnotationImpl(); annotation.setParentId(file.getId()); annotation.setXpath(xpath); String jsonAnnotation = MarshallerHelper.objectToJson(annotation, CtxBuilder.get()); try (CloseableClientResponse response = getResponse(RequestType.POST, "id/" + file.getId() + "/@annotation", jsonAnnotation)) { assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus()); JsonNode node = mapper.readTree(response.getEntityInputStream()); assertEquals(file.getId(), node.get(COMMENT_PARENT_ID_FIELD).textValue()); assertEquals(xpath, node.get(ANNOTATION_XPATH).textValue()); } }
Source:
<code>public boolean isRoot() { <START> return source instanceof RequestScope; <END> }</code><technical_language>this more sense parentResource is null parentResource.isEmpty()</technical_language>

Target:
public boolean isRoot() { return parentResource == null; }
Source:
<code>public void testOptimizedFold() { for (int i = 0; i <= Unicode.MAX_RUNE; i++) { int[] orbit = Unicode.optimizedFoldOrbit(i); if (orbit != null) { <START> int r = Unicode.simpleFold(i); <END> int j = 0; while (r != i) { assertEquals(r, orbit[j]); j++; r = Unicode.simpleFold(r); } } else { int r = Unicode.simpleFold(i); assertEquals(r, Unicode.optimizedFoldNonOrbit(i)); assertEquals(i, Unicode.simpleFold(r)); } } }</code><technical_language>Hoist this statement out of if block</technical_language>

Target:
public void testOptimizedFold() { for (int i = 0; i <= Unicode.MAX_RUNE; i++) { int[] orbit = Unicode.optimizedFoldOrbit(i); if (orbit != null) { testOptimizedFoldOrbitCase(i, orbit); } else { testOptimizedFoldNonOrbitCase(i); } } }
Source:
<code>public void test_evaluate_invalid_return_value() { if (SwtTestUtil.isWindows) { return; } final AtomicInteger exception = new AtomicInteger(-1); browser.addProgressListener(new ProgressListener() { @Override public void changed(ProgressEvent event) @Override public void completed(ProgressEvent event) { try { browser.evaluate("return new Date()"); } catch (SWTException e) { exception.set(e.code); } } }); browser.setText("<html><body>HelloWorld</body></html>"); shell.open(); for (int i = 0; i < (loopMultipier * secondsToWaitTillFail); i++) { runLoopTimer(waitMS); if (exception.get() != -1) { if (exception.get() == SWT.ERROR_INVALID_RETURN_VALUE) { return; } else if (exception.get() == SWT.ERROR_FAILED_EVALUATE) { System.err.println("SWT Warning: test_evaluate_invalid_return_value threw wrong exception code." + " Expected ERROR_INVALID_RETURN_VALUE but got ERROR_FAILED_EVALUATE"); return; } else { <START> System.err.println("test_evaluate_invalid_return_value - Invalid exception code : " + exception.get()); <END> } break; } } fail(name.getMethodName() + " failed. This test tests for evaluation to return an invalid return value. An exception should have been returned, but it wasn't. Got: " + exception.get()); }</code><technical_language>fail again</technical_language>

Target:
public void test_evaluate_invalid_return_value() { assumeFalse(webkit1SkipMsg(), isWebkit1); if (SwtTestUtil.isWindows) { return; } final AtomicInteger exception = new AtomicInteger(-1); browser.addProgressListener(new ProgressListener() { @Override public void changed(ProgressEvent event) @Override public void completed(ProgressEvent event) { try { browser.evaluate("return new Date()"); } catch (SWTException e) { exception.set(e.code); } } }); browser.setText("<html><body>HelloWorld</body></html>"); shell.open(); for (int i = 0; i < (loopMultipier * secondsToWaitTillFail); i++) { runLoopTimer(waitMS); if (exception.get() != -1) { if (exception.get() == SWT.ERROR_INVALID_RETURN_VALUE) { return; } else if (exception.get() == SWT.ERROR_FAILED_EVALUATE) { System.err.println("SWT Warning: test_evaluate_invalid_return_value threw wrong exception code." + " Expected ERROR_INVALID_RETURN_VALUE but got ERROR_FAILED_EVALUATE"); return; } else { fail("Invalid exception code : " + exception.get()); } break; } } fail("This test tests for evaluation to return an invalid return value. An exception should have been thrown, but none was thrown. Or test timed out"); }
Source:
<code>DTestNodeTool(boolean withNotifications) { super(new InternalNodeProbeFactory(withNotifications)); <START> storageProxy = InternalNodeProbe.create(withNotifications).getStorageService(); <END> storageProxy.addNotificationListener(notifications, null, null); }</code><technical_language>InternalNodeProbe.create(withNotifications) jmx connection leak</technical_language>

Target:
DTestNodeTool(boolean withNotifications) { super(new InternalNodeProbeFactory(withNotifications)); storageProxy = new InternalNodeProbe(withNotifications).getStorageService(); storageProxy.addNotificationListener(notifications, null, null); }
Source:
<code>private void saveCompletedContribution(Contribution contribution, UploadResult uploadResult) throws ParseException { contribution.setFilename(uploadResult.createCanonicalFileName()); contribution.setImageUrl(uploadResult.getImageinfo().getOriginalUrl()); contribution.setState(Contribution.STATE_COMPLETED); contribution.setDateUploaded(CommonsDateUtil.getIso8601DateFormatTimestamp() .parse(uploadResult.getImageinfo().getTimestamp())); <START> final Disposable disposable = contributionDao.delete(contribution) <END> .flatMap(integer -> mediaClient.getMedia("File:" + uploadResult.getFilename())) .subscribe(media -> contributionDao.save(new Contribution(media))); compositeDisposable.add(disposable); }</code><technical_language>do need this variable? inlined previous code</technical_language>

Target:
private void saveCompletedContribution(Contribution contribution, UploadResult uploadResult) { compositeDisposable.add(mediaClient.getMedia("File:" + uploadResult.getFilename()) .map(media -> new Contribution(media, Contribution.STATE_COMPLETED)) .flatMapCompletable(newContribution -> contributionDao.saveAndDelete(contribution, newContribution)) .subscribe()); }
Source:
<code>public List<?> find(final LdapQueryData queryData, final long resultCount) { final String domainName = queryData.getDomain(); final Domain domain = getDomainObject(domainName); if (domain == null) { log.errorFormat("Error in finding LDAP servers for domain {0} using user {1}", domainName, ldapCredentials.getUserName()); return null; } List<URI> ldapServerURIs = domain.getLdapServers(); <START> List<URI> editableLdapServerURIs = new ArrayList<>(); <END> editableLdapServerURIs.addAll(ldapServerURIs); if (log.isDebugEnabled()) { log.debug("Ldap server list: " + StringUtils.join(ldapServerURIs, ", ")); } List<?> response = null; for (Iterator<URI> iterator = ldapServerURIs.iterator(); iterator.hasNext();) { URI ldapURI = iterator.next(); response = findAndOrderServers(queryData, ldapURI, domainName, resultCount, editableLdapServerURIs); if (response != null) { break; } } domain.setLdapServers(editableLdapServerURIs); return response; }</code><technical_language>new ArrayList<>(ldapServerURIs)</technical_language>

Target:
public List<?> find(final LdapQueryData queryData, final long resultCount) { final String domainName = queryData.getDomain(); final Domain domain = getDomainObject(domainName); if (domain == null) { log.errorFormat("Error in finding LDAP servers for domain {0} using user {1}", domainName, ldapCredentials.getUserName()); return null; } List<URI> ldapServerURIs = domain.getLdapServers(); List<URI> editableLdapServerURIs = new ArrayList<>(ldapServerURIs); if (log.isDebugEnabled()) { log.debug("Ldap server list: " + StringUtils.join(ldapServerURIs, ", ")); } List<?> response = null; for (Iterator<URI> iterator = ldapServerURIs.iterator(); iterator.hasNext();) { URI ldapURI = iterator.next(); response = findAndOrderServers(queryData, ldapURI, domainName, resultCount, editableLdapServerURIs); if (response != null) { break; } } domain.setLdapServers(editableLdapServerURIs); return response; }
Source:
<code>private boolean removeVm(VM vm) { RemoveVmFromPoolParameters removeVmFromPoolParameters = new RemoveVmFromPoolParameters(vm.getId()); removeVmFromPoolParameters.setTransactionScopeOption(TransactionScopeOption.Suppress); VdcReturnValueBase result = runInternalActionWithTasksContext( VdcActionType.RemoveVmFromPool, removeVmFromPoolParameters); if (!result.getSucceeded()) { return false; } result = runInternalAction( VdcActionType.RemoveVm, new RemoveVmParameters(vm.getId(), false), createRemoveVmStepContext(vm)); if (!result.getSucceeded()) { return false; } <START> getTaskIdList().addAll(result.getInternalVdsmTaskIdList()); <END> vmsRemoved.add(vm.getId()); return true; }</code><technical_language>I this is wrong this command is set parent command of internal commands tasks added here. please if is necessary</technical_language>

Target:
private boolean removeVm(VM vm) { RemoveVmFromPoolParameters removeVmFromPoolParameters = new RemoveVmFromPoolParameters(vm.getId()); removeVmFromPoolParameters.setTransactionScopeOption(TransactionScopeOption.Suppress); VdcReturnValueBase result = runInternalActionWithTasksContext( VdcActionType.RemoveVmFromPool, removeVmFromPoolParameters); if (!result.getSucceeded()) { return false; } result = runInternalAction( VdcActionType.RemoveVm, new RemoveVmParameters(vm.getId(), false), createRemoveVmStepContext(vm)); if (!result.getSucceeded()) { return false; } vmsRemoved.add(vm.getId()); return true; }
Source:
<code>protected Connector[] getConnectors(Server server) <START> { <END> SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(_keyStorePath); sslContextFactory.setKeyStorePassword(_keyStorePassword); sslContextFactory.setTrustStorePath(_trustStorePath); sslContextFactory.setTrustStorePassword(_trustStorePassword); HttpConfiguration config = new HttpConfiguration(); config.setSecureScheme(HttpScheme.HTTPS.asString()); config.addCustomizer(new SecureRequestCustomizer()); ServerConnector sslConnector = new ServerConnector(_server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(config)); sslConnector.setPort(_sslPort); Connector[] httpConnectors = super.getConnectors(server); Connector[] connectors = new Connector[httpConnectors.length + 1]; int i = 0; for (Connector c : httpConnectors) { connectors[i++] = c; } connectors[i++] = sslConnector; return connectors; }</code><technical_language>This is rest.li style, parseq is modern style</technical_language>

Target:
protected Connector[] getConnectors(Server server) { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(_keyStorePath); sslContextFactory.setKeyStorePassword(_keyStorePassword); sslContextFactory.setTrustStorePath(_trustStorePath); sslContextFactory.setTrustStorePassword(_trustStorePassword); HttpConfiguration config = new HttpConfiguration(); config.setSecureScheme(HttpScheme.HTTPS.asString()); config.addCustomizer(new SecureRequestCustomizer()); ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(config)); sslConnector.setPort(_sslPort); Connector[] httpConnectors = super.getConnectors(server); Connector[] connectors = Arrays.copyOf(httpConnectors, httpConnectors.length + 1); connectors[httpConnectors.length] = sslConnector; return connectors; }
Source:
<code><START> public boolean equals(Object o) { <END> if (o == null || !(o instanceof CommandConfiguration)) { return false; } CommandConfiguration other = (CommandConfiguration)o; if (this.getName() != null) { if (!this.getName().equals(other.getName())) { return false; } } else { if (other.getName() != null) { return false; } } if (this.getType() != null) { if (!this.getType().getId().equals(other.getType().getId())) { return false; } } else { if (other.getType() != null) { return false; } } if (this.toCommandLine() != null) { if (!this.toCommandLine().equals(other.toCommandLine())) { return false; } } else { if (other.toCommandLine() != null) { return false; } } return true; }</code><technical_language>This method simplified Objects.equals() method. For example: <LINK_0></technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof CommandConfiguration)) { return false; } CommandConfiguration other = (CommandConfiguration)o; return Objects.equals(getName(), other.getName()) && Objects.equals(getType().getId(), other.getType().getId()) && Objects.equals(toCommandLine(), other.toCommandLine()); }
Source:
<code>public void copyInstallResources() { try { getLocation().acquireMutex("installing "+elvis(entity,this), "installation lock at host for files and templates"); getLocation().execCommands("create install directory", ImmutableList.of("mkdir -p " + getInstallDir())); Map<String, String> installFiles = entity.getConfig(SoftwareProcess.INSTALL_FILES); if (installFiles != null && installFiles.size() > 0) { for (String source : installFiles.keySet()) { String target = installFiles.get(source); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getInstallDir(), target); copyResource(source, destination, true); } } Map<String, String> installTemplates = entity.getConfig(SoftwareProcess.INSTALL_TEMPLATES); if (installTemplates != null && installTemplates.size() > 0) { for (String source : installTemplates.keySet()) { String target = installTemplates.get(source); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getInstallDir(), target); copyTemplate(source, destination, true, MutableMap.<String, Object>of()); } } } catch (Exception e) { <START> Exceptions.propagateIfFatal(e); <END> } finally { getLocation().releaseMutex("installing "+elvis(entity,this)); } }</code><technical_language>Log exception, catching ignoring</technical_language>

Target:
public void copyInstallResources() { getLocation().acquireMutex("installing "+elvis(entity,this), "installation lock at host for files and templates"); try { execute("mkdir -p " + getInstallDir(), "create install directory"); Map<String, String> installFiles = entity.getConfig(SoftwareProcess.INSTALL_FILES); if (installFiles != null && installFiles.size() > 0) { for (String source : installFiles.keySet()) { String target = installFiles.get(source); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getInstallDir(), target); copyResource(source, destination, true); } } Map<String, String> installTemplates = entity.getConfig(SoftwareProcess.INSTALL_TEMPLATES); if (installTemplates != null && installTemplates.size() > 0) { for (String source : installTemplates.keySet()) { String target = installTemplates.get(source); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getInstallDir(), target); copyTemplate(source, destination, true, MutableMap.<String, Object>of()); } } } catch (Exception e) { log.warn("Error copying install resources", e); throw Exceptions.propagate(e); } finally { getLocation().releaseMutex("installing "+elvis(entity,this)); } }
Source:
<code>public void testGetValue() { <START> Assert.assertFalse((Boolean)config.GetValue(ConfigValues.NonVmNetworkSupported, "3.0")); <END> Assert.assertFalse(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.0")); Assert.assertTrue((Boolean)config.GetValue(ConfigValues.NonVmNetworkSupported, "3.1")); Assert.assertTrue(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.1")); Assert.assertTrue((Boolean)config.GetValue(ConfigValues.NonVmNetworkSupported, "3.2")); Assert.assertTrue(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.2")); }</code><technical_language>flavor cast (as opposed generic notation redundent - need test casts in Java work :-)</technical_language>

Target:
public void testGetValue() { Assert.assertFalse(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.0")); Assert.assertTrue(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.1")); Assert.assertTrue(Config.<Boolean> GetValue(ConfigValues.NonVmNetworkSupported, "3.2")); }
Source:
<code>private byte[] inferPriorValue(final Bytes key, final byte[] serializedChange) { final byte[] priorValue; if (index.containsKey(key)) { priorValue = internalPriorValueForBuffered(key); } else { <START> final Change<V> change = valueSerde.deserializer().deserialize( <END> changelogTopic, serializedChange ); priorValue = valueSerde.innerSerde().serializer().serialize( changelogTopic, change.oldValue ); } return priorValue; }</code><technical_language>Similarly here, deserialized Changed object need old-value here, I ChangedSerde works skip deserializing new-value</technical_language>

Target:
private byte[] inferPriorValue(final Bytes key, final byte[] serializedChange) { return index.containsKey(key) ? internalPriorValueForBuffered(key) : FullChangeSerde.extractOldValuePart(ByteBuffer.wrap(serializedChange)); }
Source:
<code>public static synchronized void init(Context context) { if (BaseRealm.applicationContext == null) { if (context == null) { throw new IllegalArgumentException("Non-null context required."); } checkFilesDirAvailable(context); RealmCore.loadLibrary(context); setDefaultConfiguration(new RealmConfiguration.Builder(context).build()); ObjectServerFacade.getSyncFacadeIfPossible().init(context); <START> BaseRealm.applicationContext = context; <END> SharedRealm.initialize(new File(context.getFilesDir(), ".realm.temp")); } }</code><technical_language>handle activity context case java BaseRealm.applicationContext = context.getApplicationContext(); if (BaseRealm.applicationContext == null) { BaseRealm.applicationContext = context; } if (BaseRealm.applicationContext == null) { throw new IllegalArgumentException("The context is null"); }</technical_language>

Target:
public static synchronized void init(Context context) { if (BaseRealm.applicationContext == null) { if (context == null) { throw new IllegalArgumentException("Non-null context required."); } checkFilesDirAvailable(context); RealmCore.loadLibrary(context); setDefaultConfiguration(new RealmConfiguration.Builder(context).build()); ObjectServerFacade.getSyncFacadeIfPossible().init(context); if (context.getApplicationContext() != null) { BaseRealm.applicationContext = context.getApplicationContext(); } else { BaseRealm.applicationContext = context; } SharedRealm.initialize(new File(context.getFilesDir(), ".realm.temp")); } }
Source:
<code><START> private Logger getNewLoggingInstance( String name ) <END> { if ( logLevelRecorder == null ) { return new MavenSimpleLogger( name ); } else { return new MavenFailLevelLogger( name, logLevelRecorder ); } }</code><technical_language>I need dive this. is this method called a lot, time check if logLeverRecorder is null, this change. Java 8 MethodReference is answer this</technical_language>

Target:
private Logger getNewLoggingInstance( String name ) { if ( logLevelRecorder == null ) { return new MavenSimpleLogger( name ); } else { return new MavenFailOnSeverityLogger( name, logLevelRecorder ); } }
Source:
<code>private void plugToExternalNetwork() { Provider<?> provider = providerDao.get(getNetwork().getProvidedBy().getProviderId()); String pluginType = <START> StringUtils.defaultString( <END> ((OpenstackNetworkProviderProperties) provider.getAdditionalProperties()).getPluginType()); String hostBindingId = hostProviderBindingDao.get(getVds().getId(), pluginType); Map<String, String> runtimeProperties = getProviderProxy().allocate(getNetwork(), vnicProfile, getParameters().getNic(), getVds(), false, hostBindingId); if (runtimeProperties != null) { getVm().getRuntimeDeviceCustomProperties().put(vmDevice.getId(), runtimeProperties); } }</code><technical_language>please check if this moved hostProviderBindingDao.get()</technical_language>

Target:
private void plugToExternalNetwork() { String pluginType = ((OpenstackNetworkProviderProperties) getProvider() .getAdditionalProperties()).getPluginType(); String hostBindingId = hostProviderBindingDao.get(getVds().getId(), pluginType); Map<String, String> runtimeProperties = getProviderProxy().allocate(getNetwork(), vnicProfile, getParameters().getNic(), getVds(), false, hostBindingId); if (runtimeProperties != null) { getVm().getRuntimeDeviceCustomProperties().put(vmDevice.getId(), runtimeProperties); } }
Source:
<code>protected void onDestroy() { super.onDestroy(); closeInteractiveShell(); tabHandler.close(); utilsHandler.close(); cloudHandler.close(); <START> if (mCloudCursorData != null) mCloudCursorData.close(); <END> CryptHandler cryptHandler = new CryptHandler(this); cryptHandler.close(); SshConnectionPool.getInstance().expungeAllConnections(); }</code><technical_language>Closing this cursor is undefined behaviour, can't</technical_language>

Target:
protected void onDestroy() { super.onDestroy(); closeInteractiveShell(); tabHandler.close(); utilsHandler.close(); cloudHandler.close(); CryptHandler cryptHandler = new CryptHandler(this); cryptHandler.close(); SshConnectionPool.getInstance().expungeAllConnections(); }
Source:
<code>private void makeRequestAndVerify(String expected) throws IOException, SAXException { WebRequest req = new WebRequest(new URL(j.getURL(), "test-post")); req.setHttpMethod(HttpMethod.POST); req.setEncodingType(null); Page p = wc.getPage(req); <START> assertEquals(expected, p.getWebResponse().getContentAsString().trim()); <END> }</code><technical_language>BTW trim unnecessary text plainText</technical_language>

Target:
private void makeRequestAndVerify(String expected) throws IOException, SAXException { WebRequest req = new WebRequest(new URL(j.getURL(), "test-post")); req.setHttpMethod(HttpMethod.POST); req.setEncodingType(null); Page p = wc.getPage(req); assertEquals(expected, p.getWebResponse().getContentAsString()); }
Source:
<code>public synchronized Cluster getCluster(String clusterId, String zoneId) { Cluster response = null; for (Cluster cluster : getClusters().getClustersList()) { if (cluster.getName().endsWith("/clusters/" + clusterId) && cluster.getLocation().endsWith("/locations/" + zoneId)) { if (response == null) { response = cluster; } else { throw new IllegalStateException( String.format("Got multiple clusters named %s in the %z zone.", clusterId, zoneId)); } } } <START> return Preconditions.checkNotNull(response, "Cluster " + clusterId + " was not found"); <END> }</code><technical_language>calling this out another place helpful log zone</technical_language>

Target:
public synchronized Cluster getCluster(String clusterId, String zoneId) { Cluster response = null; for (Cluster cluster : getClusters().getClustersList()) { if (cluster.getName().endsWith("/clusters/" + clusterId) && cluster.getLocation().endsWith("/locations/" + zoneId)) { if (response == null) { response = cluster; } else { throw new IllegalStateException( String.format("Got multiple clusters named %s in zone %z.", clusterId, zoneId)); } } } return Preconditions.checkNotNull(response, String.format("Cluster %s in zone %s was not found.", clusterId, zoneId)); }
Source:
<code>public PackageId(String group, String name, Version version) { fromPath = false; <START> if (group == null || group.equals(ETC_PACKAGES)) { <END> group = ""; } else if (group.startsWith(ETC_PACKAGES_PREFIX)) { group = group.substring(ETC_PACKAGES_PREFIX.length()); } else if (group.startsWith("/")) { group = group.substring(1); } this.group = group; if (name == null) name = ""; this.name = name; this.version = version == null ? Version.EMPTY : version; this.str = getString(this.group, name, this.version); }</code><technical_language>this change is related issue</technical_language>

Target:
public PackageId(String group, String name, Version version) { fromPath = false; if (group.equals(ETC_PACKAGES)) { group = ""; } else if (group.startsWith(ETC_PACKAGES_PREFIX)) { group = group.substring(ETC_PACKAGES_PREFIX.length()); } else if (group.startsWith("/")) { group = group.substring(1); } this.group = group; this.name = name; this.version = version == null ? Version.EMPTY : version; this.str = getString(this.group, name, this.version); }
Source:
<code><START> private void createJobToMonitor(VDSGroup cluster, GlusterAsyncTask task) { <END> if (task.getStatus() != JobExecutionStatus.STARTED) { return; } StepEnum step = task.getType().getStep(); VdcActionType actionType; switch (step) { case REBALANCING_VOLUME: actionType = VdcActionType.StartRebalanceGlusterVolume; break; default: actionType = VdcActionType.Unknown; } VdcReturnValueBase result = getBackend().runInternalAction(VdcActionType.AddInternalJob, new AddInternalJobParameters(ExecutionMessageDirector.resolveJobMessage(actionType, getMessageMap(cluster, task)), actionType, true) ); if (!result.getSucceeded()) { throw new VdcBLLException(result.getFault().getError()); } Guid jobId = (Guid)result.getActionReturnValue(); result = getBackend().runInternalAction(VdcActionType.AddInternalStep, new AddStepParameters(jobId, ExecutionMessageDirector.resolveStepMessage(StepEnum.EXECUTING, null), StepEnum.EXECUTING)); if (!result.getSucceeded()) { throw new VdcBLLException(result.getFault().getError()); } Guid execStepId = (Guid)result.getActionReturnValue(); result = getBackend().runInternalAction(VdcActionType.AddInternalStep, new AddStepParameters(execStepId, getTaskMessage(cluster, step, task), step)); if (!result.getSucceeded()) { throw new VdcBLLException(result.getFault().getError()); } Guid asyncStepId = (Guid)result.getActionReturnValue(); Step asyncStep = getStepDao().get(asyncStepId); ExecutionHandler.updateStepExternalId(asyncStep, task.getTaskId(), ExternalSystemType.GLUSTER); }</code><technical_language>break this method in smaller modular ones? Similar code is executed</technical_language>

Target:
private void createJobToMonitor(VDSGroup cluster, GlusterAsyncTask task) { if (task.getStatus() != JobExecutionStatus.STARTED) { return; } StepEnum step = task.getType().getStep(); VdcActionType actionType; switch (step) { case REBALANCING_VOLUME: actionType = VdcActionType.StartRebalanceGlusterVolume; break; default: actionType = VdcActionType.Unknown; } Guid jobId = addJob(cluster, task, actionType); Guid execStepId = addExecutingStep(jobId); Guid asyncStepId = addAsyncTaskStep(cluster, task, step, execStepId); Step asyncStep = getStepDao().get(asyncStepId); ExecutionHandler.updateStepExternalId(asyncStep, task.getTaskId(), ExternalSystemType.GLUSTER); }
Source:
<code>public String toString() { <START> return "skadi(" + baseUrl + ")"; <END> }</code><technical_language>Due consistency I return "skadi"</technical_language>

Target:
public String toString() { return "skadi"; }
Source:
<code>private void mountAsEnv(E env, Secret secret, String targetContainerName) throws InfrastructureException { <START> for (PodData pd : env.getPodsData().values()) { <END> if (!pd.getRole().equals(PodRole.DEPLOYMENT)) { continue; } for (Container c : pd.getSpec().getContainers()) { if (targetContainerName != null && !c.getName().equals(targetContainerName)) { continue; } for (Entry<String, String> entry : secret.getData().entrySet()) { final String mountEnvName = envName(secret, entry.getKey()); c.getEnv() .add( new EnvVarBuilder() .withName(mountEnvName) .withValueFrom( new EnvVarSourceBuilder() .withSecretKeyRef( new SecretKeySelectorBuilder() .withName(secret.getMetadata().getName()) .withKey(entry.getKey()) .build()) .build()) .build()); } } } }</code><technical_language>please full names ? podData, container, ..</technical_language>

Target:
private void mountAsEnv(E env, Secret secret, String targetContainerName) throws InfrastructureException { for (PodData podData : env.getPodsData().values()) { if (!podData.getRole().equals(PodRole.DEPLOYMENT)) { continue; } for (Container container : podData.getSpec().getContainers()) { if (targetContainerName != null && !container.getName().equals(targetContainerName)) { continue; } for (Entry<String, String> secretDataEntry : secret.getData().entrySet()) { final String mountEnvName = envName(secret, secretDataEntry.getKey()); container .getEnv() .add( new EnvVarBuilder() .withName(mountEnvName) .withValueFrom( new EnvVarSourceBuilder() .withSecretKeyRef( new SecretKeySelectorBuilder() .withName(secret.getMetadata().getName()) .withKey(secretDataEntry.getKey()) .build()) .build()) .build()); } } } }
Source:
<code>private List<T> loadInstances(ClassLoader classloader) { ServiceLoader<T> loader = ServiceLoader.load( clazz, classloader ); Iterator<T> iterator = loader.iterator(); List<T> instances = new ArrayList<T>(); while ( iterator.hasNext() ) { try { instances.add( iterator.next() ); } catch (ServiceConfigurationError e) { <START> LOG.error( "Error while loading Instances {}",e ); <END> } } return instances; }</code><technical_language>This message included in Log class (with a parameter for service name a @Cause, tons of examples in code). message "An error occurred while loading instance of service <service class>."</technical_language>

Target:
private List<T> loadInstances(ClassLoader classloader) { ServiceLoader<T> loader = ServiceLoader.load( clazz, classloader ); Iterator<T> iterator = loader.iterator(); List<T> instances = new ArrayList<T>(); while ( iterator.hasNext() ) { try { instances.add( iterator.next() ); } catch (ServiceConfigurationError e) { LOG.getServiceConfigurationErrorException( loader.getClass().getName(), e ); } } return instances; }
Source:
<code>public PDFDocumentImpl(PDDocument document) { <START> this.document = document; <END> }</code><technical_language>check for null</technical_language>

Target:
public PDFDocumentImpl(PDDocument document) { if (document == null) { throw new IllegalArgumentException("Document representation can not be null"); } this.document = document; }