auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testStaffOnly() throws Exception { Map<String, String> depositStatus = new HashMap<>(); depositStatus.put(DepositField.staffOnly.name(), "true"); when(depositStatusFactory.get(eq(depositUUID))).thenReturn(depositStatus); PID objPid = makePid(); Bag objBag = model.createBag(objPid.getRepositoryPath()); objBag.addProperty(RDF.type, Cdr.Folder); Resource fileResc = addFileObject(objBag, FILE_CONTENT1); <START> objBag.addProperty(Cdr.primaryObject, fileResc); <END> objBag.addProperty(RDF.type, Cdr.FileObject); depBag.add(objBag); job.closeModel(); job.run(); model = job.getReadOnlyModel(); Resource roles = model.getResource(objPid.getRepositoryPath()); assertTrue(roles.hasProperty(none.getProperty(), AUTHENTICATED_PRINC)); assertTrue(roles.hasProperty(none.getProperty(), PUBLIC_PRINC)); assertFalse(fileResc.hasProperty(none.getProperty())); }</code><technical_language>i this is test data, a folder allow a primaryObject. remove this property, objBag a work. Also, child type, a file a storage location necessary for this test</technical_language>

Target:
public void testStaffOnly() throws Exception { Map<String, String> depositStatus = new HashMap<>(); depositStatus.put(DepositField.staffOnly.name(), "true"); when(depositStatusFactory.get(eq(depositUUID))).thenReturn(depositStatus); PID objPid = makePid(); Bag objBag = model.createBag(objPid.getRepositoryPath()); objBag.addProperty(RDF.type, Cdr.Work); Resource fileResc = addFileObject(objBag); objBag.addProperty(Cdr.primaryObject, fileResc); depBag.add(objBag); job.closeModel(); job.run(); model = job.getReadOnlyModel(); Resource roles = model.getResource(objPid.getRepositoryPath()); assertTrue(roles.hasProperty(none.getProperty(), AUTHENTICATED_PRINC)); assertTrue(roles.hasProperty(none.getProperty(), PUBLIC_PRINC)); assertFalse(fileResc.hasProperty(none.getProperty())); }
Source:
<code>public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Long.valueOf(timeOut).hashCode(); <START> return result; <END> }</code><technical_language>return 31*super.hashCode() + timeOut;</technical_language>

Target:
public int hashCode() { return 31 * super.hashCode() + Long.valueOf(timeOut).hashCode(); }
Source:
<code>private void validateFields(final String projectName, final String projectDescription, final Command successCallback) { if (projectName == null || projectName.trim().isEmpty()) { hideLoadingBox(); notificationEvent.fire(new NotificationEvent(view.getEmptyNameMessage(), NotificationEvent.NotificationType.ERROR)); return; } validationService.call((Boolean isValid) -> { if (Boolean.TRUE.equals(isValid)) { if (successCallback != null) { successCallback.execute(); } } else { hideLoadingBox(); notificationEvent.fire(new NotificationEvent(view.getInvalidNameMessage(), NotificationEvent.NotificationType.ERROR)); } <START> }).validateArtifactId(projectName); <END> }</code><technical_language>[call](<LINK_0> validationService.isProjectNameValid(...) validation of project names changed</technical_language>

Target:
private void validateFields(final String projectName, final String projectDescription, final Command successCallback) { if (projectName == null || projectName.trim().isEmpty()) { hideLoadingBox(); notificationEvent.fire(new NotificationEvent(view.getEmptyNameMessage(), NotificationEvent.NotificationType.ERROR)); return; } validationService.call((Boolean isValid) -> { final String sanitizeProjectName = NewProjectUtils.sanitizeProjectName(projectName); if (Boolean.TRUE.equals(isValid) && !sanitizeProjectName.isEmpty()) { if (successCallback != null) { successCallback.execute(); } } else { hideLoadingBox(); notificationEvent.fire(new NotificationEvent(view.getInvalidNameMessage(), NotificationEvent.NotificationType.ERROR)); } }).isProjectNameValid(projectName); }
Source:
<code>public static <T> T loadFirst(Class<T> spi) { ServiceLoader<T> serviceLoader = ServiceLoader.load(spi); if (serviceLoader.iterator().hasNext()) { <START> return serviceLoader.iterator().next(); <END> } else { throw new UnavailableImplementationException(spi); } }</code><technical_language>this is a public API class, I a notNull assertion spi</technical_language>

Target:
public static <T> T loadFirst(Class<T> spi) { Assert.notNull(spi, "Parameter 'spi' must not be null."); ServiceLoader<T> serviceLoader = ServiceLoader.load(spi); if (serviceLoader.iterator().hasNext()) { return serviceLoader.iterator().next(); } else { throw new UnavailableImplementationException(spi); } }
Source:
<code>protected TokenManager getLexerForSource(SourceCode sourceCode) { <START> return new JspTokenManager(new CharSequenceReader(sourceCode.getCodeBuffer())); <END> }</code><technical_language>Hm... lost feature skip BOM... simplest probably: java StringBuilder buffer = sourceCode.getCodeBuffer(); Reader reader; if (buffer.charAt(0) == '\uFEFF') { // skip BOM if present reader = new CharSequenceReader(buffer.substring(1)); } else { reader = new CharSequenceReader(buffer); } return new JspTokenManager(reader);</technical_language>

Target:
protected TokenManager getLexerForSource(SourceCode sourceCode) { return new JspTokenManager(IOUtil.skipBOM(new CharSequenceReader(sourceCode.getCodeBuffer()))); }
Source:
<code>public ParsingHybridProperty( Parser<? extends ModelT> parser, PrettyPrinter<? super ModelT> printer, ObservableList<Token> tokens, ParsingContextFactory parsingContextFactory) { myParser = parser; myPrinter = printer; mySourceTokens = tokens; myParsingContextFactory = parsingContextFactory; initUpdate(); myValue = parse(); update(); mySourceTokens.addListener(new CollectionListener<Token>() { @Override public void onItemAdded(final CollectionItemEvent<? extends Token> event) { if (event.getNewItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.add(event.getIndex(), event.getNewItem()); } }); } else { update(); } } @Override public void onItemSet(final CollectionItemEvent<? extends Token> event) { if (event.getNewItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.set(event.getIndex(), event.getNewItem()); } }); if (!(event.getOldItem() instanceof CommentToken)) { update(); } } else if (event.getOldItem() instanceof CommentToken) { <START> myPrettyTokens.set(event.getIndex(), event.getNewItem()); <END> update(); } else { update(); } } @Override public void onItemRemoved(final CollectionItemEvent<? extends Token> event) { if (event.getOldItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.remove(event.getIndex()); } }); } else { update(); } } }); }</code><technical_language>tests pass, curious missing executeInUpdate()</technical_language>

Target:
public ParsingHybridProperty( Parser<? extends ModelT> parser, PrettyPrinter<? super ModelT> printer, ObservableList<Token> tokens, ParsingContextFactory parsingContextFactory) { myParser = parser; myPrinter = printer; mySourceTokens = tokens; myParsingContextFactory = parsingContextFactory; initUpdate(); myValue = parse(); update(); mySourceTokens.addListener(new CollectionListener<Token>() { @Override public void onItemAdded(final CollectionItemEvent<? extends Token> event) { if (event.getNewItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.add(event.getIndex(), event.getNewItem()); } }); } else { update(); } } @Override public void onItemSet(final CollectionItemEvent<? extends Token> event) { if (event.getNewItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.set(event.getIndex(), event.getNewItem()); } }); if (!(event.getOldItem() instanceof CommentToken)) { update(); } } else if (event.getOldItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.set(event.getIndex(), event.getNewItem()); } }); update(); } else { update(); } } @Override public void onItemRemoved(final CollectionItemEvent<? extends Token> event) { if (event.getOldItem() instanceof CommentToken) { executeInUpdate(new Runnable() { @Override public void run() { myPrettyTokens.remove(event.getIndex()); } }); } else { update(); } } }); }
Source:
<code>public boolean test(BlockVector3 vector) { <START> Map<String, Object> existingStates = getExtent().getBlock(vector).getStates().entrySet().stream() <END> .collect(Collectors.toMap(p -> p.getKey().getName(), Entry::getValue)); return states.entrySet().stream().allMatch(matchState -> existingStates.containsKey(matchState.getKey()) && existingStates.get(matchState.getKey()).toString().equals(matchState.getValue())); }</code><technical_language>I this caching, called often. another performant do I of</technical_language>

Target:
public boolean test(BlockVector3 vector) { BlockState block = getExtent().getBlock(vector); final Map<Property<Object>, Object> checkProps = cache .computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b))); if (strict && checkProps.isEmpty()) { return false; } return checkProps.entrySet().stream() .allMatch(entry -> block.getState(entry.getKey()) == entry.getValue()); }
Source:
<code><START> public static boolean isDiskInterfaceSupportedByOs (DiskInterface diskInterface, int osId, Version version) { <END> List<DiskInterface> supportedDiskInterfaces = getSupportedDiskInterfaces(osId, version); if (!supportedDiskInterfaces.contains(diskInterface)) { return false; } return true; }</code><technical_language>This method be: return getSupportedDiskInterfaces(osId, version).contains(diskInterface);</technical_language>

Target:
public static boolean isDiskInterfaceSupportedByOs(DiskInterface diskInterface, int osId, Version version) { return getOsRepository().getDiskInterfaces(osId, version).contains(diskInterface.name()); }
Source:
<code>private void restartRoom() { fireEvent(new ControllerEvent(this, ControllerEvent.RESTARTROOM, "Room restarted")); Model.restartRoom(); ArrayList<PowerUp> powers = Model.getPowerUps(); <START> for(int i = 0; i < powers.size(); i++) { <END> powers.get(i).reset(); } Model.clearPowerUps(); Model.clearShortPower(); getTimers().restartTimer(); collisionHandler.addCollidable(Model.getCurrentRoom().getCollidables()); }</code><technical_language>foreach</technical_language>

Target:
private void restartRoom() { fireEvent(new ControllerEvent(this, ControllerEvent.RESTARTROOM, "Room restarted")); Model.restartRoom(); ArrayList<PowerUp> powers = Model.getPowerUps(); for(PowerUp power: powers) { power.reset(); } Model.clearPowerUps(); Model.clearShortPower(); getTimers().restartTimer(); collisionHandler.addCollidable(Model.getCurrentRoom().getCollidables()); }
Source:
<code>public Promise<String> getValue() { final Resource[] resources = appContext.getResources(); if (resources == null || resources.length != 1) { return promises.resolve(""); } final Resource resource = resources[0]; final Optional<Project> project = resource.getRelatedProject(); if (!JavaUtil.isJavaProject(project.get())) { return promises.resolve(""); } final String projectPath = project.get().getLocation().toString(); return classpathContainer.getClasspathEntries(projectPath).then(new Function<List<ClasspathEntryDto>, String>() { @Override public String apply(List<ClasspathEntryDto> arg) throws FunctionException { classpathResolver.resolveClasspathEntries(arg); Set<String> libs = classpathResolver.getLibs(); <START> StringBuilder classpath = new StringBuilder(""); <END> for (String lib : libs) { classpath.append(lib).append(':'); } if (classpath.toString().isEmpty()) { classpath.append(appContext.getProjectsRoot().toString()).append(projectPath).append(':'); } return classpath.toString(); } }); }</code><technical_language>StringBuilder ""</technical_language>

Target:
public Promise<String> getValue() { final Resource[] resources = appContext.getResources(); if (resources == null || resources.length != 1) { return promises.resolve(""); } final Resource resource = resources[0]; final Optional<Project> project = resource.getRelatedProject(); if (!JavaUtil.isJavaProject(project.get())) { return promises.resolve(""); } final String projectPath = project.get().getLocation().toString(); return classpathContainer.getClasspathEntries(projectPath).then(new Function<List<ClasspathEntryDto>, String>() { @Override public String apply(List<ClasspathEntryDto> arg) throws FunctionException { classpathResolver.resolveClasspathEntries(arg); Set<String> libs = classpathResolver.getLibs(); StringBuilder classpath = new StringBuilder(); for (String lib : libs) { classpath.append(lib).append(':'); } if (classpath.toString().isEmpty()) { classpath.append(appContext.getProjectsRoot().toString()).append(projectPath).append(':'); } return classpath.toString(); } }); }
Source:
<code>private Decrypt decryptor() { final String host = System.getProperty(HOST_KEY, ""); Decrypt result; if (host.isEmpty()) { result = new Decrypt(this.profile); } else { final String port = System.getProperty(PORT_KEY, ""); int portValue = DEFAULT_PORT; if (!port.isEmpty()) { try { portValue = Integer.parseInt(port); <START> } catch (final NumberFormatException exception) { <END> throw new IllegalStateException( Joiner.on(' ').join( "Can't parse proxy port", port ), exception ); } } result = new Decrypt(this.profile, host, portValue); } return result; }</code><technical_language>is for? unchecked exception, do catch here</technical_language>

Target:
private Decrypt decryptor() { return new Decrypt( this.profile, System.getProperty(HOST_KEY, ""), Integer.parseInt(System.getProperty(PORT_KEY, DEFAULT_PORT)) ); }
Source:
<code>public Mono<ResponseEntity<?>> cleanupWorkflows( @RequestBody @ApiParam(value = "Parameters for the maintenance process", required = true) MaintenanceRequest request) { return handleExceptions(() -> { MaintenanceConfiguration configuration = converter.convert(request); MaintenanceResults results = maintenanceService.cleanupWorkflows(configuration); <START> return scheduler.wrapBlocking(() -> ok(converter.convert(results))); <END> }); }</code><technical_language>I blocking operation is maintenanceService.cleanupWorkflows, result conversion</technical_language>

Target:
public Mono<ResponseEntity<?>> cleanupWorkflows( @RequestBody @ApiParam(value = "Parameters for the maintenance process", required = true) MaintenanceRequest request) { return handleExceptions(() -> wrapBlocking(() -> { MaintenanceConfiguration configuration = converter.convert(request); MaintenanceResults results = maintenanceService.cleanupWorkflows(configuration); return ok(converter.convert(results)); })); }
Source:
<code>public void maybeUpdateGCGraceSeconds() { logger.info("Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated"); Stopwatch stopwatch = Stopwatch.createStarted(); Map<String, String> replication = session.getCluster().getMetadata().getKeyspace(keyspace).getReplication(); String replicationFactor = replication.get("replication_factor"); Completable check; <START> if (getClusterSize() == 1 || replicationFactor.equals("1")) { <END> check = updateAllGCGraceSeconds(0); } else { check = Completable.merge(configurationService.load("org.hawkular.metrics").map(config -> { int gcGraceSeconds = Integer.parseInt(config.get("gcGraceSeconds", Integer.toString( DEFAULT_GC_GRACE_SECONDS))); return updateAllGCGraceSeconds(gcGraceSeconds); })); } check.subscribe( () -> { stopwatch.stop(); logger.info("Finished gc_grace_seconds updates in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms"); updatesFinished.ifPresent(subject -> subject.onNext(null)); }, t -> { logger.warn("There was an error checking and updating gc_grace_seconds"); updatesFinished.ifPresent(subject -> subject.onNext(t)); } ); }</code><technical_language>Is replication factor equal 1 now</technical_language>

Target:
public void maybeUpdateGCGraceSeconds() { logger.info("Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated"); Stopwatch stopwatch = Stopwatch.createStarted(); Map<String, String> replication = session.getCluster().getMetadata().getKeyspace(keyspace).getReplication(); String replicationFactor = replication.get("replication_factor"); Completable check; if (getClusterSize() == 1 || replicationFactor.equals("1")) { check = updateAllGCGraceSeconds(0); } else { check = Completable.merge(configurationService.load("org.hawkular.metrics", "gcGraceSeconds") .switchIfEmpty(Observable.just(Integer.toString(DEFAULT_GC_GRACE_SECONDS))) .map(property -> { int gcGraceSeconds = Integer.parseInt(property); return updateAllGCGraceSeconds(gcGraceSeconds); })); } check.subscribe( () -> { stopwatch.stop(); logger.info("Finished gc_grace_seconds updates in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms"); updatesFinished.ifPresent(subject -> subject.onNext(null)); }, t -> { logger.warn("There was an error checking and updating gc_grace_seconds"); updatesFinished.ifPresent(subject -> subject.onNext(t)); } ); }
Source:
<code><START> void testDescribeSnapshotsWithFilterInvalid() { <END> String region = defaultRegion; SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { Snapshot snapshot = allResults.last(); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegionWithFilter(region, ImmutableMultimap.<String, String>builder() .put("invalid-filter", snapshot.getId()).build())); } }</code><technical_language>[minor] "WithInvalidFilter"</technical_language>

Target:
void testDescribeSnapshotsWithFilterInvalid() { String region = defaultRegion; SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (!allResults.isEmpty()) { Snapshot snapshot = allResults.last(); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegionWithFilter(region, ImmutableMultimap.<String, String>builder() .put("invalid-filter", snapshot.getId()).build())); } }
Source:
<code>public void testClusterRestartWithPersistence() throws Exception { <START> persistence = true; <END> startGrids(2); grid(0).cluster().state(ClusterState.ACTIVE); startCollectStatistics(); stopAllGrids(false); startGrids(2); grid(0).cluster().state(ClusterState.ACTIVE); waitForStatisticsEnabled(true); }</code><technical_language>clear persistence in finally block</technical_language>

Target:
public void testClusterRestartWithPersistence() throws Exception { startGrids(2); if (persistence) grid(0).cluster().state(ClusterState.ACTIVE); startCollectStatistics(); stopAllGrids(false); startGrids(2); if (persistence) grid(0).cluster().state(ClusterState.ACTIVE); waitForStatisticsEnabled(persistence); }
Source:
<code>public Table listStepExecutions( @CliOption(mandatory = true, key = { "", "id" }, help = "the id of the job execution") long jobExecutionId) { final List<StepExecutionInfoResource> stepExecutions = jobOperations().listStepExecutions(jobExecutionId); final Table table = new Table(); table.addHeader(1, new TableHeader("Id")) .addHeader(2, new TableHeader("Step Name")) .addHeader(3, new TableHeader("Job Exec ID")) .addHeader(4, new TableHeader("Start Time (UTC)")) .addHeader(5, new TableHeader("End Time (UTC)")) .addHeader(6, new TableHeader("Status")); for (StepExecutionInfoResource stepExecutionInfoResource : stepExecutions) { final String utcStartTime = CommonUtils.getUtcTime(stepExecutionInfoResource.getStepExecution().getStartTime()); String utcEndTime = ""; if (stepExecutionInfoResource.getStepExecution().getEndTime() != null) { CommonUtils.getUtcTime(stepExecutionInfoResource.getStepExecution().getEndTime()); <START> } <END> final TableRow row = new TableRow(); row.addValue(1, String.valueOf(stepExecutionInfoResource.getStepExecution().getId())) .addValue(2, stepExecutionInfoResource.getStepExecution().getStepName()) .addValue(3, String.valueOf(stepExecutionInfoResource.getJobExecutionId())) .addValue(4, utcStartTime) .addValue(5, utcEndTime) .addValue(6, stepExecutionInfoResource.getStepExecution().getStatus().name()); table.getRows().add(row); } return table; }</code><technical_language>I intended assigning output of CommonUtils.getUtcTime utcEndTime, assigned here. do this suggestion? final Date endTimeDate = stepExecutionInfoResource.getStepExecution().getEndTime(); final String utcEndTime = endTimeDate == null ? "" : CommonUtils.getUtcTime(endTimeDate); This invoke stepExecutionInfoResource.getStepExecution().getEndTime() if is null</technical_language>

Target:
public Table listStepExecutions( @CliOption(mandatory = true, key = { "", "id" }, help = "the id of the job execution") long jobExecutionId) { final List<StepExecutionInfoResource> stepExecutions = jobOperations().listStepExecutions(jobExecutionId); final Table table = new Table(); table.addHeader(1, new TableHeader("Id")) .addHeader(2, new TableHeader("Step Name")) .addHeader(3, new TableHeader("Job Exec ID")) .addHeader(4, new TableHeader("Start Time (UTC)")) .addHeader(5, new TableHeader("End Time (UTC)")) .addHeader(6, new TableHeader("Status")); for (StepExecutionInfoResource stepExecutionInfoResource : stepExecutions) { final String utcStartTime = CommonUtils.getUtcTime(stepExecutionInfoResource.getStepExecution().getStartTime()); final Date endTimeDate = stepExecutionInfoResource.getStepExecution().getEndTime(); final String utcEndTime = (endTimeDate == null) ? "" : CommonUtils.getUtcTime(endTimeDate); final TableRow row = new TableRow(); row.addValue(1, String.valueOf(stepExecutionInfoResource.getStepExecution().getId())) .addValue(2, stepExecutionInfoResource.getStepExecution().getStepName()) .addValue(3, String.valueOf(stepExecutionInfoResource.getJobExecutionId())) .addValue(4, utcStartTime) .addValue(5, utcEndTime) .addValue(6, stepExecutionInfoResource.getStepExecution().getStatus().name()); table.getRows().add(row); } return table; }
Source:
<code>JavaType getReturnType(@Nullable JavaType returnType, JavaType defSite, JavaType callSite, TypeSubstitution substitution, JavaSymbol.MethodJavaSymbol method) { JavaType resultType = returnType; if (method.isConstructor()) { if (constructParametrizedTypeWithoutSubstitution(method, defSite)) { resultType = applySubstitution(defSite, substitution); } else { return defSite; } } <START> if(defSite == symbols.objectType && "getClass".equals(method.name())) { <END> TypeJavaSymbol classSymbol = symbols.classType.symbol; resultType = parametrizedTypeCache.getParametrizedTypeType(classSymbol, new TypeSubstitution().add(classSymbol.typeVariableTypes.get(0), callSite.erasure())); } resultType = applySiteSubstitution(resultType, defSite); if (callSite != defSite) { resultType = applySiteSubstitution(resultType, callSite); } resultType = applySubstitution(resultType, substitution); if (!isReturnTypeCompletelySubstituted(resultType, method.typeVariableTypes) || (method.isConstructor() && !isReturnTypeCompletelySubstituted(resultType, defSite.symbol.typeVariableTypes))) { resultType = symbols.deferedType(resultType); } return resultType; }</code><technical_language>![MAJOR](<LINK_0> Change this comparison equals method. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
JavaType getReturnType(@Nullable JavaType returnType, JavaType defSite, JavaType callSite, TypeSubstitution substitution, JavaSymbol.MethodJavaSymbol method) { JavaType resultType = returnType; if (method.isConstructor()) { if (constructParametrizedTypeWithoutSubstitution(method, defSite)) { resultType = applySubstitution(defSite, substitution); } else { return defSite; } } if(defSite == symbols.objectType && "getClass".equals(method.name())) { TypeJavaSymbol classSymbol = symbols.classType.symbol; JavaType wildcardType = parametrizedTypeCache.getWildcardType(callSite.erasure(), WildCardType.BoundType.EXTENDS); resultType = parametrizedTypeCache.getParametrizedTypeType(classSymbol, new TypeSubstitution().add(classSymbol.typeVariableTypes.get(0), wildcardType)); } resultType = applySiteSubstitution(resultType, defSite); if (callSite != defSite) { resultType = applySiteSubstitution(resultType, callSite); } resultType = applySubstitution(resultType, substitution); if (!isReturnTypeCompletelySubstituted(resultType, method.typeVariableTypes) || (method.isConstructor() && !isReturnTypeCompletelySubstituted(resultType, defSite.symbol.typeVariableTypes))) { resultType = symbols.deferedType(resultType); } return resultType; }
Source:
<code>private void validateFilter() { String filter = getProperty(NotificationProperties.FILTER, true); <START> if (filter != null) <END> FirstMatchSimpleFilter.parse(filter); }</code><technical_language>I is some findbugs issue sure</technical_language>

Target:
private void validateFilter() { String filter = getProperty(NotificationProperties.FILTER, true); if (filter != null) { FirstMatchSimpleFilter.parse(filter); } }
Source:
<code>public ObjectMapper getObjectMapper() { <START> return objectMapper; <END> }</code><technical_language>add this (also below)</technical_language>

Target:
public ObjectMapper getObjectMapper() { return this.objectMapper; }
Source:
<code><START> public <K, V> BasicCache<K, V> getCache(String cacheName) { <END> return remoteCacheManager.getCache(cacheName); }</code><technical_language>This method return RemoteCache<K, V></technical_language>

Target:
public <K, V> RemoteCache<K, V> getCache(String cacheName) { return this.remoteCacheManager.getCache(cacheName); }
Source:
<code>public MemoryAddressHash(int pointers) { this.pointerCount = nextPowerOfTwo(pointers); long bytes = ((long) pointerCount) << 3; <START> memory = OffHeapMemory.allocate(bytes); <END> UNSAFE.setMemory(memory, bytes, (byte) 0); }</code><technical_language>happy I mixed mixing static non-static methods in OffHeapMemory, of static</technical_language>

Target:
public MemoryAddressHash(int pointers) { this.pointerCount = nextPowerOfTwo(pointers); long bytes = ((long) pointerCount) << 3; memory = MEMORY.allocate(bytes); UNSAFE.setMemory(memory, bytes, (byte) 0); }
Source:
<code>public void testTranslateServiceWithManagementStatisticsUnspecifiedAndNoCaches() { Jsr107ServiceConfigurationParser configTranslator = new Jsr107ServiceConfigurationParser(); boolean jsr107CompliantAtomics = false; <START> Map<String, String> templateMap = new ConcurrentHashMap<>(); <END> Jsr107Configuration serviceCreationConfiguration = new Jsr107Configuration("tiny-template", templateMap, jsr107CompliantAtomics, ConfigurationElementState.UNSPECIFIED, ConfigurationElementState.UNSPECIFIED); Node retElement = configTranslator.unparseServiceCreationConfiguration(serviceCreationConfiguration); assertThat(retElement, is(notNullValue())); assertAttributeItemsWithManagementStatisticsUnspecifiedAndNoCaches(retElement); assertThat(retElement.getNodeName(), is("jsr107:defaults")); assertThat(retElement.getFirstChild(), is(nullValue())); }</code><technical_language>Again. CHM</technical_language>

Target:
public void testTranslateServiceWithManagementStatisticsUnspecifiedAndNoCaches() { Jsr107ServiceConfigurationParser configTranslator = new Jsr107ServiceConfigurationParser(); boolean jsr107CompliantAtomics = false; Map<String, String> templateMap = new HashMap<>(); Jsr107Configuration serviceCreationConfiguration = new Jsr107Configuration("tiny-template", templateMap, jsr107CompliantAtomics, ConfigurationElementState.UNSPECIFIED, ConfigurationElementState.UNSPECIFIED); Node retElement = configTranslator.unparseServiceCreationConfiguration(serviceCreationConfiguration); assertThat(retElement, is(notNullValue())); assertAttributeItemsWithManagementStatisticsUnspecifiedAndNoCaches(retElement); assertThat(retElement.getNodeName(), is("jsr107:defaults")); assertThat(retElement.getFirstChild(), is(nullValue())); }
Source:
<code>private void fireNewSessionEvents() { if (!isManagingZkConnection()) { return; } final String sessionId = getHexSessionId(); for (final IZkStateListener stateListener : _stateListener) { _eventThread .send(new ZkEventThread.ZkEvent("New session event sent to " + stateListener, sessionId) { @Override public void run() throws Exception { <START> if (_syncOnNewSession) { <END> LOG.info("syncOnNewSession with sessionId {}", sessionId); final ZkConnection zkConnection = (ZkConnection) getConnection(); if (zkConnection == null || zkConnection.getZookeeper() == null) { throw new IllegalStateException( "ZkConnection is in invalid state! Please close this ZkClient and create new client."); } final String syncPath = new String("/"); zkConnection.getZookeeper().sync(syncPath, new AsyncCallback.VoidCallback() { @Override public void processResult(int rt, String s, Object ctx) { LOG.info("sycnOnNewSession with sessionID async return code: {}", sessionId, rt); } }, syncPath); } stateListener.handleNewSession(sessionId); } }); } }</code><technical_language>Please extract a method for sync</technical_language>

Target:
private void fireNewSessionEvents() { if (!isManagingZkConnection()) { return; } final String sessionId = getHexSessionId(); if (SYNC_ON_SESSION) { final ZooKeeper zk = ((ZkConnection) getConnection()).getZookeeper(); _eventThread.send(new ZkEventThread.ZkEvent("Sync call before new session event of session " + sessionId, sessionId) { @Override public void run() throws Exception { if (issueSync(zk) == false) { LOG.warn("\"Failed to call sync() on new session {}", sessionId); } } }); } for (final IZkStateListener stateListener : _stateListener) { _eventThread .send(new ZkEventThread.ZkEvent("New session event sent to " + stateListener, sessionId) { @Override public void run() throws Exception { stateListener.handleNewSession(sessionId); } }); } }
Source:
<code>private void addCapabilities(List<?> result, Schema s) { if (s == null) { return; } Map<String, Action> actions = s.getResourceActions(); if (actions == null || actions.size() == 0) { return; } boolean addCapability = false; for (Map.Entry<String, Action> entry : actions.entrySet()) { Map<String, Object> attributes = entry.getValue().getAttributes(); if (attributes == null || attributes.size() == 0) { continue; } String capability = ObjectUtils.toString(attributes.get(ObjectMetaDataManager.CAPABILITY), null); if (ObjectMetaDataManager.MODIFY_INFRA_CAPABILITY.equals(capability)) { addCapability = true; break; } } <START> if (addCapability && infraAccess.canModifyInfrastructure((Policy) ApiContext.getContext().getPolicy())) { <END> for (Object r : result) { ApiContext.getContext().addCapability(r, ObjectMetaDataManager.MODIFY_INFRA_CAPABILITY); } } }</code><technical_language>Nit: check for infraAccess.canModifyInfrastructure((Policy) ApiContext.getContext().getPolicy()) moved up, is false, return immediately? This save a bit capabilities</technical_language>

Target:
private void addCapabilities(List<?> result, Schema s) { if (s == null) { return; } Map<String, Action> actions = s.getResourceActions(); if (actions == null || actions.size() == 0) { return; } if (!infraAccess.canModifyInfrastructure((Policy) ApiContext.getContext().getPolicy())) { return; } boolean addCapability = false; for (Map.Entry<String, Action> entry : actions.entrySet()) { Map<String, Object> attributes = entry.getValue().getAttributes(); if (attributes == null || attributes.size() == 0) { continue; } String capability = ObjectUtils.toString(attributes.get(ObjectMetaDataManager.CAPABILITY), null); if (ObjectMetaDataManager.MODIFY_INFRA_CAPABILITY.equals(capability)) { addCapability = true; break; } } if (addCapability) { for (Object r : result) { ApiContext.getContext().addCapability(r, ObjectMetaDataManager.MODIFY_INFRA_CAPABILITY); } } }
Source:
<code>public boolean containsFrom(final ActivationState state) { <START> return transitions.stream().anyMatch(tr -> Objects.equals(tr.from, state)); <END> }</code><technical_language>This transitionMap instead</technical_language>

Target:
public boolean containsFrom(final ActivationState state) { return transitionMap.containsKey(state) && !transitionMap.get(state).isEmpty(); }
Source:
<code>public Map<String, String> getOptions() { <START> Map<String, String> convertedMap = new HashMap(); <END> Set<QName> keys = options.keySet(); for (QName key : keys) { convertedMap.put(key.getNamespaceURI(), options.get(key)); } return convertedMap; }</code><technical_language><> here</technical_language>

Target:
public Map<String, String> getOptions() { Map<String, String> convertedMap = new HashMap<>(); Set<QName> keys = options.keySet(); for (QName key : keys) { convertedMap.put(key.getNamespaceURI(), options.get(key)); } return convertedMap; }
Source:
<code>private RollingUpdateOp rollingUpdateDeploy(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { <START> final List<ZooKeeperOperation> operations = Lists.newArrayList(); <END> final Deployment deployment = Deployment.of(deploymentGroup.getJobId(), Goal.START, Deployment.EMTPY_DEPLOYER_USER, this.name, deploymentGroup.getName()); try { operations.addAll(getDeployOperations(client, host, deployment, Job.EMPTY_TOKEN)); } catch (JobDoesNotExistException | TokenVerificationException | HostNotFoundException | JobPortAllocationConflictException e) { return opFactory.taskError(e, host); } catch (JobAlreadyDeployedException e) { } return opFactory.nextTask(operations); }</code><technical_language>spurious changes changed behaviour in this file. Necessary</technical_language>

Target:
private RollingUpdateOp rollingUpdateDeploy(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final Deployment deployment = Deployment.of(deploymentGroup.getJobId(), Goal.START, Deployment.EMTPY_DEPLOYER_USER, this.name, deploymentGroup.getName()); try { return opFactory.nextTask(getDeployOperations(client, host, deployment, Job.EMPTY_TOKEN)); } catch (JobDoesNotExistException e) { return opFactory.taskError(e, host, RollingUpdateError.JOB_NOT_FOUND); } catch (TokenVerificationException e) { return opFactory.taskError(e, host, RollingUpdateError.TOKEN_VERIFICATION_ERROR); } catch (HostNotFoundException e) { return opFactory.taskError(e, host, RollingUpdateError.HOST_NOT_FOUND); } catch (JobPortAllocationConflictException e) { return opFactory.taskError(e, host, RollingUpdateError.PORT_CONFLICT); } catch (JobAlreadyDeployedException e) { return opFactory.nextTask(); } }
Source:
<code>public PayaraNotification build() { <START> return notification; <END> }</code><technical_language>suggested in notification this IMHO construct a immutable object build()</technical_language>

Target:
public PayaraNotification build() { return new PayaraNotification(eventType, serverName, hostName, domainName, instanceName, subject, message, data, notifierWhitelist, notifierBlacklist); }
Source:
<code>private void checkAndNotify( final AsyncFileEntry parent, final List<AsyncFileEntry> previous, @Nullable final File[] files, final AsyncFileAlterationListener listenerCopy) { if (files == null) { return; } int c = 0; for (final AsyncFileEntry entry : previous) { while (c < files.length && failedAndNotUpdated(files[c])) { c++; } <START> if (c < files.length && !failedAndNotUpdated(files[c])) { <END> while (c < files.length && entry.compareToFile(files[c]) > 0) { doCreate(new AsyncFileEntry(parent, files[c]), listenerCopy); c++; } } if (c < files.length && entry.compareToFile(files[c]) == 0) { doMatch(entry, listenerCopy); checkAndNotify(entry, entry.getChildren(), listFiles(files[c]), listenerCopy); c++; } else { if (!entry.checkNetwork()) { return; } checkAndNotify(entry, entry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, listenerCopy); doDelete(entry, listenerCopy); } } for (; c < files.length; c++) { if (!failedAndNotUpdated(files[c])) { doCreate(new AsyncFileEntry(parent, files[c]), listenerCopy); } } }</code><technical_language>Do need condition, !failedAndNotUpdated(files[c])? while loop this satisfy condition (c < file length) if line 391's failedAndNotUpdated false</technical_language>

Target:
private void checkAndNotify( final AsyncFileEntry parent, final List<AsyncFileEntry> previous, @Nullable final File[] files, final AsyncFileAlterationListener listenerCopy) { if (files == null) { return; } int c = 0; for (final AsyncFileEntry entry : previous) { while (c < files.length && entry.compareToFile(files[c]) > 0) { doCreate(new AsyncFileEntry(parent, files[c]), listenerCopy); c++; } if (c < files.length && entry.compareToFile(files[c]) == 0) { doMatch(entry, listenerCopy); checkAndNotify(entry, entry.getChildren(), listFiles(files[c]), listenerCopy); c++; } else { if (!entry.checkNetwork()) { return; } checkAndNotify(entry, entry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, listenerCopy); doDelete(entry, listenerCopy); } } for (; c < files.length; c++) { doCreate(new AsyncFileEntry(parent, files[c]), listenerCopy); } }
Source:
<code>public void closeIdleConnectionsWhenServerIsStoppedWhileThereIsAnInflightRequest() throws IOException, MuleException, InterruptedException { Thread stopper = new MuleContextStopper(); try (Socket idlePersistentConnection = generateIdlePersistentConnection()) { try (Socket slowRequestConnection = new Socket("localhost", dynamicPort.getNumber())) { sendRequest(slowRequestConnection, "/slow"); sleep(100); stopper.start(); <START> new PollingProber(300, 50).check(new ConnectionClosedProbe(idlePersistentConnection)); <END> } } finally { stopper.join(); } }</code><technical_language>constants</technical_language>

Target:
public void closeIdleConnectionsWhenServerIsStoppedWhileThereIsAnInflightRequest() throws IOException, MuleException, InterruptedException { Thread stopper = new MuleContextStopper(); try (Socket idlePersistentConnection = generateIdlePersistentConnection()) { try (Socket slowRequestConnection = new Socket("localhost", dynamicPort.getNumber())) { sendRequest(slowRequestConnection, SLOW_PROCESSING_ENDPOINT); sleep(100); stopper.start(); new PollingProber(POLL_TIMEOUT_MILLIS, POLL_DELAY_MILLIS).check(new ConnectionClosedProbe(idlePersistentConnection)); } } finally { stopper.join(); } }
Source:
<code>public BithumbResponse( @JsonProperty("status") String status, @JsonProperty("message") String message, <START> @JsonProperty("data") D data) { <END> this.status = status; this.message = message; this.data = data; }</code><technical_language>if add this here: if (!StringUtils.equals(status, "0000")) { throw new ExceptionalReturnContentException("Got error status"); } rescu catch re-parse body BithumbException this eliminate need for checkResult method</technical_language>

Target:
public BithumbResponse( @JsonProperty("status") String status, @JsonProperty("message") String message, @JsonProperty("data") D data) { if (!StringUtils.equals(status, "0000")) { throw new ExceptionalReturnContentException(message); } this.status = status; this.message = message; this.data = data; }
Source:
<code>public void verifyTableRemoved() { waitForElementNotPresent(articleTableBy); <START> PageObjectLogging.log(commentAuthorLink, commentAuthorLink, true); <END> }</code><technical_language>put proper String's :)</technical_language>

Target:
public void verifyTableRemoved() { waitForElementNotPresent(articleTableBy); PageObjectLogging.log("verifyTableRemoved", "table was removedcd", true); }
Source:
<code>void setWappalyzer(boolean enabled) { if (this.enabled == enabled) { return; } this.enabled = enabled; wappalyzerParam.setEnabled(enabled); getPassiveScanner().setEnabled(enabled); try { <START> wappalyzerParam.getConfig().save(); <END> } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } getTechPanel().getEnableToggleButton().setSelected(enabled); }</code><technical_language>config explicitly saved (it is ZAP shuts down)</technical_language>

Target:
void setWappalyzer(boolean enabled) { if (this.enabled == enabled) { return; } this.enabled = enabled; wappalyzerParam.setEnabled(enabled); getPassiveScanner().setEnabled(enabled); if (View.isInitialised()) { getTechPanel().getEnableToggleButton().setSelected(enabled); } }
Source:
<code>protected byte[] toBytes(BulkRequest request) { BytesStreamOutput out = new BytesStreamOutput(); try { request.writeTo(out); <START> ByteArrayOutputStream out2 = new ByteArrayOutputStream(); <END> out.bytes().writeTo(out2); return out2.toByteArray(); } catch (IOException e) { throw new NuxeoException("Cannot write elasticsearch bulk request " + request, e); } }</code><technical_language>need a byte-like stream. do return BytesReference.toBytes(out.bytes()) that</technical_language>

Target:
protected byte[] toBytes(BulkRequest request) { BytesStreamOutput out = new BytesStreamOutput(); try { request.writeTo(out); return BytesReference.toBytes(out.bytes()); } catch (IOException e) { throw new NuxeoException("Cannot write elasticsearch bulk request " + request, e); } }
Source:
<code>private void handleConstructor(NewClassTree tree) { <START> if (PASSWORD_AUTHENTICATION_CONSTRUCTOR.matches(tree)) { <END> ExpressionTree secondArg = tree.arguments().get(1); if (secondArg.is(Tree.Kind.METHOD_INVOCATION)) { MethodInvocationTree mit = (MethodInvocationTree) secondArg; if (isCallOnStringLiteral(mit.methodSelect()) && STRING_TO_CHAR_ARRAY.matches(mit)) { reportIssue(secondArg); } } } }</code><technical_language>a matter of style, I reverse conditions nest 3 if statements</technical_language>

Target:
private void handleConstructor(NewClassTree tree) { if (!PASSWORD_AUTHENTICATION_CONSTRUCTOR.matches(tree)) { return; } ExpressionTree secondArg = tree.arguments().get(1); if (secondArg.is(Tree.Kind.METHOD_INVOCATION)) { MethodInvocationTree mit = (MethodInvocationTree) secondArg; if (isCallOnStringLiteral(mit.methodSelect()) && STRING_TO_CHAR_ARRAY.matches(mit)) { reportIssue(secondArg); } } }
Source:
<code>private void minimizeDependencies(HashMap<String, IPluginImport> usedPlugins, ArrayList<ImportPackageObject> usedPackages, IProgressMonitor monitor) { ListIterator<ImportPackageObject> li = usedPackages.listIterator(); while (li.hasNext()) { ImportPackageObject ipo = li.next(); String bundle = ipo.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE); if (usedPlugins.containsKey(bundle)) fList.add(ipo); } Iterator<String> it = usedPlugins.keySet().iterator(); Stack<String> plugins = new Stack<>(); while (it.hasNext()) plugins.push(it.next().toString()); while (!(plugins.isEmpty())) { String pluginId = plugins.pop(); IPluginModelBase base = PluginRegistry.findModel(pluginId); if (base == null) continue; IPluginImport[] imports = base.getPluginBase().getImports(); for (int j = 0; j < imports.length; j++) if (imports[j].isReexported()) { String reExportedId = imports[j].getId(); Object pluginImport = usedPlugins.remove(imports[j].getId()); if (pluginImport != null) { fList.add(pluginImport); <START> updateMonitor(monitor, fList.size()); <END> } plugins.push(reExportedId); } } }</code><technical_language>Consider reporting some progress</technical_language>

Target:
private void minimizeDependencies(HashMap<String, IPluginImport> usedPlugins, ArrayList<ImportPackageObject> usedPackages, IProgressMonitor monitor) { ListIterator<ImportPackageObject> li = usedPackages.listIterator(); while (li.hasNext()) { ImportPackageObject ipo = li.next(); String bundle = ipo.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE); if (usedPlugins.containsKey(bundle)) fList.add(ipo); } Iterator<String> it = usedPlugins.keySet().iterator(); Stack<String> plugins = new Stack<>(); while (it.hasNext()) plugins.push(it.next().toString()); SubMonitor subMonitor = SubMonitor.convert(monitor, plugins.size()); while (!(plugins.isEmpty())) { String pluginId = plugins.pop(); IPluginModelBase base = PluginRegistry.findModel(pluginId); if (base == null) continue; IPluginImport[] imports = base.getPluginBase().getImports(); SubMonitor iterationMonitor = subMonitor.newChild(1).setWorkRemaining(imports.length); for (int j = 0; j < imports.length; j++) { if (imports[j].isReexported()) { String reExportedId = imports[j].getId(); Object pluginImport = usedPlugins.remove(imports[j].getId()); if (pluginImport != null) { fList.add(pluginImport); updateMonitor(iterationMonitor, fList.size()); } plugins.push(reExportedId); } iterationMonitor.worked(1); } } }
Source:
<code>public void testAttachAfterKillingActive() throws Exception { int activeId = findActive(1).getAsInt(); int passiveId = findPassives(1)[0]; ActiveVoter activeVoter = new ActiveVoter("mvoter", new CompletableFuture<>(), Optional.empty(), getNode(1, activeId).getHostPort(), getNode(1, passiveId).getHostPort()); activeVoter.start(); startNode(1, 3); waitForDiagnostic(1, 3); assertThat(getUpcomingCluster("localhost", getNodePort(1, 3)).getNodeCount(), is(equalTo(1))); stopNode(1, activeId); waitForActive(1, passiveId); assertThat(configToolInvocation("attach", "-d", "localhost:" + getNodePort(1, passiveId), "-s", "localhost:" + getNodePort(1, 3)), is(successful())); Set<String> expectedRes = new HashSet<>(); expectedRes.add(getNode(1, activeId).getHostPort()); expectedRes.add(getNode(1, passiveId).getHostPort()); expectedRes.add(getNode(1, 3).getHostPort()); Thread.sleep(TOPOLOGY_FETCH_INTERVAL); assertThat(activeVoter.getExistingTopology(), is(expectedRes)); assertThat(activeVoter.getHeartbeatFutures().size(), is(3)); <START> activeVoter.stop(); <END> }</code><technical_language>a try/finally voter is stopped in case of a test failure</technical_language>

Target:
public void testAttachAfterKillingActive() throws Exception { ActiveVoter activeVoter = null; try { int activeId = findActive(1).getAsInt(); int passiveId = findPassives(1)[0]; activeVoter = new ActiveVoter("mvoter", new CompletableFuture<>(), Optional.empty(), getNode(1, activeId).getHostPort(), getNode(1, passiveId).getHostPort()); activeVoter.start(); startNode(1, 3); waitForDiagnostic(1, 3); assertThat(getUpcomingCluster("localhost", getNodePort(1, 3)).getNodeCount(), is(equalTo(1))); stopNode(1, activeId); waitForActive(1, passiveId); assertThat(configToolInvocation("attach", "-d", "localhost:" + getNodePort(1, passiveId), "-s", "localhost:" + getNodePort(1, 3)), is(successful())); Set<String> expectedRes = new HashSet<>(); expectedRes.add(getNode(1, activeId).getHostPort()); expectedRes.add(getNode(1, passiveId).getHostPort()); expectedRes.add(getNode(1, 3).getHostPort()); Thread.sleep(TOPOLOGY_FETCH_INTERVAL); assertThat(activeVoter.getExistingTopology(), is(expectedRes)); assertThat(activeVoter.getHeartbeatFutures().size(), is(3)); } finally { activeVoter.stop(); } }