auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testContainsAnyIgnoreCase_StringStringArray() { assertFalse(StringUtils.containsAnyIgnoreCase(null, (String[]) null)); <START> assertFalse(StringUtils.containsAnyIgnoreCase(null, new String[0])); assertFalse(StringUtils.containsAnyIgnoreCase(null, new String[] { "hello" })); <END> assertFalse(StringUtils.containsAnyIgnoreCase("", (String[]) null)); assertFalse(StringUtils.containsAnyIgnoreCase("", new String[0])); assertFalse(StringUtils.containsAnyIgnoreCase("", new String[] { "hello" })); assertFalse(StringUtils.containsAnyIgnoreCase("hello, goodbye", (String[]) null)); assertFalse(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[0])); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"hello", "goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"hello", "Goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"Hello", "Goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"Hello", null})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, null", new String[] { "Hello", null })); assertTrue(StringUtils.containsAnyIgnoreCase("abcd", "AB", null)); assertTrue(StringUtils.containsAnyIgnoreCase("abcd", "ab", "CD")); assertTrue(StringUtils.containsAnyIgnoreCase("abc", "D", "abc")); assertFalse(StringUtils.containsAnyIgnoreCase("abc", "d", "efg")); }</code><technical_language>short-circuit condition assertion redundant</technical_language>

Target:
public void testContainsAnyIgnoreCase_StringStringArray() { assertFalse(StringUtils.containsAnyIgnoreCase("", (String[]) null)); assertFalse(StringUtils.containsAnyIgnoreCase("", new String[0])); assertFalse(StringUtils.containsAnyIgnoreCase("", new String[] { "hello" })); assertFalse(StringUtils.containsAnyIgnoreCase("hello, goodbye", (String[]) null)); assertFalse(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[0])); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"hello", "goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"hello", "Goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"Hello", "Goodbye"})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, goodbye", new String[]{"Hello", null})); assertTrue(StringUtils.containsAnyIgnoreCase("hello, null", new String[] { "Hello", null })); assertTrue(StringUtils.containsAnyIgnoreCase("abcd", "AB", null)); assertTrue(StringUtils.containsAnyIgnoreCase("abcd", "ab", "CD")); assertTrue(StringUtils.containsAnyIgnoreCase("abc", "D", "abc")); assertFalse(StringUtils.containsAnyIgnoreCase("abc", "d", "efg")); }
Source:
<code>public StringBuffer format(double x, StringBuffer sb) { <START> StringBuffer temp = new StringBuffer(); <END> if ((Math.abs(x) >= DECIMAL_MIN && x < DECIMAL_MAX) || x == 0) { x = truncate(x); long lx = (long) x; if (lx == x) { temp.append(lx); } else { temp.append(x); } } else { if (forcedDecimal) { coordFormatter.format(x, temp, ZERO); } else { temp.append(truncate(x)); } } return sb.append(eventuallyPad(temp)); }</code><technical_language>This allocation happens, is required? work original sb</technical_language>

Target:
public StringBuffer format(double x, StringBuffer sb) { String formatted; if ((Math.abs(x) >= DECIMAL_MIN && x < DECIMAL_MAX) || x == 0) { x = truncate(x); long lx = (long) x; if (lx == x) { formatted = lx + ""; } else { formatted = x + ""; } } else { if (forcedDecimal) { StringBuffer temp = new StringBuffer(); coordFormatter.format(x, temp, ZERO); formatted = temp.toString(); } else { formatted = truncate(x) + ""; } } return sb.append(zeroPad(formatted)); }
Source:
<code>public IClientRouter addClient(IClient client) { client.setRouter(this); <START> try { client.getHandledTypes().stream() .forEach(x -> { handlerMap.put(x, client); log.info("Registered client to handle messages of type {}", x); }); } catch (Exception ex) { } <END> clientList.add(client); return this; }</code><technical_language>Is exception expected thrown getHandledTypes() returns empty set? I thought if explicitly check if (client.getHandledTypes().isEmpty()) log warn/info. 100% throw exception pass silently if streaming collection is empty</technical_language>

Target:
public IClientRouter addClient(IClient client) { client.setRouter(this); try { client.getHandledTypes().stream() .forEach(x -> { handlerMap.put(x, client); log.info("Registered client to handle messages of type {}", x); }); } catch (UnsupportedOperationException ex) { log.error("No registered CorfuMsg handler for client {}", client, ex); } clientList.add(client); return this; }
Source:
<code>private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) { for (CredentialsStore store : CredentialsProvider.lookupStores(object)) { if (!store.hasPermission(CredentialsProvider.VIEW)) { continue; } ModelObject storeContext = store.getContext(); for (Domain domain : store.getDomains()) { Credentials match = CredentialsMatchers .firstOrNull(store.getCredentials(domain), CredentialsMatchers.withId(value)); if (match != null) { if (storeContext == context) { return FormValidation.error("This ID is already in use"); } else { if (match.getScope() == CredentialsScope.SYSTEM) { <START> continue; <END> } return FormValidation.warning("The ID ‘%s’ is already in use in %s", value, storeContext instanceof Item ? ((Item) storeContext).getFullDisplayName() : storeContext.getDisplayName()); } } } } return null; }</code><technical_language>continue other credentials in domain then? firstOrNull skips others I</technical_language>

Target:
private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) { CredentialsMatcher withId = CredentialsMatchers.withId(value); for (CredentialsStore store : CredentialsProvider.lookupStores(object)) { if (!store.hasPermission(CredentialsProvider.VIEW)) { continue; } ModelObject storeContext = store.getContext(); for (Domain domain : store.getDomains()) { for (Credentials match : CredentialsMatchers.filter(store.getCredentials(domain), withId)) { if (storeContext == context) { return FormValidation.error("This ID is already in use"); } else { CredentialsScope scope = match.getScope(); if (scope != null && !scope.isVisible(context)) { continue; } return FormValidation.warning("The ID ‘%s’ is already in use in %s", value, storeContext instanceof Item ? ((Item) storeContext).getFullDisplayName() : storeContext.getDisplayName()); } } } } return null; }
Source:
<code>public int hashCode() { <START> return HashUtil.combineHashCodes(slaDueDate.hashCode()); <END> }</code><technical_language>Objects.hashCode</technical_language>

Target:
public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(slaDueDate)); }
Source:
<code>public JSONObject toJSON() throws JSONException { <START> final JSONObject rv = new JSONObject(); <END> rv.put("format", format.ordinal()); rv.put("plainLat", plainLat); rv.put("plainLon", plainLon); rv.put("latHemisphere", latHemisphere); rv.put("lonHemisphere", lonHemisphere); { final JSONArray array = new JSONArray(); for (final CalculateButton.ButtonData but : buttons) { array.put(but.toJASON()); } rv.put("buttons", array); } { final JSONArray array = new JSONArray(); for (final CalculatorVariable.VariableData equ : equations) { array.put(equ.toJSON()); } rv.put("equations", array); } { final JSONArray array = new JSONArray(); for (final CalculatorVariable.VariableData equ : freeVariables) { array.put(equ.toJSON()); } rv.put("freeVariables", array); } rv.put("notes", notes); return rv; }</code><technical_language>rv is descriptive</technical_language>

Target:
public JSONObject toJSON() throws JSONException { final JSONObject returnValue = new JSONObject(); returnValue.put("format", format.ordinal()); returnValue.put("plainLat", plainLat); returnValue.put("plainLon", plainLon); returnValue.put("latHemisphere", latHemisphere); returnValue.put("lonHemisphere", lonHemisphere); returnValue.put("buttons", toJSON(buttons)); returnValue.put("equations", toJSON(equations)); returnValue.put("freeVariables", toJSON(freeVariables)); returnValue.put("notes", notes); return returnValue; }
Source:
<code>public void run(InputStream inputStream) { try (Scanner scanner = new Scanner(inputStream)) { while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.equals("stop")) { <START> commandSender.printInfo(TextComponent.of("Stopping!")); <END> break; } CommandEvent event = new CommandEvent(commandSender, line); WorldEdit.getInstance().getEventBus().post(event); if (!event.isCancelled()) { commandSender.printError(TextComponent.of("Unknown command!")); } else { saveAllWorlds(false); } } } finally { saveAllWorlds(false); } }</code><technical_language>localization keys for these</technical_language>

Target:
public void run(InputStream inputStream) { try (Scanner scanner = new Scanner(inputStream)) { while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.equals("stop")) { commandSender.printInfo(TranslatableComponent.of("worldedit.cli.stopping")); break; } CommandEvent event = new CommandEvent(commandSender, line); WorldEdit.getInstance().getEventBus().post(event); if (!event.isCancelled()) { commandSender.printError(TranslatableComponent.of("worldedit.cli.unknown-command")); } else { saveAllWorlds(false); } } } finally { saveAllWorlds(false); } }
Source:
<code>private boolean provideJavaClasses(IPluginModelBase[] models, IProgressMonitor monitor) { try { IProject project = fModel.getUnderlyingResource().getProject(); if (!project.hasNature(JavaCore.NATURE_ID)) return false; IJavaProject jProject = JavaCore.create(project); IPackageFragment[] packageFragments = PluginJavaSearchUtil.collectPackageFragments(models, jProject, true); SearchEngine engine = new SearchEngine(); IJavaSearchScope searchScope = PluginJavaSearchUtil.createSeachScope(jProject); <START> SubMonitor subMonitor = SubMonitor.convert(monitor, "", packageFragments.length * 2); END> for (int i = 0; i < packageFragments.length; i++) { IPackageFragment pkgFragment = packageFragments[i]; if (pkgFragment.hasChildren()) { Requestor requestor = new Requestor(); engine.search(SearchPattern.createPattern(pkgFragment, IJavaSearchConstants.REFERENCES), new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, searchScope, requestor, subMonitor.newChild(1)); if (requestor.foundMatches()) { if (provideJavaClasses(packageFragments[i], engine, searchScope, subMonitor.newChild(1))) { return true; } } else subMonitor.worked(1); } else { subMonitor.worked(2); } } } catch (CoreException e) { } return false; }</code><technical_language>2-arg constructor</technical_language>

Target:
private boolean provideJavaClasses(IPluginModelBase[] models, IProgressMonitor monitor) { try { IProject project = fModel.getUnderlyingResource().getProject(); if (!project.hasNature(JavaCore.NATURE_ID)) return false; IJavaProject jProject = JavaCore.create(project); IPackageFragment[] packageFragments = PluginJavaSearchUtil.collectPackageFragments(models, jProject, true); SearchEngine engine = new SearchEngine(); IJavaSearchScope searchScope = PluginJavaSearchUtil.createSeachScope(jProject); SubMonitor subMonitor = SubMonitor.convert(monitor, packageFragments.length * 2); for (int i = 0; i < packageFragments.length; i++) { SubMonitor iterationMonitor = subMonitor.newChild(2); IPackageFragment pkgFragment = packageFragments[i]; if (pkgFragment.hasChildren()) { Requestor requestor = new Requestor(); engine.search(SearchPattern.createPattern(pkgFragment, IJavaSearchConstants.REFERENCES), new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, searchScope, requestor, iterationMonitor.newChild(1)); if (requestor.foundMatches()) { if (provideJavaClasses(packageFragments[i], engine, searchScope, iterationMonitor.newChild(1))) { return true; } } } } } catch (CoreException e) { PDEPlugin.logException(e); } return false; }
Source:
<code>private void prepareBuffer() { if (bufferToSend == null) { bufferToSend = ByteBuffer.allocate(sizeExcludingBlobAndCrcSize()); writeHeader(); int crcStart = bufferToSend.position(); bufferToSend.put(blobId.toBytes()); <START> BlobPropertiesSerDe.serializeBlobProperties(bufferToSend, properties); <END> bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.putShort((short) blobType.ordinal()); short keyLength = blobEncryptionKey == null ? 0 : (short) blobEncryptionKey.remaining(); bufferToSend.putShort(keyLength); if (keyLength > 0) { bufferToSend.put(blobEncryptionKey); } bufferToSend.putLong(blobSize); crc.update(bufferToSend.array(), bufferToSend.arrayOffset() + crcStart, bufferToSend.position() - crcStart); nioBuffersFromBlob = blob.nioBuffers(); for (ByteBuffer bb : nioBuffersFromBlob) { crc.update(bb); bb.position(0); } crcBuf.putLong(crc.getValue()); crcBuf.flip(); bufferToSend.flip(); } }</code><technical_language>Is convert BlobProperties userMeatadata bytebuf first, Bytebuf bufferToSend</technical_language>

Target:
private void prepareBuffer() { bufferToSend = ByteBuffer.allocate(sizeExcludingBlobAndCrcSize()); writeHeader(); int crcStart = bufferToSend.position(); bufferToSend.put(blobId.toBytes()); BlobPropertiesSerDe.serializeBlobProperties(bufferToSend, properties); bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.putShort((short) blobType.ordinal()); short keyLength = blobEncryptionKey == null ? 0 : (short) blobEncryptionKey.remaining(); bufferToSend.putShort(keyLength); if (keyLength > 0) { bufferToSend.put(blobEncryptionKey); } bufferToSend.putLong(blobSize); crc.update(bufferToSend.array(), bufferToSend.arrayOffset() + crcStart, bufferToSend.position() - crcStart); nioBuffersFromBlob = blob.nioBuffers(); for (ByteBuffer bb : nioBuffersFromBlob) { crc.update(bb); bb.position(0); } crcBuf.putLong(crc.getValue()); crcBuf.flip(); bufferToSend.flip(); }
Source:
<code>public Map<String, Object> getSpecificEventStyle(ITimeEvent event) { Map<String, Object> map = new HashMap<>(super.getSpecificEventStyle(event)); if (isType(event.getEntry(), Type.CURRENT_THREAD) && event instanceof TimeEvent) { int threadEventValue = ((TimeEvent) event).getValue(); RGBAColor color = PALETTE.get(Math.floorMod(threadEventValue + COLOR_DIFFERENCIATION_FACTOR, NUM_COLORS)); map.put(StyleProperties.BACKGROUND_COLOR, <START> X11ColorUtils.toHexColor(color.getRed(), <END> color.getGreen(), color.getBlue())); map.put(StyleProperties.STYLE_NAME, String.valueOf(threadEventValue)); } else if (event.getEntry() instanceof TimeGraphEntry && ((TimeGraphEntry) event.getEntry()).getEntryModel() instanceof ITimeGraphEntryModelWeighted) { ITimeGraphEntryModelWeighted model = (ITimeGraphEntryModelWeighted) ((TimeGraphEntry) event.getEntry()).getEntryModel(); int eventValue = ((TimeEvent) event).getValue(); map.put(StyleProperties.HEIGHT, (float) model.getWeight(eventValue)); } return map; }</code><technical_language>ColorUtils</technical_language>

Target:
public Map<String, Object> getSpecificEventStyle(ITimeEvent event) { Map<String, Object> map = new HashMap<>(super.getSpecificEventStyle(event)); if (isType(event.getEntry(), Type.CURRENT_THREAD) && event instanceof TimeEvent) { int threadEventValue = ((TimeEvent) event).getValue(); RGBAColor color = PALETTE.get(Math.floorMod(threadEventValue + COLOR_DIFFERENCIATION_FACTOR, NUM_COLORS)); map.put(StyleProperties.BACKGROUND_COLOR, ColorUtils.toHexColor(color.getRed(), color.getGreen(), color.getBlue())); map.put(StyleProperties.STYLE_NAME, String.valueOf(threadEventValue)); } else if (event.getEntry() instanceof TimeGraphEntry && ((TimeGraphEntry) event.getEntry()).getEntryModel() instanceof ITimeGraphEntryModelWeighted) { ITimeGraphEntryModelWeighted model = (ITimeGraphEntryModelWeighted) ((TimeGraphEntry) event.getEntry()).getEntryModel(); int eventValue = ((TimeEvent) event).getValue(); map.put(StyleProperties.HEIGHT, (float) model.getWeight(eventValue)); } return map; }
Source:
<code>public String toString() { return "KafkaSupervisorSpec{" + "dataSchema=" + getDataSchema() + ", tuningConfig=" + getTuningConfig() + ", ioConfig=" + getIoConfig() + <START> '}'; <END> }</code><technical_language>include context suspend</technical_language>

Target:
public String toString() { return "KafkaSupervisorSpec{" + "dataSchema=" + getDataSchema() + ", tuningConfig=" + getTuningConfig() + ", ioConfig=" + getIoConfig() + ", context=" + getContext() + ", suspend=" + isSuspended() + '}'; }
Source:
<code>protected Map<String, Pair<String, String>> getExclusiveLocks() { return Collections.singletonMap(getVmTemplateId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, <START> EngineMessage.VM_TEMPLATE_IS_LOCKED)); <END> }</code><technical_language>add a more informative message explains template is locked</technical_language>

Target:
protected Map<String, Pair<String, String>> getExclusiveLocks() { Map<String, Pair<String, String>> locks = new HashMap<>(); locks.put(getVmTemplateId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, EngineMessage.VM_TEMPLATE_SYSPREP_IS_RUNNING)); getDiskImages().forEach(diskImage -> locks.put(diskImage.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, EngineMessage.VM_TEMPLATE_SYSPREP_IS_RUNNING))); return locks; }
Source:
<code>public void waitForView(int viewId) { if (channel == null) return; log.tracef("Waiting on view %d being accepted", viewId); viewUpdateLock.lock(); try { while (channel != null && this.getViewId() < viewId) { try { viewUpdateCondition.await(); } catch (InterruptedException e) { <START> log.interruptedWaitingForCoordinator(e); <END> } } } finally { viewUpdateLock.unlock(); } }</code><technical_language>if is exception. IMO, throw InterruptedException instead of ignoring it</technical_language>

Target:
public void waitForView(int viewId) throws InterruptedException { if (channel == null) return; log.tracef("Waiting on view %d being accepted", viewId); viewUpdateLock.lock(); try { while (channel != null && this.getViewId() < viewId) { viewUpdateCondition.await(); } } finally { viewUpdateLock.unlock(); } }
Source:
<code>public void testExactMatchBeforeCoercion() { TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = createFunctionRegistry(typeManager); boolean foundOperator = false; for (SqlFunction function : registry.listOperators()) { OperatorType operatorType = unmangleOperator(function.getSignature().getName()); <START> if (operatorType == CAST || operatorType == OperatorType.SATURATED_FLOOR_CAST) { <END> continue; } if (!function.getSignature().getTypeVariableConstraints().isEmpty()) { continue; } if (function.getSignature().getArgumentTypes().stream().anyMatch(TypeSignature::isCalculated)) { continue; } FunctionHandle exactOperator = registry.resolveOperator(operatorType, resolveTypes(function.getSignature().getArgumentTypes(), typeManager)); assertEquals(exactOperator.getSignature(), function.getSignature()); foundOperator = true; } assertTrue(foundOperator); }</code><technical_language>hmmmm... OperatorType other omitted proper</technical_language>

Target:
public void testExactMatchBeforeCoercion() { TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = createFunctionRegistry(typeManager); boolean foundOperator = false; for (SqlFunction function : registry.listOperators()) { OperatorType operatorType = unmangleOperator(function.getSignature().getName()); if (operatorType == CAST || operatorType == SATURATED_FLOOR_CAST) { continue; } if (!function.getSignature().getTypeVariableConstraints().isEmpty()) { continue; } if (function.getSignature().getArgumentTypes().stream().anyMatch(TypeSignature::isCalculated)) { continue; } FunctionHandle exactOperator = registry.resolveOperator(operatorType, resolveTypes(function.getSignature().getArgumentTypes(), typeManager)); assertEquals(exactOperator.getSignature(), function.getSignature()); foundOperator = true; } assertTrue(foundOperator); }
Source:
<code>protected void okPressed() { boolean copyAsLink = false; <START> if(fCopyLinkButton != null) { <END> copyAsLink = fCopyLinkButton.getSelection(); } IResource trace = copyTrace(fNewTraceName.getText(), copyAsLink); if (trace == null) { return; } setSelectionResult(new IResource[] { trace }); super.okPressed(); }</code><technical_language>Missing space. shortened as: copyAsLink = null && is selected;</technical_language>

Target:
protected void okPressed() { boolean copyAsLink = fCopyLinkButton != null ? fCopyLinkButton.getSelection() : false; IResource trace = copyTrace(fNewTraceName.getText(), copyAsLink); if (trace == null) { return; } setSelectionResult(new IResource[] { trace }); super.okPressed(); }
Source:
<code><START> private TryBackToAllSnapshotsOfVmParameters(Guid <END> vmId, Guid dstSnapshotId, boolean restoreMemory) { this(vmId, dstSnapshotId); this.restoreMemory = restoreMemory; }</code><technical_language>why? If this ctor called publicly (should?) inlined, this scope of **this** patch. do in a separate please</technical_language>

Target:
public TryBackToAllSnapshotsOfVmParameters(Guid vmId, Guid dstSnapshotId, boolean restoreMemory) { this(vmId, dstSnapshotId); this.restoreMemory = restoreMemory; }
Source:
<code>private static String msg(byte[] bytes, int offset, int length) { try { return MessageFormat.format( JGitText.get().invalidId, <START> new String(bytes, offset, length, "US-ASCII")); END> } catch (UnsupportedEncodingException | StringIndexOutOfBoundsException e) { return JGitText.get().invalidId0; } }</code><technical_language>While mildly-related cleanup in this method, consider StandardCharsets.US_ASCII</technical_language>

Target:
private static String msg(byte[] bytes, int offset, int length) { try { return MessageFormat.format( JGitText.get().invalidId, new String(bytes, offset, length, US_ASCII)); } catch (StringIndexOutOfBoundsException e) { return JGitText.get().invalidId0; } }
Source:
<code>protected static void validateNameIdFormatValue(final String format, final String value) throws WSSecurityException { if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_EMAIL_ADDRESS.equals(format)) { <START> emailValidator(value); <END> } else if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_X509.equals(format)) { nameValidator(value); } else if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_WINDOWS_NAME.equals(format)) { partsValidator(value); } }</code><technical_language>rename comply java standard name convention. validateEmail</technical_language>

Target:
protected static void validateNameIdFormatValue(final String format, final String value) throws WSSecurityException { if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_EMAIL_ADDRESS.equals(format)) { validateEmail(value); } else if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_X509.equals(format)) { validateName(value); } else if (NhincConstants.AUTH_FRWK_NAME_ID_FORMAT_WINDOWS_NAME.equals(format)) { validateParts(value); } }
Source:
<code>private boolean checkElementSeparator(Collection<AbstractConfigNode> nodes) { if (flavor == ConfigSyntax.JSON) { Token t = nextTokenIgnoringWhitespace(nodes); if (t == Tokens.COMMA) { nodes.add(new ConfigNodeSingleToken(t)); return true; } else { putBack(t); return false; } } else { boolean sawSeparatorOrNewline = false; Token t = nextToken(); while (true) { if (Tokens.isIgnoredWhitespace(t) || isUnquotedWhitespace(t)) { } else if (Tokens.isComment(t)) { nodes.add(new ConfigNodeComment(t)); t = nextToken(); <START> continue; <END> } else if (Tokens.isNewline(t)) { sawSeparatorOrNewline = true; lineNumber++; } else if (t == Tokens.COMMA) { nodes.add(new ConfigNodeSingleToken(t)); return true; } else { putBack(t); return sawSeparatorOrNewline; } nodes.add(new ConfigNodeSingleToken(t)); t = nextToken(); } } }</code><technical_language>this is a clunky return, continue, fall add ConfigNodeSingleToken. suggest putting a nodes.add in branch, for return fall t = nextToken (i.e. remove t = nextToken continue this branch, add nodes.add(new ConfigNodeSingleToken) branches continue return)</technical_language>

Target:
private boolean checkElementSeparator(Collection<AbstractConfigNode> nodes) { if (flavor == ConfigSyntax.JSON) { Token t = nextTokenCollectingWhitespace(nodes); if (t == Tokens.COMMA) { nodes.add(new ConfigNodeSingleToken(t)); return true; } else { putBack(t); return false; } } else { boolean sawSeparatorOrNewline = false; Token t = nextToken(); while (true) { if (Tokens.isIgnoredWhitespace(t) || isUnquotedWhitespace(t)) { nodes.add(new ConfigNodeSingleToken(t)); } else if (Tokens.isComment(t)) { nodes.add(new ConfigNodeComment(t)); } else if (Tokens.isNewline(t)) { sawSeparatorOrNewline = true; lineNumber++; nodes.add(new ConfigNodeSingleToken(t)); } else if (t == Tokens.COMMA) { nodes.add(new ConfigNodeSingleToken(t)); return true; } else { putBack(t); return sawSeparatorOrNewline; } t = nextToken(); } } }
Source:
<code>private static HttpURLConnection getHttpConnection(String uri, SSLContext sslContext, String sniName) throws KeyManagementException, IOException { URL url = new URL(uri); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); <START> if (FhirConstants.HTTP.equals(url.getProtocol())) { <END> return urlConnection; } SSLParameters sslParamters = sslContext.getDefaultSSLParameters(); CertificateManager cm = CertificateManagerImpl.getInstance(); sslContext.init(getKeyManager(cm), getTrustManager(cm), null); SSLSocketFactory factory; if (StringUtils.isNotBlank(sniName)) { List<SNIServerName> sniHostList = new ArrayList<>(); sniHostList.add(new SNIHostName(sniName)); sslParamters.setServerNames(sniHostList); factory = new SSLSocketFactoryWrapper(sslContext.getSocketFactory(), sslParamters); } else { factory = sslContext.getSocketFactory(); } HttpsURLConnection httpsConnection = ((HttpsURLConnection) urlConnection); httpsConnection.setSSLSocketFactory(factory); if (isCNCheckDisabled()) { httpsConnection.setHostnameVerifier(getAllHostnameVerifier()); } return urlConnection; }</code><technical_language>Optional: I feel method flow if negated this check (or explicitly check if HTTPS) run lines 106 122 conditionally a return in middle of method - I missed glance</technical_language>

Target:
private static HttpURLConnection getHttpConnection(String uri, SSLContext sslContext, String sniName) throws KeyManagementException, IOException, FhirClientException { if (StringUtils.isBlank(uri)) { throw new FhirClientException("URL not specified"); } URL url = new URL(uri); if (FhirConstants.HTTPS.equals(url.getProtocol())) { return getHttpsConnection(url, sslContext, sniName); } return (HttpURLConnection) url.openConnection(); }
Source:
<code>public FEELFnResult<BigDecimal> invoke(@ParameterName( "number" ) BigDecimal number) { if ( number == null ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "cannot be null" ) ); } <START> return FEELFnResult.ofResult( new BigDecimal( Math.exp( number.doubleValue() ) ) ); <END> }</code><technical_language>convert Double for reasons motivated below</technical_language>

Target:
public FEELFnResult<BigDecimal> invoke(@ParameterName( "number" ) BigDecimal number) { if ( number == null ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "cannot be null" ) ); } return FEELFnResult.ofResult( new BigDecimal( Math.exp( number.doubleValue() ), MathContext.DECIMAL128 ) ); }
Source:
<code>private String findDefaultR() throws ConfigurationException { <START> File r = Paths.get(osChecker.isWindows() ? DEFAULT_WINDOWS_R_PATH : DEFAULT_LINUX_R_PATH).toFile(); <END> if (r.exists() && r.canExecute()) { return r.getAbsolutePath(); } else { throw new ConfigurationException("Could not find R."); } }</code><technical_language>Minor point a long expression - extract variable "osChecker.isWindows() ? DEFAULT_WINDOWS_R_PATH : DEFAULT_LINUX_R_PATH"</technical_language>

Target:
private String findDefaultR() throws ConfigurationException { String rPath = osChecker.isWindows() ? DEFAULT_WINDOWS_R_PATH : DEFAULT_LINUX_R_PATH; File r = Paths.get(rPath).toFile(); if (r.exists() && r.canExecute()) { return r.getAbsolutePath(); } else { throw new ConfigurationException("Could not find R."); } }
Source:
<code>public IStatus getProfileDefinitionStatus() { String profilePath = getProfileURI(); <START> IStatus okStatus = new Status(IStatus.OK, Activator.PLUGIN_ID, ""); END> if (profilePath == null || profilePath.equalsIgnoreCase("")) { return okStatus; } URI profileURI = URI.createURI(profilePath); ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = null; try { resource = resourceSet.getResource(profileURI, true); } catch (WrappedException ex) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_UnavailableResource); } if (resource == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NullResource); } if (resource.getContents().isEmpty()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_EmptyResource); } EObject eObject = resource.getContents().get(0); if (!(eObject instanceof Profile)) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NotAProfile); } Profile profile = (Profile) eObject; if (!profile.isDefined()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_ProfileNotDefined); } return okStatus; }</code><technical_language>is a singleton for OK Status: Status.OK_STATUS</technical_language>

Target:
public IStatus getProfileDefinitionStatus() { String profilePath = getProfileURI(); if (profilePath == null || profilePath.equalsIgnoreCase("")) { return Status.OK_STATUS; } URI profileURI = URI.createURI(profilePath); ResourceSet resourceSet = Util.createTemporaryResourceSet(); Resource resource = null; try { resource = resourceSet.getResource(profileURI, true); } catch (WrappedException ex) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_UnavailableResource, ex); } finally { EMFHelper.unload(resourceSet); } if (resource == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NullResource); } if (resource.getContents().isEmpty()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_EmptyResource); } EObject eObject = resource.getContents().get(0); if (!(eObject instanceof Profile)) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NotAProfile); } Profile profile = (Profile) eObject; if (!profile.isDefined()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_ProfileNotDefined); } return Status.OK_STATUS; }
Source:
<code>private String getIPAddress(JoinPoint jp) { Object[] args = jp.getArgs(); if (args.length <= 0) { throw new IllegalArgumentException(RATE_LIMIT_PRECONDITION_FAIL); } Object lastParam = args[args.length - 1]; if (lastParam instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest) lastParam; String ipAddress = request.getHeader("X-FORWARDED-FOR"); <START> if (ipAddress == null) { <END> ipAddress = request.getRemoteAddr(); } return ipAddress; } else { throw new IllegalArgumentException(RATE_LIMIT_PRECONDITION_FAIL); } }</code><technical_language>Consider return ipAddress == null ? request.getRemoteAddr() : ipAddress;</technical_language>

Target:
private String getIPAddress(JoinPoint jp) { Object[] args = jp.getArgs(); if (args.length <= 0) { throw new IllegalArgumentException(RATE_LIMIT_PRECONDITION_FAIL); } Object lastParam = args[args.length - 1]; if (lastParam instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest) lastParam; String ipAddress = request.getHeader("X-FORWARDED-FOR"); return ipAddress == null ? request.getRemoteAddr() : ipAddress; } else { throw new IllegalArgumentException(RATE_LIMIT_PRECONDITION_FAIL); } }
Source:
<code>public Profile get(String id) { <START> Profile profile = null; <END> try { File file = new File(storageFile); if (file.exists()) { JsonParser jsonParser = new JsonParser(); jsonParser.parse(new InputStreamReader(new FileInputStream(file))); JsonValue jsonFromFile = jsonParser.getJsonObject(); profile = profileFromJson(jsonFromFile); } else { profile = DtoFactory.getInstance().createDto(Profile.class).withId(id).withUserId("codenvy").withAttributes( Arrays.asList( DtoFactory.getInstance().createDto(Attribute.class).withName("First Name").withValue("Felix") .withDescription("User's first name"))); update(profile); } } catch (JsonException | IOException e) { LOG.error("It is not possible to parse file " + storageFile + " or this file not found", e); } return profile; }</code><technical_language>For transformation DTO factory DtoFactory.getInstance().createDtoFromJson(java.io.InputStream json, java.lang.Class<T> dtoInterface);</technical_language>

Target:
public Profile get(String id) throws IOException { Profile profile = null; File file = new File(storageFile); InputStreamReader inputStreamReader = null; try { if (file.exists()) { inputStreamReader = new InputStreamReader(new FileInputStream(file)); profile = DtoFactory.getInstance().createDtoFromJson(inputStreamReader, Profile.class); } else { profile = DtoFactory.getInstance().createDto(Profile.class).withId(id).withUserId("codenvy").withAttributes( Arrays.asList( DtoFactory.getInstance().createDto(Attribute.class).withName("First Name").withValue("Felix") .withDescription("User's first name"))); update(profile); } } catch (IOException e) { LOG.error("It is not possible to parse file " + storageFile + " or this file not found", e); } finally { if (inputStreamReader != null) { inputStreamReader.close(); } } return profile; }
Source:
<code>protected ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { <START> this.api = checkNotNull(api, "api"); <END> this.hrefToOptions = hrefToOptions; }</code><technical_language>Remove redundant check protected modifier constructor</technical_language>

Target:
ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { this.api = api; this.hrefToOptions = hrefToOptions; }
Source:
<code>public void checkSpecificAccessControl() { String feedbackQuestionId = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); FeedbackQuestionAttributes feedbackQuestion = logic.getFeedbackQuestion(feedbackQuestionId); if (feedbackQuestion == null) { throw new EntityNotFoundException(new EntityDoesNotExistException("The feedback question does not exist.")); } verifyInstructorCanSeeQuestionIfInModeration(feedbackQuestion); Intent intent = Intent.valueOf(getNonNullRequestParamValue(Const.ParamsNames.INTENT)); FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackQuestion.getFeedbackSessionName(), feedbackQuestion.getCourseId()); switch (intent) { case STUDENT_SUBMISSION: <START> if (userInfo == null && StringHelper.isEmpty(getRequestParamValue(Const.ParamsNames.REGKEY))) { <END> throw new UnauthorizedAccessException("Instructor or Student account is required to access this resource."); } gateKeeper.verifyAnswerableForStudent(feedbackQuestion); StudentAttributes studentAttributes = getStudentOfCourseFromRequest(feedbackSession.getCourseId()); checkAccessControlForStudentFeedbackSubmission(studentAttributes, feedbackSession); break; case INSTRUCTOR_SUBMISSION: if (userInfo == null) { throw new UnauthorizedAccessException("Instructor account is required to access this resource."); } gateKeeper.verifyAnswerableForInstructor(feedbackQuestion); InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(feedbackSession.getCourseId()); checkAccessControlForInstructorFeedbackSubmission(instructorAttributes, feedbackSession); break; default: throw new InvalidHttpParameterException("Unknown intent " + intent); } }</code><technical_language>delete check</technical_language>

Target:
public void checkSpecificAccessControl() { String feedbackQuestionId = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); FeedbackQuestionAttributes feedbackQuestion = logic.getFeedbackQuestion(feedbackQuestionId); if (feedbackQuestion == null) { throw new EntityNotFoundException(new EntityDoesNotExistException("The feedback question does not exist.")); } verifyInstructorCanSeeQuestionIfInModeration(feedbackQuestion); Intent intent = Intent.valueOf(getNonNullRequestParamValue(Const.ParamsNames.INTENT)); FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackQuestion.getFeedbackSessionName(), feedbackQuestion.getCourseId()); switch (intent) { case STUDENT_SUBMISSION: gateKeeper.verifyAnswerableForStudent(feedbackQuestion); StudentAttributes studentAttributes = getStudentOfCourseFromRequest(feedbackSession.getCourseId()); checkAccessControlForStudentFeedbackSubmission(studentAttributes, feedbackSession); break; case INSTRUCTOR_SUBMISSION: gateKeeper.verifyAnswerableForInstructor(feedbackQuestion); InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(feedbackSession.getCourseId()); checkAccessControlForInstructorFeedbackSubmission(instructorAttributes, feedbackSession); break; default: throw new InvalidHttpParameterException("Unknown intent " + intent); } }
Source:
<code>public void shouldOnlyCallIdentifiedTimeIfLeaseIsValid() { LeasedLockToken validToken = LeasedLockToken.of(LOCK_TOKEN, getLease()); when(timelockService.getLeaderTime()).thenReturn(getIdentifiedTime()); <START> timelockClient.refreshLockLeases(ImmutableSet.of(validToken)); <END> verify(timelockService).getLeaderTime(); verifyNoMoreInteractions(timelockService); }</code><technical_language>timelockService timelockClient wrong names for variables, renamed classes</technical_language>

Target:
public void shouldOnlyCallIdentifiedTimeIfLeaseIsValid() { LeasedLockToken validToken = LeasedLockToken.of(LOCK_TOKEN, getLease()); when(timelockRpcClient.getLeaderTime()).thenReturn(getIdentifiedTime()); timelockService.refreshLockLeases(ImmutableSet.of(validToken)); verify(timelockRpcClient).getLeaderTime(); verifyNoMoreInteractions(timelockRpcClient); }
Source:
<code>public void shouldRemoveClaimWhenPassingNull() throws Exception { Algorithm algorithm = mock(Algorithm.class); JWTVerifier verifier = JWTVerifier.init(algorithm) <START> .withSubject("1234567890") <END> .withSubject(null) .build(); assertThat(verifier.claims, is(notNullValue())); assertThat(verifier.claims, not(hasKey("sub"))); }</code><technical_language>This throwing unhandled exception. Please rollback this test's changes. Create new tests if required change existing :)</technical_language>

Target:
public void shouldRemoveClaimWhenPassingNull() throws Exception { Algorithm algorithm = mock(Algorithm.class); JWTVerifier verifier = JWTVerifier.init(algorithm) .withIssuer("iss") .withIssuer(null) .build(); assertThat(verifier.claims, is(notNullValue())); assertThat(verifier.claims, not(hasKey("iss"))); }
Source:
<code>public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { if (orderParams instanceof CancelOrderByIdParams) { <START> return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId()); <END> } else { return false; } }</code><technical_language>of this wrapped in try / catch CoingiException</technical_language>

Target:
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { try { if (orderParams instanceof CancelOrderByIdParams) { return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId()); } else { return false; } } catch (CoingiException e) { throw CoingiErrorAdapter.adapt(e); } }
Source:
<code>public void setData(@Nullable LatencyAnalysis analysis) { if (analysis == null) { <START> return; <END> } ISegmentStore<ISegment> results = analysis.getResults(); if (results != null) { updateModel(LatencyViewerUtils.storeAndGet(results)); return; } LatencyViewerUtils.runAnalysis(fListener); }</code><technical_language>If selected trace is a kernel trace, viewer data remains. call updateModel(null) here</technical_language>

Target:
public void setData(@Nullable LatencyAnalysis analysis) { if (analysis == null) { updateModel(null); return; } ISegmentStore<ISegment> results = analysis.getResults(); if (results != null) { updateModel(LatencyViewerUtils.storeAndGet(results)); return; } updateModel(null); LatencyViewerUtils.runAnalysis(fListener); }
Source:
<code>public Object[][] testSexDataProviderInt() { return new Object[][] { <START> new Object[]{Sex.Male, 1, true}, <END> new Object[]{Sex.Female, 2, true}, new Object[]{Sex.Unknown, 0, true}, new Object[]{Sex.NotReported, 0, false}, new Object[]{Sex.Female, 1, false}, new Object[]{Sex.Unknown, 2, false}, }; }</code><technical_language>operator new needed suggestion {Sex.Male, 1, true},</technical_language>

Target:
public Object[][] testSexDataProviderInt() { return new Object[][]{ {Sex.Male, 1}, {Sex.Female, 2}, {Sex.Unknown, 0}, }; }
Source:
<code>public void periodicWorkFirstPass() { try { RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); InputObjectState states = new InputObjectState(); if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && (states.notempty())) { boolean finished = false; do { Uid uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { SubordinationManager .getTransactionImporter().recoverTransaction( uid); } else { <START> finished = true; <END> } } while (!finished); } } catch (ObjectStoreException | XAException | IOException e) { e.printStackTrace(); } }</code><technical_language>break instead of flag</technical_language>

Target:
public void periodicWorkFirstPass() { RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); InputObjectState states = new InputObjectState(); Uid uid = null; try { if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && (states.notempty())) { while (true) { uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { SubordinationManager .getTransactionImporter().recoverTransaction( uid); } else { break; } } } recoveryScanCompletedWithoutError = true; } catch (ObjectStoreException | XAException | IOException e) { jtaLogger.i18NLogger.warn_could_not_recover_subordinate(uid, e); recoveryScanCompletedWithoutError = false; } if (!validatePosition()) { recoveryScanCompletedWithoutError = false; } }
Source:
<code>public String getName() { ServletContext servletContext = ResteasyContext.getContextData(ServletContext.class); FilterConfig filterConfig = ResteasyContext.getContextData(FilterConfig.class); ServletConfig servletConfig = ResteasyContext.getContextData(ServletConfig.class); <START> return (servletContext != null ? servletContext.getServletContextName() : null) + <END> ":" + (filterConfig != null ? filterConfig.getFilterName() : null) + ":" + (servletConfig != null ? servletConfig.getServletName() : null) + ":FilterConfigSource"; }</code><technical_language>wondering this is computed once, stored reused. reason basically 1) stability of result (is name changes multiple invocations?) 2) performances (there're multiple string concat involved in computing name). WDYT</technical_language>

Target:
public String getName() { if (name == null) { synchronized(this) { if (name == null) { ServletContext servletContext = ResteasyContext.getContextData(ServletContext.class); FilterConfig filterConfig = ResteasyContext.getContextData(FilterConfig.class); StringBuilder sb = new StringBuilder(); name = sb.append(servletContext != null ? servletContext.getServletContextName() : null).append(":") .append(filterConfig != null ? filterConfig.getFilterName() : null) .append(":FilterConfigSource").toString(); } } } return name; }
Source:
<code>public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.grid_item_channel, parent, false); final FavouriteItemViewHolder vh = new FavouriteItemViewHolder(convertView); convertView.setTag(vh); } final FavouriteItemViewHolder vh = (FavouriteItemViewHolder) convertView.getTag(); final FavouriteType.DetailsFavourite favouriteDetail = getItem(position); vh.contextMenu.setVisibility(View.GONE); vh.titleView.setText(favouriteDetail.title); <START> vh.detailView.setText(favouriteDetail.type); <END> UIUtils.loadImageWithCharacterAvatar(getContext(), hostManager, favouriteDetail.thumbnail, favouriteDetail.title, vh.artView, artWidth, artHeight); return convertView; }</code><technical_language>Ideally favoriteDetail.type text. values strings.xml those, translated/made user friendly</technical_language>

Target:
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.grid_item_channel, parent, false); final FavouriteItemViewHolder vh = new FavouriteItemViewHolder(convertView); convertView.setTag(vh); } final FavouriteItemViewHolder vh = (FavouriteItemViewHolder) convertView.getTag(); final FavouriteType.DetailsFavourite favouriteDetail = getItem(position); vh.contextMenu.setVisibility(View.GONE); vh.titleView.setText(favouriteDetail.title); @StringRes final int typeRes; switch (favouriteDetail.type) { case FavouriteType.FavouriteTypeEnum.MEDIA: typeRes = R.string.media; break; case FavouriteType.FavouriteTypeEnum.SCRIPT: typeRes = R.string.script; break; case FavouriteType.FavouriteTypeEnum.WINDOW: typeRes = R.string.window; break; default: typeRes = R.string.unknown; } vh.detailView.setText(typeRes); UIUtils.loadImageWithCharacterAvatar(getContext(), hostManager, favouriteDetail.thumbnail, favouriteDetail.title, vh.artView, artWidth, artHeight); return convertView; }
Source:
<code>public static boolean containsIgnoreCase(String src, String what) { final int length = what.length(); if (length == 0) { return true; } final char firstLo = Character.toLowerCase(what.charAt(0)); final char firstUp = Character.toUpperCase(what.charAt(0)); for (int i = src.length() - length; i >= 0; i--) { final char ch = src.charAt(i); if (ch != firstLo && ch != firstUp) { continue; } <START> <END> if (src.regionMatches(true, i, what, 0, length)) { return true; } } return false; }</code><technical_language>camel-jmh test String provided, plain regionMatches fastest; Needs run more iterations get error smaller. Mode Cnt Score Error Units src.regionMatches avgt 20 4937.268 +- 106.718 us/op empty check+src.regionMatches avgt 20 4889.541 +- 38.962 us/op quick check avgt 20 7250.833 +- 49.024 us/op test cases equal number of falses trues. Result's ofc depend distribution of data</technical_language>

Target:
public static boolean containsIgnoreCase(String src, String what) { if (src == null || what == null) { return false; } final int length = what.length(); if (length == 0) { return true; } final char firstLo = Character.toLowerCase(what.charAt(0)); final char firstUp = Character.toUpperCase(what.charAt(0)); for (int i = src.length() - length; i >= 0; i--) { final char ch = src.charAt(i); if (ch != firstLo && ch != firstUp) { continue; } if (src.regionMatches(true, i, what, 0, length)) { return true; } } return false; }
Source:
<code>private Connection createConnection() throws SQLException { <START> if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(pass)) { <END> return DriverManager.getConnection(connectionUrl, username, pass); } else { return DriverManager.getConnection(connectionUrl); } }</code><technical_language>a "" password allowed? (I idea if is valid)</technical_language>

Target:
private Connection createConnection() throws SQLException { if (StringUtils.isNotBlank(username) && pass != null) { return DriverManager.getConnection(connectionUrl, username, pass); } else { return DriverManager.getConnection(connectionUrl); } }