auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Predicate<String> create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { checkNotNull(resourceGroup, "resourceGroup cannot be null"); checkNotNull(vaultUri, "vaultUri cannot be null"); return retry(new Predicate<String>() { @Override public boolean apply(final String name) { boolean present = false; checkNotNull(name, "name cannot be null"); DeletedSecretBundle secret = api.getVaultApi(resourceGroup).getDeletedSecret(vaultUri, name); if (shouldBePresent) { return secret != null; } else { return secret == null; <START> } <END> } }, operationTimeout, initialPeriod, maxPeriod); }</code><technical_language>java return shouldBePresent == (secret != null);</technical_language>

Target:
public Predicate<String> create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { checkNotNull(resourceGroup, "resourceGroup cannot be null"); checkNotNull(vaultUri, "vaultUri cannot be null"); return retry(new Predicate<String>() { @Override public boolean apply(final String name) { boolean present = false; checkNotNull(name, "name cannot be null"); DeletedSecretBundle secret = api.getVaultApi(resourceGroup).getDeletedSecret(vaultUri, name); return shouldBePresent == (secret != null); } }, operationTimeout, initialPeriod, maxPeriod); }
Source:
<code>private void putUnion(final ByteBuffer buffer, final int position, final DoublesUnion union) { Int2ObjectMap<DoublesUnion> map = unions.get(buffer); <START> if (map == null) { <END> map = new Int2ObjectOpenHashMap<>(); unions.put(buffer, map); } map.put(position, union); }</code><technical_language>computeIfAbsent()</technical_language>

Target:
private void putUnion(final ByteBuffer buffer, final int position, final DoublesUnion union) { Int2ObjectMap<DoublesUnion> map = unions.computeIfAbsent(buffer, buf -> new Int2ObjectOpenHashMap<>()); map.put(position, union); }
Source:
<code>private void migrateOpenPgpGlobalToAccountSettings() { Preferences preferences = Preferences.getPreferences(this); Storage storage = preferences.getStorage(); String openPgpProvider = storage.getString("openPgpProvider", null); boolean openPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false); for (Account account : preferences.getAccounts()) { <START> account.setOpenPgpProvider(openPgpProvider); <END> account.setOpenPgpHideSignOnly(!openPgpSupportSignOnly); } storage.edit() .remove("openPgpProvider") .remove("openPgpSupportSignOnly") .commit(); }</code><technical_language>want save account settings setting crypto provider</technical_language>

Target:
private void migrateOpenPgpGlobalToAccountSettings() { Preferences preferences = Preferences.getPreferences(this); Storage storage = preferences.getStorage(); String openPgpProvider = storage.getString("openPgpProvider", null); boolean openPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false); for (Account account : preferences.getAccounts()) { account.setOpenPgpProvider(openPgpProvider); account.setOpenPgpHideSignOnly(!openPgpSupportSignOnly); account.save(preferences); } storage.edit() .remove("openPgpProvider") .remove("openPgpSupportSignOnly") .commit(); }
Source:
<code>public static VirtualChannel start(final TaskListener listener, final String rootUsername, final String rootPassword) throws IOException, InterruptedException { if(File.pathSeparatorChar==';') return newLocalChannel(); String os = Util.fixNull(System.getProperty("os.name")); if(os.equals("Linux")) return new UnixSu() { protected String sudoExe() { return "sudo"; } protected Process sudoWithPass(ArgumentListBuilder args) throws IOException { args.prepend(sudoExe(),"-S"); listener.getLogger().println("$ "+Util.join(args.toList()," ")); ProcessBuilder pb = new ProcessBuilder(args.toCommandArray()); Process p = pb.start(); <START> try (PrintStream ps = new PrintStream(p.getOutputStream())) { <END> ps.println(rootPassword); ps.println(rootPassword); ps.println(rootPassword); } return p; } }.start(listener,rootPassword); if(os.equals("SunOS")) return new UnixSu() { protected String sudoExe() { return "/usr/bin/pfexec"; } protected Process sudoWithPass(ArgumentListBuilder args) throws IOException { listener.getLogger().println("Running with embedded_su"); ProcessBuilder pb = new ProcessBuilder(args.prepend(sudoExe()).toCommandArray()); return EmbeddedSu.startWithSu(rootUsername, rootPassword, pb); } }.start(listener,rootUsername==null?null:rootPassword); return newLocalChannel(); }</code><technical_language>concerns me, test coverage for AFAICT</technical_language>

Target:
public static VirtualChannel start(final TaskListener listener, final String rootUsername, final String rootPassword) throws IOException, InterruptedException { if(File.pathSeparatorChar==';') return newLocalChannel(); String os = Util.fixNull(System.getProperty("os.name")); if(os.equals("Linux")) return new UnixSu() { protected String sudoExe() { return "sudo"; } protected Process sudoWithPass(ArgumentListBuilder args) throws IOException { args.prepend(sudoExe(),"-S"); listener.getLogger().println("$ "+Util.join(args.toList()," ")); ProcessBuilder pb = new ProcessBuilder(args.toCommandArray()); Process p = pb.start(); PrintStream ps = new PrintStream(p.getOutputStream()); ps.println(rootPassword); ps.println(rootPassword); ps.println(rootPassword); return p; } }.start(listener,rootPassword); if(os.equals("SunOS")) return new UnixSu() { protected String sudoExe() { return "/usr/bin/pfexec"; } protected Process sudoWithPass(ArgumentListBuilder args) throws IOException { listener.getLogger().println("Running with embedded_su"); ProcessBuilder pb = new ProcessBuilder(args.prepend(sudoExe()).toCommandArray()); return EmbeddedSu.startWithSu(rootUsername, rootPassword, pb); } }.start(listener,rootUsername==null?null:rootPassword); return newLocalChannel(); }
Source:
<code>private static Interval createToInterval(final String intervalName, final boolean sourceNegativeStrand, final TargetIntersection targetIntersection) { int toStart = targetIntersection.chain.getBlock(targetIntersection.firstBlockIndex).toStart + targetIntersection.startOffset; int toEnd = targetIntersection.chain.getBlock(targetIntersection.lastBlockIndex).getToEnd() - targetIntersection.offsetFromEnd; if (toEnd <= toStart || toStart < 0) { throw new SAMException("Something strange lifting over interval " + intervalName); } if (targetIntersection.chain.toOppositeStrand) { int negativeStart = targetIntersection.chain.toSequenceSize - toEnd; int negativeEnd = targetIntersection.chain.toSequenceSize - toStart; toStart = negativeStart; toEnd = negativeEnd; } <START> final boolean strand = targetIntersection.chain.toOppositeStrand ? !sourceNegativeStrand : sourceNegativeStrand; <END> return new Interval(targetIntersection.chain.toSequenceName, toStart+1, toEnd, strand, intervalName); }</code><technical_language>Tim, (Please ignore smell of burning dust this portion of memory ;-) tiny niggle: change name of this variable 'strand' 'negativeStrand?' Other that, :+1: -Alec</technical_language>

Target:
private static Interval createToInterval(final String intervalName, final boolean sourceNegativeStrand, final TargetIntersection targetIntersection) { int toStart = targetIntersection.chain.getBlock(targetIntersection.firstBlockIndex).toStart + targetIntersection.startOffset; int toEnd = targetIntersection.chain.getBlock(targetIntersection.lastBlockIndex).getToEnd() - targetIntersection.offsetFromEnd; if (toEnd <= toStart || toStart < 0) { throw new SAMException("Something strange lifting over interval " + intervalName); } if (targetIntersection.chain.toOppositeStrand) { int negativeStart = targetIntersection.chain.toSequenceSize - toEnd; int negativeEnd = targetIntersection.chain.toSequenceSize - toStart; toStart = negativeStart; toEnd = negativeEnd; } final boolean negativeStrand = targetIntersection.chain.toOppositeStrand ? !sourceNegativeStrand : sourceNegativeStrand; return new Interval(targetIntersection.chain.toSequenceName, toStart+1, toEnd, negativeStrand, intervalName); }
Source:
<code>@Test public void annotatedNestedType() { <START> String tuacanon = TypeUseAnnotation.class.getCanonicalName(); <END> String expected = "java.util.Map.@" + tuacanon + " Entry"; AnnotationSpec typeUseAnnotation = AnnotationSpec.builder(TypeUseAnnotation.class).build(); TypeName type = TypeName.get(Map.Entry.class).annotated(typeUseAnnotation); String actual = type.toString(); assertEquals(expected, actual); }</code><technical_language>inline this avoid awkward name</technical_language>

Target:
@Test public void annotatedNestedType() { String expected = "java.util.Map.@" + TypeUseAnnotation.class.getCanonicalName() + " Entry"; AnnotationSpec typeUseAnnotation = AnnotationSpec.builder(TypeUseAnnotation.class).build(); TypeName type = TypeName.get(Map.Entry.class).annotated(typeUseAnnotation); String actual = type.toString(); assertEquals(expected, actual); }
Source:
<code>private <T> CompletableFuture<List<T>> sendSplitRequest(final MultiRequest<T> multiRequest) { final List<byte[]> keys = multiRequest.getKeys(); final Map<RawMemcacheClient, List<byte[]>> routing = Maps.newIdentityHashMap(); final List<RawMemcacheClient> routing2 = Lists.newArrayListWithCapacity(keys.size()); for (final byte[] key : keys) { final RawMemcacheClient client = getClient(key); List<byte[]> subKeys = routing.get(client); if (subKeys == null) { subKeys = Lists.newArrayList(); routing.put(client, subKeys); } subKeys.add(key); routing2.add(client); } final Map<RawMemcacheClient, CompletableFuture<List<T>>> futures = Maps.newIdentityHashMap(); for (final Map.Entry<RawMemcacheClient, List<byte[]>> entry : routing.entrySet()) { final List<byte[]> subKeys = entry.getValue(); final Request<List<T>> subRequest = multiRequest.create(subKeys); final RawMemcacheClient client = entry.getKey(); CompletableFuture<List<T>> send = client.send(subRequest); futures.put(client, send); } CompletableFuture<List<T>> cfs = futures.values().toArray(new CompletableFuture[futures.size()]); CompletableFuture<List<T>> result = CompletableFuture .allOf(cfs) <START> .thenApply(__ -> Arrays.stream(cfs) <END> .map(CompletableFuture::join) .flatMap(List::stream) .collect(Collectors.toList())); return result; }</code><technical_language>merges it, in correct order</technical_language>

Target:
private <T> CompletionStage<List<T>> sendSplitRequest(final MultiRequest<T> multiRequest) { final List<byte[]> keys = multiRequest.getKeys(); final Map<RawMemcacheClient, List<byte[]>> routing = Maps.newIdentityHashMap(); final List<RawMemcacheClient> routing2 = Lists.newArrayListWithCapacity(keys.size()); for (final byte[] key : keys) { final RawMemcacheClient client = getClient(key); List<byte[]> subKeys = routing.get(client); if (subKeys == null) { subKeys = Lists.newArrayList(); routing.put(client, subKeys); } subKeys.add(key); routing2.add(client); } final Map<RawMemcacheClient, CompletionStage<List<T>>> futures = Maps.newIdentityHashMap(); for (final Map.Entry<RawMemcacheClient, List<byte[]>> entry : routing.entrySet()) { final List<byte[]> subKeys = entry.getValue(); final Request<List<T>> subRequest = multiRequest.create(subKeys); final RawMemcacheClient client = entry.getKey(); CompletionStage<List<T>> send = client.send(subRequest); futures.put(client, send); } List<CompletableFuture<List<T>>> cfs = futures.values().stream() .map(CompletionStage::toCompletableFuture) .collect(Collectors.toList()); CompletableFuture<List<T>> result = CompletableFuture .allOf(cfs.toArray(new CompletableFuture[futures.size()])) .thenApply(__ -> cfs.stream() .map(CompletableFuture::join) .flatMap(List::stream) .collect(Collectors.toList())); return result; }
Source:
<code><START> public void setSessionRollbackCount(int count) { <END> sessionRollbackCount = count; }</code><technical_language>synchronized</technical_language>

Target:
public synchronized void setSessionRollbackCount(int count) { sessionRollbackCount = count; }
Source:
<code>public ExportInfo exportInfo() { List<String> pages = listPaths(perspectivesFS, p -> p.endsWith(FILE_EXT)).stream() .map(p -> p.getName(p.getNameCount() - 2)) .map(Object::toString) .collect(Collectors.toList()); List<DataSetDef> datasetsDefs = listPaths(datasetsFS, p -> p.endsWith(DATASET_EXT)).stream() .map(this::getDataSetFileContent) .map(this::parseDataSetDefinition) .filter(DataSetDef::isPublic) .collect(Collectors.toList()); <START> boolean connectedToDashbuilder = isExternalServerConfigured(); return new ExportInfo(datasetsDefs, pages, connectedToDashbuilder); <END> }</code><technical_language>suggestion return new ExportInfo(datasetsDefs, pages, isExternalServerConfigured());</technical_language>

Target:
public ExportInfo exportInfo() { List<String> pages = listPaths(perspectivesFS, p -> p.endsWith(FILE_EXT)).stream() .map(p -> p.getName(p.getNameCount() - 2)) .map(Object::toString) .collect(Collectors.toList()); List<DataSetDef> datasetsDefs = listPaths(datasetsFS, p -> p.endsWith(DATASET_EXT)).stream() .map(this::getDataSetFileContent) .map(this::parseDataSetDefinition) .filter(DataSetDef::isPublic) .collect(Collectors.toList()); return new ExportInfo(datasetsDefs, pages, isExternalServerConfigured()); }
Source:
<code>private void provisionServicesForDiscoverableServers( Map<String, ? extends ServerConfig> servers) { servers.forEach( <START> (k, server) -> { <END> if (server.isDiscoverable() && server.getAttributes().containsKey(SERVER_NAME_ATTRIBUTE)) { ServicePort servicePort = getServicePort(server); Service service = new ServerServiceBuilder() .withName(server.getAttributes().get(SERVER_NAME_ATTRIBUTE)) .withMachineName(machineName) .withSelectorEntry(CHE_ORIGINAL_NAME_LABEL, pod.getMetadata().getName()) .withPorts(Collections.singletonList(servicePort)) .withServers(Collections.singletonMap(k, server)) .build(); k8sEnv.getServices().put(service.getMetadata().getName(), service); } }); }</code><technical_language>wdyt classical loop simpler</technical_language>

Target:
private void provisionServicesForDiscoverableServers( Map<String, ? extends ServerConfig> servers) { for (String serverName : servers.keySet()) { ServerConfig server = servers.get(serverName); if (server.getAttributes().containsKey(SERVER_NAME_ATTRIBUTE)) { String endpointName = server.getAttributes().remove(SERVER_NAME_ATTRIBUTE); if (server.isDiscoverable()) { Service service = new ServerServiceBuilder() .withName(endpointName) .withMachineName(machineName) .withSelectorEntry(CHE_ORIGINAL_NAME_LABEL, pod.getMetadata().getName()) .withPorts(Collections.singletonList(getServicePort(server))) .withServers(Collections.singletonMap(serverName, server)) .build(); k8sEnv.getServices().put(service.getMetadata().getName(), service); } } } }
Source:
<code>public void createFullTextResource() throws IOException, JsonParseException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { String requestBody = getJsonStringInput(DESCRIBING_CHO); <START> Annotation storedAnno = createDescribing(requestBody); <END> assertTrue(storedAnno.getMotivation().equals(MotivationTypes.DESCRIBING.name().toLowerCase())); assertEquals(storedAnno.getBody().getInternalType(), BodyInternalTypes.TEXT.name()); }</code><technical_language>replace createAnnotation</technical_language>

Target:
public void createFullTextResource() throws IOException, JsonParseException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { String requestBody = getJsonStringInput(DESCRIBING_CHO); ResponseEntity<String> response = getApiClient().createAnnotation( getApiKey(), WebAnnotationFields.PROVIDER_WEBANNO, null, true, requestBody, TEST_USER_TOKEN, null ); assertNotNull(response.getBody()); assertEquals(response.getStatusCode(), HttpStatus.CREATED); Annotation storedAnno = getApiClient().parseResponseBody(response); assertTrue(storedAnno.getMotivation().equals(MotivationTypes.DESCRIBING.name().toLowerCase())); assertEquals(storedAnno.getBody().getInternalType(), BodyInternalTypes.TEXT.name()); }
Source:
<code>public void testDescribableRoundTrip() throws Exception { DescribableModel<JUnitResultArchiver> model = new DescribableModel<JUnitResultArchiver>(JUnitResultArchiver.class); Map<String,Object> args = new TreeMap<String,Object>(); args.put("testResults", "**/TEST-*.xml"); JUnitResultArchiver j = model.instantiate(args); assertEquals("**/TEST-*.xml", j.getTestResults()); assertFalse(j.isAllowEmptyResults()); assertFalse(j.isKeepLongStdio()); assertEquals(1.0, j.getHealthScaleFactor(), 0); assertTrue(j.getTestDataPublishers().isEmpty()); assertEquals(args, model.uninstantiate(model.instantiate(args))); <START> args.put("testDataPublishers", Collections.<TestDataPublisher>singletonList(new MockTestDataPublisher("test"))); <END> Map<String,Object> explicit = model.uninstantiate(model.instantiate(args)); JUnitResultArchiver j2 = model.instantiate(explicit); assertFalse(j2.getTestDataPublishers().isEmpty()); assertEquals(explicit, model.uninstantiate(model.instantiate(explicit))); Map<String,String> describedPublisher = new HashMap<String, String>(); describedPublisher.put("$class", "MockTestDataPublisher"); describedPublisher.put("name", "test"); args.put("testDataPublishers", Collections.singletonList(describedPublisher)); Map<String,Object> described = model.uninstantiate(model.instantiate(args)); JUnitResultArchiver j3 = model.instantiate(described); assertFalse(j3.getTestDataPublishers().isEmpty()); assertEquals(described, model.uninstantiate(model.instantiate(described))); }</code><technical_language>Of type argument is unnecessary-due erasure, DescribableModel unchecked casts</technical_language>

Target:
public void testDescribableRoundTrip() throws Exception { DescribableModel<JUnitResultArchiver> model = new DescribableModel<JUnitResultArchiver>(JUnitResultArchiver.class); Map<String,Object> args = new TreeMap<String,Object>(); args.put("testResults", "**/TEST-*.xml"); JUnitResultArchiver j = model.instantiate(args); assertEquals("**/TEST-*.xml", j.getTestResults()); assertFalse(j.isAllowEmptyResults()); assertFalse(j.isKeepLongStdio()); assertEquals(1.0, j.getHealthScaleFactor(), 0); assertTrue(j.getTestDataPublishers().isEmpty()); assertEquals(args, model.uninstantiate(model.instantiate(args))); Map<String,Object> describedPublisher = new HashMap<String, Object>(); describedPublisher.put("$class", "MockTestDataPublisher"); describedPublisher.put("name", "test"); args.put("testDataPublishers", Collections.singletonList(describedPublisher)); Map<String,Object> described = model.uninstantiate(model.instantiate(args)); JUnitResultArchiver j2 = model.instantiate(described); List<TestDataPublisher> testDataPublishers = j2.getTestDataPublishers(); assertFalse(testDataPublishers.isEmpty()); assertEquals(1, testDataPublishers.size()); assertEquals(MockTestDataPublisher.class, testDataPublishers.get(0).getClass()); assertEquals("test", ((MockTestDataPublisher)testDataPublishers.get(0)).getName()); assertEquals(described, model.uninstantiate(model.instantiate(described))); }
Source:
<code>public void setCsrfIgnoreUris(Set<String> csrfIgnoreUris) { if (csrfIgnoreUris == null) { this.csrfIgnoreUris = emptySet(); } else { Set<UriPatten> csrfIgnoreUriPatterns = new HashSet<>(); for (String csrfUri : csrfIgnoreUris) { if (csrfUri == null) { LOGGER.error("CSRF ignore URI is null"); <START> throw new IllegalArgumentException("CSRF ignore URI cannot be null."); <END> } else if (csrfUri.isEmpty()) { LOGGER.error("CSRF ignore URI is empty"); throw new IllegalArgumentException("CSRF ignore URI cannot be empty."); } try { csrfIgnoreUriPatterns.add(new UriPatten(csrfUri)); } catch (IllegalArgumentException e) { String error = "CSRF ignore URI is an invalid URI pattern"; LOGGER.error(error); throw new IllegalArgumentException(error, e); } } this.csrfIgnoreUris = unmodifiableSet(csrfIgnoreUriPatterns); } }</code><technical_language>CSRF ignore URI pattern null</technical_language>

Target:
public void setCsrfIgnoreUris(Set<String> csrfIgnoreUris) { if (csrfIgnoreUris == null) { this.csrfIgnoreUris = emptySet(); } else { Set<UriPatten> csrfIgnoreUriPatterns = new HashSet<>(); for (String csrfUri : csrfIgnoreUris) { if (csrfUri == null) { throw new IllegalArgumentException("CSRF ignore URI pattern cannot be null."); } else if (csrfUri.isEmpty()) { throw new IllegalArgumentException("CSRF ignore URI pattern cannot be empty."); } try { csrfIgnoreUriPatterns.add(new UriPatten(csrfUri)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("CSRF ignore URI pattern '" + csrfUri + "' is invalid.", e); } } this.csrfIgnoreUris = unmodifiableSet(csrfIgnoreUriPatterns); } }
Source:
<code>protected void executeCommand() { <START> if (getLeaseAction().equals(VDSCommandType.AddVmLease)) { ActionReturnValue retVal = runInternalAction(ActionType.GetVmLeaseInfo, getParameters()); if (retVal.getSucceeded() && retVal.getActionReturnValue() != null) { log.info("VM '{}' lease already exists on storage domain '{}': '{}'", getParameters().getVmId(), getParameters().getStorageDomainId(), retVal.getActionReturnValue()); getParameters().setVmLeaseInfo(retVal.getActionReturnValue()); setSucceeded(true); return; } } <END> Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); VmLeaseVDSParameters params = new VmLeaseVDSParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getVmId()); VDSReturnValue returnValue = runVdsCommand(getLeaseAction(), params); if (returnValue.getSucceeded()) { getTaskIdList().add( createTask(taskId, returnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); } setSucceeded(returnValue.getSucceeded()); }</code><technical_language>Ugly... override executeCommand in AddVmLeaseCommand this block add a call super.executeCommand()</technical_language>

Target:
protected void executeCommand() { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); VmLeaseVDSParameters params = new VmLeaseVDSParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getVmId()); VDSReturnValue returnValue = runVdsCommand(getLeaseAction(), params); if (returnValue.getSucceeded()) { getTaskIdList().add( createTask(taskId, returnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); } setSucceeded(returnValue.getSucceeded()); }
Source:
<code>public Chain getAndAppend(final long key, final ByteBuffer payLoad) throws TimeoutException { <START> return performWaitingForHashInvalidation(key, () -> delegate.getAndAppend(key, payLoad), entity.getTimeouts().getMutativeOperationTimeout().toNanos()); <END> }</code><technical_language>passing TimeoutDuration in parameter prevent a redundant toNanos</technical_language>

Target:
public Chain getAndAppend(final long key, final ByteBuffer payLoad) throws TimeoutException { return performWaitingForHashInvalidation(key, () -> delegate.getAndAppend(key, payLoad), entity.getTimeouts().getMutativeOperationTimeout()); }
Source:
<code>public void test_controlled_no_scope() { val openEntity = entity("123", "abc", "something.bam", "PROJ-CD", "controlled"); <START> Mockito.when(metadataClient.getEntity("123")).thenReturn(openEntity); <END> val scopeStrs = new HashSet<String>(Arrays.asList("test1.download", "test.OTHER-CODE.upload", "test.ALT-CODE.upload", "test.CODE.upload", "test2.download")); List<AuthScope> scopes = _sut.extractScopes(scopeStrs); val result = _sut.verify(scopes, "123"); assertFalse(result); }</code><technical_language>Please static import matchers. Thanks</technical_language>

Target:
public void test_controlled_no_scope() { val openEntity = entity("123", "abc", "something.bam", "PROJ-CD", "controlled"); when(metadataService.getEntity("123")).thenReturn(openEntity); val scopeStrs = new HashSet<String>(Arrays.asList("test1.download", "test.OTHER-CODE.upload", "test.ALT-CODE.upload", "test.CODE.upload", "test2.download")); List<AuthScope> scopes = sut.extractScopes(scopeStrs); val result = sut.verify(scopes, "123"); assertFalse(result); }
Source:
<code>protected Iterable<Tree> children() { <START> ImmutableList.Builder<Tree> iteratorBuilder = ImmutableList.<Tree>builder(); <END> iteratorBuilder.add(directiveKeyword(), typeName, withKeyword); iteratorBuilder.addAll(typeNames.children()); iteratorBuilder.add(semicolonToken()); return iteratorBuilder.build(); }</code><technical_language>withKeyword is missing children, while other keywords in directives part of</technical_language>

Target:
protected Iterable<Tree> children() { return Collections.unmodifiableList(Arrays.asList( directiveKeyword(), typeName, withKeyword, typeNames, semicolonToken())); }
Source:
<code>public void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String, AttrValue> attributesForNode, GraphDef graph) { int idx = -1; int cnt = 0; int concatDimension = 0; for (int i = 0; i < nodeDef.getInputCount(); i++) { val input = nodeDef.getInput(i); val variable = initWith.getVariable(input); if (variable != null && variable.getArr() == null) { idx = cnt; if(variable.getShape() != null) concatDimension = variable.getShape()[0]; break; } else if (variable != null) { val arr = variable.getArr(); if (arr.length() == 1) { concatDimension = arr.getInt(0); idx = cnt; break; } } cnt++; } if (idx < 0) throw new ND4JIllegalStateException("Can't find dimension for concatenatiion"); if (concatDimension == 3) concatDimension = 1; <START> this.concatDimension = concatDimension; <END> log.debug("Concat dimension: {}", concatDimension); }</code><technical_language>missing addIArgument call here</technical_language>

Target:
public void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String, AttrValue> attributesForNode, GraphDef graph) { }
Source:
<code>protected Ack doPost(CommandEnvelope envelope) { final CommandDispatcher<?> dispatcher = getDispatcher(envelope); Ack result; try { dispatcher.dispatch(envelope); commandStore.setCommandStatusOk(envelope); result = acknowledge(envelope.getId()); } catch (RuntimeException e) { final Throwable cause = getRootCause(e); commandStore.updateCommandStatus(envelope, cause, log); if (causedByRejection(e)) { final ThrowableMessage throwableMessage = (ThrowableMessage) cause; final Rejection rejection = toRejection(throwableMessage, envelope.getCommand()); final Class<?> rejectionClass = AnyPacker.unpack(rejection.getMessage()) .getClass(); <START> Log.log().info("Posting rejection to RejectionBus.", rejectionClass.getName()); <END> rejectionBus().post(rejection); result = reject(envelope.getId(), rejection); } else { final Error error = toError(cause); result = reject(envelope.getId(), error); } } return result; }</code><technical_language>Log.log() is weird. Also, info. "trace" "debug". former</technical_language>

Target:
protected Ack doPost(CommandEnvelope envelope) { final CommandDispatcher<?> dispatcher = getDispatcher(envelope); Ack result; try { dispatcher.dispatch(envelope); commandStore.setCommandStatusOk(envelope); result = acknowledge(envelope.getId()); } catch (RuntimeException e) { final Throwable cause = getRootCause(e); commandStore.updateCommandStatus(envelope, cause, log); if (causedByRejection(e)) { final ThrowableMessage throwableMessage = (ThrowableMessage) cause; final Rejection rejection = toRejection(throwableMessage, envelope.getCommand()); final Class<?> rejectionClass = AnyPacker.unpack(rejection.getMessage()) .getClass(); Log.log().trace("Posting rejection to RejectionBus.", rejectionClass.getName()); rejectionBus().post(rejection); result = reject(envelope.getId(), rejection); } else { final Error error = toError(cause); result = reject(envelope.getId(), error); } } return result; }
Source:
<code>public void setAlternateIpHeaders(final String... alternateIpHeaders) { <START> Objects.requireNonNull(alternateIpHeaders, "Ip headers must be not null"); <END> this.alternateIpHeaders = Arrays.asList(alternateIpHeaders); }</code><technical_language>CommonHelper.assertNotNull for consistency other checks</technical_language>

Target:
public void setAlternateIpHeaders(final String... alternateIpHeaders) { CommonHelper.assertNotNull("alternateIpHeaders", alternateIpHeaders); this.alternateIpHeaders = Arrays.asList(alternateIpHeaders); }
Source:
<code>private void generateNewJobModel(List<String> processors) { List<String> currentProcessorsIds; if (processors.size() > 0) { currentProcessorsIds = zkUtils.getActiveProcessorsIDs(processors); } else { currentProcessorsIds = zkUtils.getSortedActiveProcessorsIDs(); } String currentJMVersion = zkUtils.getJobModelVersion(); String nextJMVersion; if (currentJMVersion == null) { LOGGER.info("pid=" + processorId + "generating first version of the model"); nextJMVersion = "1"; } else { nextJMVersion = Integer.toString(Integer.valueOf(currentJMVersion) + 1); } LOGGER.info("pid=" + processorId + "generating new model. Version = " + nextJMVersion); List<String> containerIds = new ArrayList<>(currentProcessorsIds.size()); for (String processorPid : currentProcessorsIds) { containerIds.add(processorPid); } LOGGER.info("generate new job model: processorsIds: " + Arrays.toString(containerIds.toArray())); JobModel jobModel = JobModelManager.readJobModel(this.config, Collections.emptyMap(), null, streamMetadataCache, containerIds); LOGGER.info("pid=" + processorId + "Generated jobModel: " + jobModel); zkUtils.publishJobModel(nextJMVersion, jobModel); <START> LOGGER.info("pid=" + processorId + "published new JobModel ver=" + nextJMVersion + ";jm=" + jobModel); <END> BarrierForVersionUpgrade barrier = coordinationUtils.getBarrier( JOB_MODEL_UPGRADE_BARRIER); barrier.start(nextJMVersion, currentProcessorsIds); zkUtils.publishJobModelVersion(currentJMVersion, nextJMVersion); LOGGER.info("pid=" + processorId + "published new JobModel ver=" + nextJMVersion); }</code><technical_language>I is existing code. Please remove job model this log line. need in log</technical_language>

Target:
private void generateNewJobModel(List<String> processors) { List<String> currentProcessorsIds; if (processors.size() > 0) { currentProcessorsIds = zkUtils.getActiveProcessorsIDs(processors); } else { currentProcessorsIds = zkUtils.getSortedActiveProcessorsIDs(); } String currentJMVersion = zkUtils.getJobModelVersion(); String nextJMVersion; if (currentJMVersion == null) { LOG.info("pid=" + processorId + "generating first version of the model"); nextJMVersion = "1"; } else { nextJMVersion = Integer.toString(Integer.valueOf(currentJMVersion) + 1); } LOG.info("pid=" + processorId + "generating new model. Version = " + nextJMVersion); List<String> containerIds = new ArrayList<>(currentProcessorsIds.size()); for (String processorPid : currentProcessorsIds) { containerIds.add(processorPid); } LOG.info("generate new job model: processorsIds: " + Arrays.toString(containerIds.toArray())); JobModel jobModel = JobModelManager.readJobModel(this.config, Collections.emptyMap(), null, streamMetadataCache, containerIds); LOG.info("pid=" + processorId + "Generated jobModel: " + jobModel); zkUtils.publishJobModel(nextJMVersion, jobModel); BarrierForVersionUpgrade barrier = coordinationUtils.getBarrier( JOB_MODEL_UPGRADE_BARRIER); barrier.start(nextJMVersion, currentProcessorsIds); zkUtils.publishJobModelVersion(currentJMVersion, nextJMVersion); LOG.info("pid=" + processorId + "published new JobModel ver=" + nextJMVersion); }
Source:
<code>private boolean isNonClientTransaction(GlobalTransaction gtx) { <START> return globalTxTable.values().stream() <END> .map(TxFunctions.mapTxStateToGlobalTransaction()) .noneMatch(TxFunctions.equalsGlobalTransaction(gtx)); }</code><technical_language>in case transaction is missing table is automatically considered client transaction? I find this a bit error-prone. a special singleton "client address"</technical_language>

Target:
private boolean isNonClientTransaction(GlobalTransaction gtx) { return !(gtx.getAddress() instanceof ClientAddress); }
Source:
<code>public void sendRequest(String requestType, String endPoint, String foo, String loginInfo, String baseData, String baz, String type, DataTable modifications) throws Exception { String retrievedData = commonspec.retrieveData(baseData, type); commonspec.getLogger().debug("Modifying data as {}", retrievedData, type); <START> String modifiedData; <END> modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString(); String user = null; String password = null; if (loginInfo != null) { user = loginInfo.substring(0, loginInfo.indexOf(':')); password = loginInfo.substring(loginInfo.indexOf(':') + 1, loginInfo.length()); } commonspec.getLogger().debug("Generating request to with data as {}", requestType, endPoint, modifiedData, type); Future<Response> response = commonspec.generateRequest(requestType, false, user, password, endPoint, modifiedData, type, ""); commonspec.getLogger().debug("Saving response"); commonspec.setResponse(requestType, response.get()); }</code><technical_language>variable type assignment one-lined</technical_language>

Target:
public void sendRequest(String requestType, String endPoint, String foo, String loginInfo, String baseData, String baz, String type, DataTable modifications) throws Exception { String retrievedData = commonspec.retrieveData(baseData, type); commonspec.getLogger().debug("Modifying data as {}", retrievedData, type); String modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString(); String user = null; String password = null; if (loginInfo != null) { user = loginInfo.substring(0, loginInfo.indexOf(':')); password = loginInfo.substring(loginInfo.indexOf(':') + 1, loginInfo.length()); } commonspec.getLogger().debug("Generating request to with data as {}", requestType, endPoint, modifiedData, type); Future<Response> response = commonspec.generateRequest(requestType, false, user, password, endPoint, modifiedData, type, ""); commonspec.getLogger().debug("Saving response"); commonspec.setResponse(requestType, response.get()); }
Source:
<code>private static boolean handlePushDownSingleDistinctCount(ImmutableList.Builder<AggregationColumnNode> nodeBuilder, AggregationNode aggregationNode, VariableReferenceExpression outputColumn, AggregationNode.Aggregation aggregation) { if (aggregation.getCall().getDisplayName().equalsIgnoreCase(COUNT_FUNCTION_NAME)) { List<RowExpression> arguments = aggregation.getCall().getArguments(); if (arguments.size() == 1) { RowExpression aggregationArgument = arguments.get(0); if (aggregationNode.getSource() instanceof AggregationNode) { AggregationNode sourceAggregationNode = (AggregationNode) aggregationNode.getSource(); Set<String> sourceAggregationGroupSet = getGroupKeys(sourceAggregationNode.getGroupingKeys()); Set<String> aggregationGroupSet = getGroupKeys(aggregationNode.getGroupingKeys()); aggregationGroupSet.add(aggregationArgument.toString()); if (sourceAggregationGroupSet.containsAll(aggregationGroupSet) && aggregationGroupSet.containsAll(sourceAggregationGroupSet)) { nodeBuilder.add( new AggregationFunctionColumnNode( outputColumn, new CallExpression( DISTINCT_COUNT_FUNCTION_NAME, aggregation.getFunctionHandle(), <START> BigintType.BIGINT, <END> ImmutableList.of(aggregationArgument)))); return true; } } } } return false; }</code><technical_language>is return type unconditionally a BIGINT</technical_language>

Target:
private static boolean handlePushDownSingleDistinctCount(ImmutableList.Builder<AggregationColumnNode> nodeBuilder, AggregationNode aggregationNode, VariableReferenceExpression outputColumn, AggregationNode.Aggregation aggregation) { if (!aggregation.getCall().getDisplayName().equalsIgnoreCase(COUNT_FUNCTION_NAME)) { return false; } List<RowExpression> arguments = aggregation.getCall().getArguments(); if (arguments.size() != 1) { return false; } RowExpression aggregationArgument = arguments.get(0); if (!(aggregationNode.getSource() instanceof AggregationNode)) { return false; } AggregationNode sourceAggregationNode = (AggregationNode) aggregationNode.getSource(); Set<String> sourceAggregationGroupSet = getGroupKeys(sourceAggregationNode.getGroupingKeys()); Set<String> aggregationGroupSet = getGroupKeys(aggregationNode.getGroupingKeys()); aggregationGroupSet.add(aggregationArgument.toString()); if (!sourceAggregationGroupSet.containsAll(aggregationGroupSet) && aggregationGroupSet.containsAll(sourceAggregationGroupSet)) { return false; } nodeBuilder.add( new AggregationFunctionColumnNode( outputColumn, new CallExpression( PINOT_DISTINCT_COUNT_FUNCTION_NAME, aggregation.getFunctionHandle(), aggregation.getCall().getType(), ImmutableList.of(aggregationArgument)))); return true; }
Source:
<code>ServiceTerminator(EventService eventService, Set<ServiceTermination> terminations) { this.eventService = eventService; ArrayList<ServiceTermination> terminationsList = new ArrayList<>(terminations); Collections.sort(terminationsList, new ServiceTerminationComparator(terminations)); <START> this.terminations = terminationsList; <END> }</code><technical_language>do in shot? stream for example</technical_language>

Target:
ServiceTerminator(EventService eventService, Set<ServiceTermination> terminations) { this.eventService = eventService; this.terminations = ImmutableSortedSet.copyOf(new ServiceTerminationComparator(terminations), terminations); }
Source:
<code>public void testLabelsUnderline() throws Exception { File property = new File(TestData.getResource(this, "nonStraightLines.properties").toURI()); PropertyDataStore dataStore = new PropertyDataStore(property.getParentFile()); SimpleFeatureSource featureSource = dataStore.getFeatureSource("nonStraightLines"); ReferencedEnvelope bounds = featureSource.getBounds(); bounds.expandBy(1, 1); Style style = RendererBaseTest.loadStyle(this, "underlineStyle.sld"); MapContent mapContent = new MapContent(); mapContent.addLayer(new FeatureLayer(featureSource, style)); StreamingRenderer renderer = new StreamingRenderer(); renderer.setMapContent(mapContent); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); BufferedImage image = new BufferedImage(1000, 1000, BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = image.createGraphics(); graphics.setColor(Color.LIGHT_GRAY); graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); renderer.paint(graphics, new Rectangle(0, 0, image.getWidth(), image.getHeight()), bounds); File reference = new File("./src/test/resources/org/geotools/renderer/lite/test-data/underlineStyle.sld.png"); <START> ImageAssert.assertEquals(reference, image, 100); <END> }</code><technical_language>100 pixels enough care for font rendering platforms, other labelling related tests allow 1000+ pixels if memory serves right</technical_language>

Target:
public void testLabelsUnderline() throws Exception { File property = new File(TestData.getResource(this, "nonStraightLines.properties").toURI()); PropertyDataStore dataStore = new PropertyDataStore(property.getParentFile()); SimpleFeatureSource featureSource = dataStore.getFeatureSource("nonStraightLines"); ReferencedEnvelope bounds = featureSource.getBounds(); bounds.expandBy(1, 1); Style style = RendererBaseTest.loadStyle(this, "underlineStyle.sld"); MapContent mapContent = new MapContent(); mapContent.addLayer(new FeatureLayer(featureSource, style)); StreamingRenderer renderer = new StreamingRenderer(); renderer.setMapContent(mapContent); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); BufferedImage image = new BufferedImage(1000, 1000, BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = image.createGraphics(); graphics.setColor(Color.LIGHT_GRAY); graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); renderer.paint(graphics, new Rectangle(0, 0, image.getWidth(), image.getHeight()), bounds); File reference = new File("./src/test/resources/org/geotools/renderer/lite/test-data/underlineStyle.sld.png"); ImageAssert.assertEquals(reference, image, 1200); }
Source:
<code>public void testNettyDockerCmdExecFactoryConfigWithoutApiVersion() throws Exception { NettyDockerCmdExecFactory factory = new NettyDockerCmdExecFactory(); Builder configBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("tcp://localhost:2378"); DockerClient client = DockerClientBuilder.getInstance(configBuilder) .withDockerCmdExecFactory(factory) .build(); <START> FakeDockerServer server = new FakeDockerServer(2378); <END> server.start(); try { client.versionCmd().exec(); List<HttpRequest> requests = server.getRequests(); assertEquals(requests.size(), 1); assertEquals(requests.get(0).uri(), "/version"); } finally { server.stop(); } }</code><technical_language>Please some random port get conflicts</technical_language>

Target:
public void testNettyDockerCmdExecFactoryConfigWithoutApiVersion() throws Exception { int dockerPort = getFreePort(); NettyDockerCmdExecFactory factory = new NettyDockerCmdExecFactory(); Builder configBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("tcp://localhost:" + dockerPort); DockerClient client = DockerClientBuilder.getInstance(configBuilder) .withDockerCmdExecFactory(factory) .build(); FakeDockerServer server = new FakeDockerServer(dockerPort); server.start(); try { client.versionCmd().exec(); List<HttpRequest> requests = server.getRequests(); assertEquals(requests.size(), 1); assertEquals(requests.get(0).uri(), "/version"); } finally { server.stop(); } }
Source:
<code>public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BoolExpression other = (BoolExpression) obj; return Objects.equals(mustClauses, other.mustClauses) && Objects.equals(mustNotClauses, other.mustNotClauses) && Objects.equals(shouldClauses, other.shouldClauses) && Objects.equals(filterClauses, other.filterClauses) <START> && Objects.equals(minShouldMatch, other.minShouldMatch); <END> }</code><technical_language>This box minShouldMatch Integer; a direct comparison is preferable (although breaks pattern)</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BoolExpression other = (BoolExpression) obj; return Objects.equals(mustClauses, other.mustClauses) && Objects.equals(mustNotClauses, other.mustNotClauses) && Objects.equals(shouldClauses, other.shouldClauses) && Objects.equals(filterClauses, other.filterClauses) && minShouldMatch == other.minShouldMatch; }
Source:
<code>private void registerEndpoints() { env.register(remoteLockService); <START> env.register(timestampService); <END> if (config.leader().isPresent()) { localPaxosServices = Leaders.createAndRegisterLocalServices(env, config.leader().get(), userAgent); } env.register(persistentLockService); env.register(new CheckAndSetExceptionMapper()); env.register(sweeperService); }</code><technical_language>do register time/lock endpoints, if timelock</technical_language>

Target:
private void registerEndpoints() { if (config.leader().isPresent()) { registerTimestampAndLockEndpoints(); localPaxosServices = Leaders.createAndRegisterLocalServices(env, config.leader().get(), userAgent); } else if (!((config.timestamp().isPresent() && config.lock().isPresent()) || config.timelock().isPresent())) { registerTimestampAndLockEndpoints(); } env.register(persistentLockService); env.register(new CheckAndSetExceptionMapper()); env.register(sweeperService); }
Source:
<code>private void addOrUpdateAttributeInstance(final Case openCase, Map<ArtifactKey, CorrelationAttributeInstance> artifactInstances, AbstractFile caseDbFile) throws TskCoreException, EamDbException { CorrelationCase caze = new CorrelationCase(openCase.getNumber(), openCase.getDisplayName()); CorrelationDataSource dataSource = CorrelationDataSource.fromTSKDataSource(caze, caseDbFile.getDataSource()); String filePath = caseDbFile.getParentPath() + caseDbFile.getName(); ArtifactKey instKey = new ArtifactKey(dataSource.getDeviceID(), filePath); CorrelationAttributeInstance caseDbInstance = new CorrelationAttributeInstance(caze, dataSource, filePath, "", caseDbFile.getKnown()); TskData.FileKnown knownStatus = caseDbInstance.getKnownStatus(); if (knownStatus.compareTo(TskData.FileKnown.KNOWN) != 0 && knownStatus.compareTo(TskData.FileKnown.BAD) != 0) { List<ContentTag> fileMatchTags = openCase.getServices().getTagsManager().getContentTagsByContent(caseDbFile); for (ContentTag tag : fileMatchTags) { TskData.FileKnown tagKnownStatus = tag.getName().getKnownStatus(); if (tagKnownStatus.compareTo(TskData.FileKnown.KNOWN) == 0 || tagKnownStatus.compareTo(TskData.FileKnown.BAD) == 0) { <START> caseDbInstance.setKnownStatus(TskData.FileKnown.BAD); <END> break; } } } if (knownStatus.compareTo(TskData.FileKnown.KNOWN) == 0 || knownStatus.compareTo(TskData.FileKnown.BAD) == 0 || !artifactInstances.containsKey(instKey)) { artifactInstances.put(instKey, caseDbInstance); } }</code><technical_language>Is this if tag status is BAD, set status BAD? right. I tags status test for BAD</technical_language>

Target:
private void addOrUpdateAttributeInstance(final Case openCase, Map<ArtifactKey, CorrelationAttributeInstance> artifactInstances, AbstractFile caseDbFile) throws TskCoreException, EamDbException { CorrelationCase caze = new CorrelationCase(openCase.getNumber(), openCase.getDisplayName()); CorrelationDataSource dataSource = CorrelationDataSource.fromTSKDataSource(caze, caseDbFile.getDataSource()); String filePath = caseDbFile.getParentPath() + caseDbFile.getName(); ArtifactKey instKey = new ArtifactKey(dataSource.getDeviceID(), filePath); CorrelationAttributeInstance caseDbInstance = new CorrelationAttributeInstance(caze, dataSource, filePath, "", caseDbFile.getKnown()); TskData.FileKnown knownStatus = caseDbInstance.getKnownStatus(); TskData.FileKnown knownBad = TskData.FileKnown.BAD; if (!knownStatus.equals(knownBad)) { List<ContentTag> fileMatchTags = openCase.getServices().getTagsManager().getContentTagsByContent(caseDbFile); for (ContentTag tag : fileMatchTags) { TskData.FileKnown tagKnownStatus = tag.getName().getKnownStatus(); if (tagKnownStatus.equals(knownBad)) { caseDbInstance.setKnownStatus(knownBad); break; } } } if (caseDbInstance.getKnownStatus().equals(knownBad) || !artifactInstances.containsKey(instKey)) { artifactInstances.put(instKey, caseDbInstance); } }
Source:
<code>protected StringBuilder newDeprecatedMessage() { StringBuilder builder = new StringBuilder().append("Property '") .append(getXPath()) .append("' is marked as deprecated from '") .append(getSchema().getName()) .append("' schema"); Property deprecatedParent = getDeprecatedParent(); if (deprecatedParent != this) { builder.append(" because property '") .append(deprecatedParent.getXPath()) .append("' is marked as deprecated"); } <START> return builder.append(", don't use it anymore.\n"); <END> }</code><technical_language>space instead of \n</technical_language>

Target:
protected StringBuilder newDeprecatedMessage() { StringBuilder builder = new StringBuilder().append("Property '") .append(getXPath()) .append("' is marked as deprecated from '") .append(getSchema().getName()) .append("' schema"); Property deprecatedParent = getDeprecatedParent(); if (deprecatedParent != this) { builder.append(" because property '") .append(deprecatedParent.getXPath()) .append("' is marked as deprecated"); } return builder.append(", don't use it anymore. "); }
Source:
<code><START> static public int rapidParseInt(final String input) { <END> final int len = input.length(); int val = 0; int i = 0; boolean isNegative = false; if (0 < len && '-' == input.charAt(0)) { i = 1; isNegative = true; } for (; i < len; ++i) { final char ch = input.charAt(i); if (Character.isDigit(ch)) { val = (val * 10) + (ch - 48); } else { break; } } if (isNegative) val = -val; return val; }</code><technical_language>of this method result in significantly more performant code a -?\d+ regex Integer.valueOf? question for method above</technical_language>

Target:
public static int rapidParseInt(final String input) { final int len = input.length(); int val = 0; int i = 0; boolean isNegative = false; if (0 < len && '-' == input.charAt(0)) { i = 1; isNegative = true; } for (; i < len; ++i) { final char ch = input.charAt(i); if (Character.isDigit(ch)) { val = (val * 10) + (ch - 48); } else { break; } } if (isNegative) val = -val; return val; }