auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> private void updateCpus(VmNumaNode vmNumaNode, int coresPerNode, Integer cpuCount) { <END> List<Integer> coreList = new ArrayList<Integer>(); for (int j = 0; j < coresPerNode; j++, cpuCount++) { coreList.add(cpuCount); } vmNumaNode.setCpuIds(coreList); }</code><technical_language>achieve intended - Integer is immutable cpuCount++ replace passed effect of this function 0</technical_language>

Target:
private Integer updateCpus(VmNumaNode vmNumaNode, int coresPerNode, Integer cpuCount) { List<Integer> coreList = new ArrayList<Integer>(); for (int j = 0; j < coresPerNode; j++, cpuCount++) { coreList.add(cpuCount); } vmNumaNode.setCpuIds(coreList); return cpuCount; }
Source:
<code>public void markContextAsDirtyWhenAnyEvictedPageHaveModificationTransactionHigherThenReader() throws IOException { TestVersionContext cursorContext = new TestVersionContext( () -> 5 ); VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier( cursorContext ); MuninnPageCache pageCache = createPageCache( fs, 2, 8, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, versionContextSupplier ); PagedFile pagedFile = pageCache.map( file( "a" ), 8 ); cursorContext.initWrite( 3 ); try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); cursor.putLong( 3 ); } cursorContext.initWrite( 13 ); try ( PageCursor cursor = pagedFile.io( 1, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); cursor.putLong( 4 ); } pageCache.pages.tryEvict( pageCache.grabFreeAndExclusivelyLockedPage( PageFaultEvent.NULL ), <START> EvictionRunEvent.NULL ); <END> cursorContext.initRead(); try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); assertEquals( 3, cursor.getLong() ); assertTrue( cursorContext.isDirty() ); } }</code><technical_language>sense try evict a free page. tryEvict return false page is exclusively locked. grabFreeAndExclusivelyLockedPage method do a cooperative eviction, evicted page chosen random. this test deterministic</technical_language>

Target:
public void markContextAsDirtyWhenAnyEvictedPageHaveModificationTransactionHigherThenReader() throws IOException { TestVersionContext cursorContext = new TestVersionContext( () -> 5 ); VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier( cursorContext ); MuninnPageCache pageCache = createPageCache( fs, 2, 8, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, versionContextSupplier ); PagedFile pagedFile = pageCache.map( file( "a" ), 8 ); cursorContext.initWrite( 3 ); try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); cursor.putLong( 3 ); } cursorContext.initWrite( 13 ); try ( PageCursor cursor = pagedFile.io( 1, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); cursor.putLong( 4 ); } assertEquals( 2, pageCache.evictPages( 2, 0, EvictionRunEvent.NULL ) ); cursorContext.initRead(); try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); assertEquals( 3, cursor.getLong() ); assertTrue( cursorContext.isDirty() ); } }
Source:
<code>public Class<? extends Scanner> getScannerClass(CatalogProtos.StoreType storeType) throws IOException { String handlerName = CatalogUtil.getStoreTypeString(storeType).toLowerCase(); Class<? extends Scanner> scannerClass = SCANNER_HANDLER_CACHE.get(handlerName); if (scannerClass == null) { scannerClass = conf.getClass( String.format("tajo.storage.scanner-handler.%s.class", handlerName), null, Scanner.class); <START> if (scannerClass != null) <END> SCANNER_HANDLER_CACHE.put(handlerName, scannerClass); } if (scannerClass == null) { throw new IOException("Unknown Storage Type: " + storeType.name()); } return scannerClass; }</code><technical_language>explain add IF statement</technical_language>

Target:
public Class<? extends Scanner> getScannerClass(CatalogProtos.StoreType storeType) throws IOException { String handlerName = CatalogUtil.getStoreTypeString(storeType).toLowerCase(); Class<? extends Scanner> scannerClass = SCANNER_HANDLER_CACHE.get(handlerName); if (scannerClass == null) { scannerClass = conf.getClass( String.format("tajo.storage.scanner-handler.%s.class", handlerName), null, Scanner.class); if (scannerClass != null) { SCANNER_HANDLER_CACHE.put(handlerName, scannerClass); } } if (scannerClass == null) { throw new UnsupportedException("Unsupported Storage Type: " + storeType.name()); } return scannerClass; }
Source:
<code>public void deleteMatchingPartitionsByTime(long upperLimit) throws IOException { if (upperLimit > 0 && upperLimit < Long.MAX_VALUE) { <START> PartitionFilter filter = PartitionFilter.builder().addRangeCondition("snapshot", null, upperLimit).build(); <END> Set<PartitionDetail> partitions = files.getPartitions(filter); for (PartitionDetail partition : partitions) { files.dropPartition(partition.getPartitionKey()); } } }</code><technical_language>put field name in a constant</technical_language>

Target:
public void deleteMatchingPartitionsByTime(long upperLimit) throws IOException { if (upperLimit > 0 && upperLimit < Long.MAX_VALUE) { PartitionFilter filter = PartitionFilter.builder().addRangeCondition(SNAPSHOT_FIELD, null, upperLimit).build(); Set<PartitionDetail> partitions = files.getPartitions(filter); for (PartitionDetail partition : partitions) { files.dropPartition(partition.getPartitionKey()); } } }
Source:
<code>public List<EmailWrapper> generateFeedbackSessionClosedEmails(FeedbackSessionAttributes session) { if (session.isPrivateSession()) { return new ArrayList<>(); } CourseAttributes course = coursesLogic.getCourse(session.getCourseId()); boolean isEmailNeededForStudents = false; try { isEmailNeededForStudents = fsLogic.isFeedbackSessionHasQuestionForStudents( session.getFeedbackSessionName(), session.getCourseId()); } catch (EntityDoesNotExistException e) { log.severe("Course " + session.getCourseId() + " does not exist or " + "session " + session.getFeedbackSessionName() + " does not exist"); } List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(session.getCourseId()); List<StudentAttributes> students = isEmailNeededForStudents ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>(); String template = EmailTemplates.USER_FEEDBACK_SESSION; List<EmailWrapper> emails = generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_CLOSED.getSubject(), EmailTemplates.FRAGMENT_CLOSED_SESSION_ADDITIONAL_INSTRUCTIONS); for (EmailWrapper email : emails) { email.setContent(email.getContent().replace("${status}", Const.StatusMessages.FEEDBACK_SESSION_CLOSED_MESSAGE)); <START> } <END> return emails; }</code><technical_language>replace ${status} field of template line 336</technical_language>

Target:
public List<EmailWrapper> generateFeedbackSessionClosedEmails(FeedbackSessionAttributes session) { if (session.isPrivateSession()) { return new ArrayList<>(); } CourseAttributes course = coursesLogic.getCourse(session.getCourseId()); boolean isEmailNeededForStudents = false; try { isEmailNeededForStudents = fsLogic.isFeedbackSessionHasQuestionForStudents( session.getFeedbackSessionName(), session.getCourseId()); } catch (EntityDoesNotExistException e) { log.severe("Course " + session.getCourseId() + " does not exist or " + "session " + session.getFeedbackSessionName() + " does not exist"); } List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(session.getCourseId()); List<StudentAttributes> students = isEmailNeededForStudents ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>(); String template = EmailTemplates.USER_FEEDBACK_SESSION .replace("${status}", FEEDBACK_STATUS_SESSION_CLOSED); return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_CLOSED.getSubject(), EmailTemplates.FRAGMENT_CLOSED_SESSION_ADDITIONAL_INSTRUCTIONS, FEEDBACK_ACTION_VIEW); }
Source:
<code>public URL locate(String resourcePath) throws MalformedURLException { if (StringUtils.isEmpty(resourcePath) || "/".equals(resourcePath)) { resourcePath = "index.html"; } if (resourcePath.startsWith("/")) { resourcePath = resourcePath.substring(1); } URL ret; try { ret = URI.create(swaggerUiRoot + resourcePath).toURL(); <START> } catch (Exception ex) { <END> throw new MalformedURLException(ex.getMessage()); } return ret; }</code><technical_language>URI.create thrown IllegalArgumentException exception, please instead of generic Exception? Thank you</technical_language>

Target:
public URL locate(String resourcePath) throws MalformedURLException { if (StringUtils.isEmpty(resourcePath) || "/".equals(resourcePath)) { resourcePath = "index.html"; } if (resourcePath.startsWith("/")) { resourcePath = resourcePath.substring(1); } URL ret; try { ret = URI.create(swaggerUiRoot + resourcePath).toURL(); } catch (IllegalArgumentException ex) { throw new MalformedURLException(ex.getMessage()); } return ret; }
Source:
<code>public void close() throws IOException { if (isOpen) { isOpen = false; if (numChunksWrittenOut != numChunksTotal) { <START> abort(new RouterException("The ReadableStreamChannel for blob data has been closed by the user.", <END> RouterErrorCode.ChannelClosed)); } } }</code><technical_language>.. closed unexpectedly ...</technical_language>

Target:
public void close() throws IOException { if (isOpen.compareAndSet(true, false)) { if (numChunksWrittenOut != numChunksTotal) { setOperationException(new RouterException( "The ReadableStreamChannel for blob data has been closed by the user before all chunks were written out.", RouterErrorCode.ChannelClosed)); } } }
Source:
<code>protected TypedQuery<T> createQuery(String jpql) { <START> return entityManager.createQuery(jpql, getType()).setHint("org.hibernate.cacheable", true); <END> }</code><technical_language>@gunnarmorling mind a ? I think, in theory caching queries reasonable</technical_language>

Target:
protected TypedQuery<T> createQuery(String jpql) { return entityManager.createQuery(jpql, getType()); }
Source:
<code>public void initializeTaskToolbox() throws S3ServiceException { if (taskToolbox == null) { final RestS3Service s3Client = new RestS3Service( new AWSCredentials( PropUtils.getProperty(props, "com.metamx.aws.accessKey"), PropUtils.getProperty(props, "com.metamx.aws.secretKey") ) ); final SegmentPusher segmentPusher = new S3SegmentPusher( s3Client, configFactory.build(S3SegmentPusherConfig.class), jsonMapper ); <START> final SegmentKiller segmentKiller = new S3SegmentKiller( <END> s3Client ); taskToolbox = new TaskToolbox(config, emitter, s3Client, segmentPusher, segmentKiller, jsonMapper); } }</code><technical_language>Newing this hard for put in own... rest of Nodes a get() method pull expose a setter overloaded, do too</technical_language>

Target:
public void initializeTaskToolbox() throws S3ServiceException { if (taskToolbox == null) { final RestS3Service s3Client = new RestS3Service( new AWSCredentials( PropUtils.getProperty(props, "com.metamx.aws.accessKey"), PropUtils.getProperty(props, "com.metamx.aws.secretKey") ) ); final SegmentPusher segmentPusher = new S3SegmentPusher( s3Client, configFactory.build(S3SegmentPusherConfig.class), jsonMapper ); final SegmentKiller segmentKiller = new S3SegmentKiller( s3Client ); taskToolbox = new TaskToolbox(taskConfig, emitter, s3Client, segmentPusher, segmentKiller, jsonMapper); } }
Source:
<code>private static boolean shouldPerformDiscovery(final SimpleDescriptor desc) { <START> final String discoveryType = desc.getDiscoveryType(); <END> if (discoveryType != null && !discoveryType.isEmpty()) { return true; } final String address = desc.getDiscoveryAddress(); if (address != null && !address.isEmpty()) { return true; } final String cluster = desc.getCluster(); if (cluster != null && !cluster.isEmpty()) { return true; } final String discoveryUser = desc.getDiscoveryUser(); if (discoveryUser != null && !discoveryUser.isEmpty()) { return true; } final String discoveryPass = desc.getDiscoveryPasswordAlias(); if (discoveryPass != null && !discoveryPass.isEmpty()) { return true; } return false; }</code><technical_language>Instead of relying properties rely discoveryType? confusion if else logic while defining descriptor</technical_language>

Target:
private static boolean shouldPerformDiscovery(final SimpleDescriptor desc) { final String discoveryType = desc.getDiscoveryType(); if (discoveryType != null && !discoveryType.isEmpty()) { return true; } log.missingDiscoveryTypeInDescriptor(desc.getName()); return false; }
Source:
<code><START> private static void addBoundedContext(ImmutableMap.Builder<TypeUrl, BoundedContext> mapBuilder, <END> BoundedContext boundedContext) { final ImmutableSet<TypeUrl> availableTypes = boundedContext.getStand() .getAvailableTypes(); for (TypeUrl availableType : availableTypes) { mapBuilder.put(availableType, boundedContext); } }</code><technical_language>align parameters here</technical_language>

Target:
private static void addBoundedContext(ImmutableMap.Builder<TypeUrl, BoundedContext> mapBuilder, BoundedContext boundedContext) { final Stand stand = boundedContext.getStand(); final ImmutableSet<TypeUrl> exposedTypes = stand.getExposedTypes(); for (TypeUrl availableType : exposedTypes) { mapBuilder.put(availableType, boundedContext); } }
Source:
<code>protected Map<String, List<String>> doGetInternalRoleListOfUsersWithID(List<String> userIDs, String domainName) throws UserStoreException { if (Boolean.parseBoolean(realmConfig.getUserStoreProperty(MULIPLE_ATTRIBUTE_ENABLE))) { List<String> updatedUserNameList = new ArrayList<>(); for (String userID : userIDs) { String userNameAttribute = realmConfig.getUserStoreProperty(LDAPConstants.USER_NAME_ATTRIBUTE); if (userNameAttribute != null && userNameAttribute.trim().length() > 0) { Map<String, String> map = getUserPropertyValues(userID, new String[] { userNameAttribute }, null); String tempUserName = map.get(userNameAttribute); if (tempUserName != null) { updatedUserNameList.add(tempUserName); if (log.isDebugEnabled()) { log.debug( "Replaced user name : " + userID + " from user property value : " + tempUserName); } } else { updatedUserNameList.add(userID); } } else { <START> updatedUserNameList.add(userID); <END> } } userIDs = updatedUserNameList; } return hybridRoleManager.getHybridRoleListOfUsers(userIDs, domainName); }</code><technical_language>input is userIds. Do need consider MULIPLE_ATTRIBUTE_ENABLE property</technical_language>

Target:
protected Map<String, List<String>> doGetInternalRoleListOfUsersWithID(List<String> userIDs, String domainName) throws UserStoreException { if (Boolean.parseBoolean(realmConfig.getUserStoreProperty(MULIPLE_ATTRIBUTE_ENABLE))) { List<String> updatedUserNameList = new ArrayList<>(); for (String userID : userIDs) { String userNameAttribute = realmConfig.getUserStoreProperty(LDAPConstants.USER_NAME_ATTRIBUTE); if (StringUtils.isNotEmpty(userNameAttribute)) { Map<String, String> map = getUserPropertyValues(userID, new String[] { userNameAttribute }, null); String tempUserName = map.get(userNameAttribute); if (tempUserName != null) { updatedUserNameList.add(tempUserName); if (log.isDebugEnabled()) { log.debug( "Replaced user name : " + userID + " from user property value : " + tempUserName); } } else { updatedUserNameList.add(userID); } } else { updatedUserNameList.add(userID); } } userIDs = updatedUserNameList; } return hybridRoleManager.getHybridRoleListOfUsers(userIDs, domainName); }
Source:
<code>protected SegmentCompletionProtocol.Response commit(String controllerVipUrl, boolean isSplitCommit) { SegmentCompletionProtocol.Request.Params params = new SegmentCompletionProtocol.Request.Params(); params.withSegmentName(_segmentNameStr).withStreamPartitionMsgOffset(_currentOffset.toString()) .withNumRows(_numRowsConsumed).withInstanceId(_instanceId) .withBuildTimeMillis(_segmentBuildDescriptor.getBuildTimeMillis()) .withSegmentSizeBytes(_segmentBuildDescriptor.getSegmentSizeBytes()) .withWaitTimeMillis(_segmentBuildDescriptor.getWaitTimeMillis()); if (_isOffHeap) { params.withMemoryUsedBytes(_memoryManager.getTotalAllocatedBytes()); } SegmentCommitter segmentCommitter; if (isSplitCommit) { SegmentUploader segmentUploader; <START> if (this._tableConfig.getValidationConfig().getPeerSegmentDownloadScheme() != null) { <END> segmentUploader = new PinotFSSegmentUploader(_indexLoadingConfig.getSegmentStoreURI(), PinotFSSegmentUploader.DEFAULT_SEGMENT_UPLOAD_TIMEOUT_MILLIS); segmentCommitter = _segmentCommitterFactory.createPeerSchemeSplitSegmentCommitter(params, segmentUploader); } else { try { segmentUploader = new Server2ControllerSegmentUploader(segmentLogger, _protocolHandler.getFileUploadDownloadClient(), _protocolHandler.getSegmentCommitUploadURL(params, controllerVipUrl), _segmentNameStr, ServerSegmentCompletionProtocolHandler.getSegmentUploadRequestTimeoutMs(), _serverMetrics); } catch (URISyntaxException e) { segmentLogger.error("Segment commit upload url error: ", e); return SegmentCompletionProtocol.RESP_NOT_SENT; } segmentCommitter = _segmentCommitterFactory.createSplitSegmentCommitter(params, segmentUploader); } } else { segmentCommitter = _segmentCommitterFactory.createDefaultSegmentCommitter(params); } return segmentCommitter.commit(_segmentBuildDescriptor); }</code><technical_language>Move this logic SegmentCommitterFactory class. Instantiate class tableConfig Change factory a single call create committer, params isSplit. uploader constructed factory (in split case)</technical_language>

Target:
protected SegmentCompletionProtocol.Response commit(String controllerVipUrl, boolean isSplitCommit) { SegmentCompletionProtocol.Request.Params params = new SegmentCompletionProtocol.Request.Params(); params.withSegmentName(_segmentNameStr).withStreamPartitionMsgOffset(_currentOffset.toString()) .withNumRows(_numRowsConsumed).withInstanceId(_instanceId) .withBuildTimeMillis(_segmentBuildDescriptor.getBuildTimeMillis()) .withSegmentSizeBytes(_segmentBuildDescriptor.getSegmentSizeBytes()) .withWaitTimeMillis(_segmentBuildDescriptor.getWaitTimeMillis()); if (_isOffHeap) { params.withMemoryUsedBytes(_memoryManager.getTotalAllocatedBytes()); } SegmentCommitter segmentCommitter; try { segmentCommitter = _segmentCommitterFactory.createSegmentCommitter(isSplitCommit, params, controllerVipUrl); } catch (URISyntaxException e) { segmentLogger.error("Failed to create a segment committer: ", e); return SegmentCompletionProtocol.RESP_NOT_SENT; } return segmentCommitter.commit(_segmentBuildDescriptor); }
Source:
<code>public void getAllPatients_shouldFetchVoidedPatientsWhenGivenIncludeVoidedIsTrue() throws Exception { List<Patient> allPatients = patientService.getAllPatients(true); <START> assertEquals(7, allPatients.size()); <END> }</code><technical_language>is this necessary</technical_language>

Target:
public void getAllPatients_shouldFetchVoidedPatientsWhenGivenIncludeVoidedIsTrue() throws Exception { List<Patient> allPatients = patientService.getAllPatients(true); assertEquals(6, allPatients.size()); }
Source:
<code>private void processWebhookPayloadBitBucketSelfHosted(JSONObject payload) { JSONObject repo; if (payload.has("repository")) { repo = payload.getJSONObject("repository"); } else if (payload.has("pullRequest")) { repo = payload.getJSONObject("pullRequest").getJSONObject("toRef").getJSONObject("repository"); } else { LOGGER.log(Level.WARNING, "Not possible to trigger job for event '{0}'. Only PR events and pushes are supported for now.", payload.get("eventKey")); LOGGER.log(Level.FINE, payload.toString()); return; } String user = payload.getJSONObject("actor").getString("name"); <START> String url = repo.getJSONObject("project").getString("key").toLowerCase() + "/" + repo.getString("name"); <END> String scm = "git"; probe.triggerMatchingJobs(user, url, scm, payload.toString()); }</code><technical_language>This work site. I needed replace repo.getString("name") repo.getString("slug") work. name part is equal slug part, if is a whitespace in name</technical_language>

Target:
private void processWebhookPayloadBitBucketSelfHosted(JSONObject payload) { JSONObject repo; if (payload.has("repository")) { repo = payload.getJSONObject("repository"); } else if (payload.has("pullRequest")) { repo = payload.getJSONObject("pullRequest").getJSONObject("toRef").getJSONObject("repository"); } else { LOGGER.log(Level.WARNING, "Not possible to trigger job for event '{0}'. Only PR events and pushes are supported for now.", payload.get("eventKey")); LOGGER.log(Level.FINE, payload.toString()); return; } String user = payload.getJSONObject("actor").getString("name"); String url = repo.getJSONObject("project").getString("key").toLowerCase() + "/" + repo.getString("slug"); String scm = "git"; probe.triggerMatchingJobs(user, url, scm, payload.toString()); }
Source:
<code>public FrontendConfig(VerifiableProperties verifiableProperties) { frontendCacheValiditySeconds = verifiableProperties.getLong("frontend.cache.validity.seconds", 365 * 24 * 60 * 60); frontendIdConverterFactory = verifiableProperties .getString("frontend.id.converter.factory", "com.github.ambry.frontend.AmbryIdConverterFactory"); frontendSecurityServiceFactory = verifiableProperties .getString("frontend.security.service.factory", "com.github.ambry.frontend.AmbrySecurityServiceFactory"); frontendPathPrefixesToRemove = Arrays.asList(verifiableProperties.getString("frontend.path.prefixes.to.remove", "").split(",")); frontendChunkedGetResponseThresholdInBytes = <START> verifiableProperties.getInt("ffrontend.chunked.get.response.threshold.in.bytes", 8192); <END> }</code><technical_language>typo: "f"s avoid typos, please copy config directly. hard catch for them</technical_language>

Target:
public FrontendConfig(VerifiableProperties verifiableProperties) { frontendCacheValiditySeconds = verifiableProperties.getLong("frontend.cache.validity.seconds", 365 * 24 * 60 * 60); frontendIdConverterFactory = verifiableProperties .getString("frontend.id.converter.factory", "com.github.ambry.frontend.AmbryIdConverterFactory"); frontendSecurityServiceFactory = verifiableProperties .getString("frontend.security.service.factory", "com.github.ambry.frontend.AmbrySecurityServiceFactory"); frontendPathPrefixesToRemove = Arrays.asList(verifiableProperties.getString("frontend.path.prefixes.to.remove", "").split(",")); frontendChunkedGetResponseThresholdInBytes = verifiableProperties.getInt("frontend.chunked.get.response.threshold.in.bytes", 8192); }
Source:
<code>private static boolean hasClass(String className) { try { Class.forName(className); <START> } catch (Exception e) { <END> return false; } return true; }</code><technical_language>narrowing ClassNotFoundException fail other exceptions</technical_language>

Target:
private static boolean hasClass(String className) { try { Class.forName(className); } catch (ClassNotFoundException e) { return false; } return true; }
Source:
<code><START> public List<Entry> getEntries() { <END> return entries; }</code><technical_language>Consider wrapping Collections.unmodifiableList(...) calling a copy constructor callers inadvertently mess entry contents (unless desired?)</technical_language>

Target:
public List<Entry> getEntries() { return Collections.unmodifiableList(entries); }
Source:
<code>public List<LeaderAndIsrPartitionState> partitionStates() { if (partitionStates == null) { synchronized (data) { if (partitionStates == null) { if (version() >= 2) { <START> List<LeaderAndIsrPartitionState> partitionStates = new ArrayList<>(); <END> for (LeaderAndIsrTopicState topicState : data.topicStates()) { for (LeaderAndIsrPartitionState partitionState : topicState.partitionStates()) { partitionState.setTopicName(topicState.topicName()); partitionStates.add(partitionState); } } this.partitionStates = partitionStates; } else { partitionStates = data.ungroupedPartitionStates(); } } } } return partitionStates; }</code><technical_language>@Override</technical_language>

Target:
public Iterable<LeaderAndIsrPartitionState> partitionStates() { if (version() >= 2) return () -> new FlattenedIterator<>(data.topicStates().iterator(), topicState -> topicState.partitionStates().iterator()); return data.ungroupedPartitionStates(); }
Source:
<code>protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) { <START> xml.rightAngleBracket(); <END> return xml; }</code><technical_language>Must/Should setEmptyElement()</technical_language>

Target:
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) { xml.setEmptyElement(); return xml; }
Source:
<code>private CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(@NonNull IDocument document) { URI docURI = LSPEclipseUtils.toUri(document); IFile file = LSPEclipseUtils.getFile(document); if (docURI != null && file != null) { CodeLensParams param = new CodeLensParams(new TextDocumentIdentifier(docURI.toString())); List<LSPCodeMining> codeLensResults = Collections.synchronizedList(new ArrayList<>()); try { <START> Collection<LanguageServerWrapper> serverWrappers = LanguageServiceAccessor.getLSWrappers(file, <END> capabilities -> capabilities.getCodeLensProvider() != null); CompletableFuture<?>[] futures = serverWrappers.stream().map(wrapper -> { String languageServerId = wrapper.serverDefinition.id; CompletableFuture<LanguageServer> server = wrapper.getInitializedServer(); return server .thenComposeAsync(languageServer -> languageServer.getTextDocumentService().codeLens(param) .thenAcceptAsync(codeLenses -> codeLenses.stream().filter(Objects::nonNull) .map(codeLens -> toCodeMining(document, languageServer, languageServerId, codeLens)) .filter(Objects::nonNull).forEach(codeLensResults::add))); }).toArray(CompletableFuture[]::new); return CompletableFuture.allOf(futures).thenApplyAsync(theVoid -> codeLensResults); } catch (IOException e) { LanguageServerPlugin.logError(e); return null; } } return null; }</code><technical_language>Calling this method is causing test failures. intended called externally breaks invariant synchronization</technical_language>

Target:
private CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(@NonNull IDocument document) { URI docURI = LSPEclipseUtils.toUri(document); if (docURI != null) { CodeLensParams param = new CodeLensParams(new TextDocumentIdentifier(docURI.toString())); List<LSPCodeMining> codeLensResults = Collections.synchronizedList(new ArrayList<>()); return LanguageServiceAccessor .getLanguageServers(document, capabilities -> capabilities.getCodeLensProvider() != null) .thenComposeAsync(languageServers -> CompletableFuture.allOf(languageServers.stream() .map(languageServer -> languageServer.getTextDocumentService().codeLens(param) .thenAcceptAsync(codeLenses -> codeLenses.stream().filter(Objects::nonNull).map(codeLens -> toCodeMining(document, languageServer, codeLens)).filter(Objects::nonNull).forEach(codeLensResults::add))) .toArray(CompletableFuture[]::new))) .thenApplyAsync(theVoid -> codeLensResults); } else { return null; } }
Source:
<code><START> public int getParentTransactionDepthInBlocks() { <END> return chainHeight - storedOutput.getHeight() + 1; }</code><technical_language>This needs Override annotation, no</technical_language>

Target:
public int getParentTransactionDepthInBlocks() { return chainHeight - output.getHeight() + 1; }
Source:
<code>private static Properties loadDefaultProperties(Class<? extends Messages> leafClass) throws URISyntaxException, IOException { Properties hierarchyProps = new Properties(); ArrayList<Class<? extends Messages>> hierarchy = new ArrayList<Class<? extends Messages>>(); ArrayList<Class<? extends Messages>> round = new ArrayList<Class<? extends Messages>>(); round.add(leafClass); while (!round.isEmpty()) { ArrayList<Class<? extends Messages>> round2 = new ArrayList<Class<? extends Messages>>(); for (Class<? extends Messages> c : round) { hierarchy.add(c); for (Class<?> up : c.getInterfaces()) { if (Messages.class.isAssignableFrom(up) && Messages.class != up) { round2.add((Class<? extends Messages>)up); } } } round = round2; } <START> Collections.reverse(hierarchy); <END> for (Class<?> theClass : hierarchy) { File classDir = new File(theClass.getResource(".").toURI().toASCIIString().replaceAll("file:", "")); File classPropFile = new File(classDir, theClass.getSimpleName() + ".properties"); Properties classProps = classPropFile.exists() ? loadProperties(classPropFile) : new Properties(); hierarchyProps.putAll(classProps); }; return hierarchyProps; }</code><technical_language>Interesting, assemble class hierarchy leaf parent (excluding root Messages), reverse hierarchy process parent leaf</technical_language>

Target:
private static Properties loadDefaultProperties(Class<? extends Messages> leafClass) throws URISyntaxException, IOException { Properties hierarchyProps = new Properties(); ArrayList<Class<? extends Messages>> hierarchy = new ArrayList<Class<? extends Messages>>(); ArrayList<Class<? extends Messages>> round = new ArrayList<Class<? extends Messages>>(); round.add(leafClass); while (!round.isEmpty()) { ArrayList<Class<? extends Messages>> round2 = new ArrayList<Class<? extends Messages>>(); for (Class<? extends Messages> c : round) { hierarchy.add(c); for (Class<?> up : c.getInterfaces()) { if (Messages.class.isAssignableFrom(up) && Messages.class != up) { round2.add((Class<? extends Messages>)up); } } } round = round2; } Collections.reverse(hierarchy); System.out.println("message hierarchy: " + hierarchy); for (Class<?> theClass : hierarchy) { String classPropertyFileName = theClass.getName().replace(".", "/") + ".properties"; System.out.println("theClass: " + theClass + ", classPropertyFileName: " + classPropertyFileName); URL theResource = theClass.getResource(classPropertyFileName); if (theResource == null) { theResource = theClass.getResource(theClass.getSimpleName() + ".properties"); } System.out.println("theResource: " + theResource); Properties classProps = new Properties(); try (InputStream input = theResource.openStream()) { classProps.load(input); } hierarchyProps.putAll(classProps); }; return hierarchyProps; }
Source:
<code>public static Optional<Boolean> getInitParameter(MailetConfig config, String name) { Object value = config.getInitParameter(name, Boolean.class); if(value != null){ if(Boolean.class.isInstance(value)){ return Optional.of((Boolean)value); } else throw new ClassCastException(name + " property is not of type " + Boolean.class); } <START> else return Optional.empty(); <END> }</code><technical_language>This pass checkstyle rules. need explicitly define blocks of code {}</technical_language>

Target:
public static Optional<Boolean> getInitParameter(MailetConfig config, String name) { return Optional.ofNullable(config.getInitParameter(name, Boolean.class)); }
Source:
<code>private boolean hasNonProjects() { for (IResource <START> fResource : <END> fResources) { if (!ReorgUtils.isProject(fResource)) { return true; } } for (IJavaElement fJavaElement : fJavaElements) { if (!ReorgUtils.isProject(fJavaElement)) { return true; } } return false; }</code><technical_language>rename resource</technical_language>

Target:
private boolean hasNonProjects() { for (IResource resource : fResources) { if (!ReorgUtils.isProject(resource)) { return true; } } for (IJavaElement javaElement : fJavaElements) { if (!ReorgUtils.isProject(javaElement)) { return true; } } return false; }
Source:
<code>public void unscheduleTask() { while (true) { if (scheduledFuture == null) { Thread.yield(); } else { scheduledFuture.cancel(false); <START> scheduledFuture = null; <END> } } }</code><technical_language>a "return" this good : If failLoop reconnect failed connection, stopFailover() (actual line 451) loop this while, freed thread</technical_language>

Target:
public void unscheduleTask() { while (true) { if (scheduledFuture == null) { Thread.yield(); } else { scheduledFuture.cancel(false); scheduledFuture = null; return; } } }
Source:
<code>public boolean isEmpty() { <START> fOutputLock.lock(); <END> try { return (fInputBuffer.isEmpty() && fOutputBuffer.isEmpty() && fInnerQueue.isEmpty()); } finally { fOutputLock.unlock(); } }</code><technical_language>This deadlock if output lock is held consumer is blocked while queue is empty</technical_language>

Target:
public boolean isEmpty() { return fQueueSize.get() == 0; }
Source:
<code>public void testCreateNewTaskFromLockedTask() { Datastream stream = DatastreamTestUtils.createDatastream("dummy", "dummy", "dummy"); stream.getMetadata().put(DatastreamMetadataConstants.TASK_PREFIX, DatastreamTaskImpl.getTaskPrefix(stream)); DatastreamTaskImpl task = new DatastreamTaskImpl(Collections.singletonList(stream)); ZkAdapter mockZkAdapter = mock(ZkAdapter.class); task.setZkAdapter(mockZkAdapter); DatastreamTaskImpl task0 = new DatastreamTaskImpl(Collections.singletonList(stream)); <START> ZkAdapter mockZkAdapter2 = mock(ZkAdapter.class); <END> task0.setZkAdapter(mockZkAdapter2); when(mockZkAdapter2.checkIsTaskLocked(anyString(), anyString(), anyString())).thenReturn(true); task.addDependency(task0); when(mockZkAdapter.checkIsTaskLocked(anyString(), anyString(), anyString())).thenReturn(true); DatastreamTaskImpl task2 = new DatastreamTaskImpl(task, new ArrayList<>()); Assert.assertEquals(new HashSet<>(task2.getDependencies()), ImmutableSet.of(task.getDatastreamTaskName())); }</code><technical_language>nit: mockZkAdapter2 0, other places</technical_language>

Target:
public void testCreateNewTaskFromLockedTask() { Datastream stream = DatastreamTestUtils.createDatastream("dummy", "dummy", "dummy"); stream.getMetadata().put(DatastreamMetadataConstants.TASK_PREFIX, DatastreamTaskImpl.getTaskPrefix(stream)); DatastreamTaskImpl task = new DatastreamTaskImpl(Collections.singletonList(stream)); ZkAdapter mockZkAdapter = mock(ZkAdapter.class); task.setZkAdapter(mockZkAdapter); task.addDependency(createDependencyTask(stream, true)); when(mockZkAdapter.checkIsTaskLocked(anyString(), anyString(), anyString())).thenReturn(true); DatastreamTaskImpl task2 = new DatastreamTaskImpl(task, new ArrayList<>()); Assert.assertEquals(new HashSet<>(task2.getDependencies()), ImmutableSet.of(task.getDatastreamTaskName())); }
Source:
<code>protected void executeCommand() { if (FeatureSupported.liveMerge(getVm().getVdsGroupCompatibilityVersion())) { if (!getVm().isQualifiedForSnapshotMerge()) { log.error("Cannot remove VM snapshot. Vm is not Down, Up or Paused"); throw new VdcBLLException(VdcBllErrors.VM_NOT_QUALIFIED_FOR_SNAPSHOT_MERGE); } } else if (!getVm().isDown()) { log.error("Cannot remove VM snapshot. Vm is not Down and cluster version does not support Live Merge"); throw new VdcBLLException(VdcBllErrors.IRS_IMAGE_STATUS_ILLEGAL); } final Snapshot snapshot = getSnapshotDao().get(getParameters().getSnapshotId()); boolean snapshotHasImages = hasImages(); boolean removeSnapshotMemory = isMemoryVolumeRemoveable(snapshot.getMemoryVolume()); if (!snapshotHasImages && !removeSnapshotMemory) { getSnapshotDao().remove(getParameters().getSnapshotId()); setSucceeded(true); return; } lockSnapshot(snapshot); freeLock(); getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId())); if (snapshotHasImages) { removeImages(); if (getSnapshotActionType() == VdcActionType.RemoveSnapshotSingleDiskLive) { setCommandStatus(CommandStatus.ACTIVE_ASYNC); persistCommandWithoutContext(getParameters().getParentCommand(), true); } } if (removeSnapshotMemory) { removeMemory(snapshot); } setSucceeded(true); if (snapshotHasImages) { if (getSnapshotActionType() == VdcActionType.RemoveSnapshotSingleDiskLive) { <START> setCommandStatus(CommandStatus.ACTIVE_ASYNC_EXECUTED); <END> } } }</code><technical_language>sets commandstatus other action types</technical_language>

Target:
protected void executeCommand() { if (FeatureSupported.liveMerge(getVm().getVdsGroupCompatibilityVersion())) { if (!getVm().isQualifiedForSnapshotMerge()) { log.error("Cannot remove VM snapshot. Vm is not Down, Up or Paused"); throw new VdcBLLException(VdcBllErrors.VM_NOT_QUALIFIED_FOR_SNAPSHOT_MERGE); } } else if (!getVm().isDown()) { log.error("Cannot remove VM snapshot. Vm is not Down and cluster version does not support Live Merge"); throw new VdcBLLException(VdcBllErrors.IRS_IMAGE_STATUS_ILLEGAL); } final Snapshot snapshot = getSnapshotDao().get(getParameters().getSnapshotId()); boolean snapshotHasImages = hasImages(); boolean removeSnapshotMemory = isMemoryVolumeRemoveable(snapshot.getMemoryVolume()); if (!snapshotHasImages && !removeSnapshotMemory) { getSnapshotDao().remove(getParameters().getSnapshotId()); setSucceeded(true); return; } lockSnapshot(snapshot); freeLock(); getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId())); if (snapshotHasImages) { removeImages(); if (getSnapshotActionType() == VdcActionType.RemoveSnapshotSingleDiskLive) { setCommandStatus(CommandStatus.ACTIVE_ASYNC); persistCommandWithoutContext(getParameters().getParentCommand(), true); } } if (removeSnapshotMemory) { removeMemory(snapshot); } setSucceeded(true); }
Source:
<code>public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { InputStream inStream = null; try { inStream = new FileInputStream(mHttpsCertPath); CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate ca = (X509Certificate) cf.generateCertificate(inStream); for (X509Certificate cert : certs) { cert.verify(ca.getPublicKey()); } } catch (FileNotFoundException |NoSuchAlgorithmException|InvalidKeyException |NoSuchProviderException |SignatureException e) { <START> throw new CertificateException("Untrusted Certificate!"); <END> } finally { try { if (inStream != null) inStream.close(); } catch (IOException e) { Log.w(TAG, e); } } }</code><technical_language>pass e Exception constructor? debugging easier</technical_language>

Target:
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { InputStream inStream = null; try { inStream = new FileInputStream(mHttpsCertPath); CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate ca = (X509Certificate) cf.generateCertificate(inStream); for (X509Certificate cert : certs) { cert.verify(ca.getPublicKey()); } } catch (FileNotFoundException |NoSuchAlgorithmException|InvalidKeyException| NoSuchProviderException |SignatureException e) { throw new CertificateException("Untrusted Certificate!", e); } finally { try { if (inStream != null) inStream.close(); } catch (IOException e) { Log.w(TAG, e); } } }
Source:
<code>@Override public WebViewMapFragment build() { if (options == null) { options = new MapboxWebMapType(mapboxAccessToken, mapboxMapId); } <START> if (options instanceof MapboxWebMapType) { <END> return MapboxWebViewMapFragment.newInstance(options); } if (options instanceof GoogleWebMapType) { return GoogleWebViewMapFragment.newInstance(options); } if (options instanceof GoogleChinaMapType) { return GoogleChinaWebViewMapFragment.newInstance(options); } return null; }</code><technical_language>add logic return a MapboxWebViewMapFragment if a mapbox ID token set. If existing user of this library a mapbox ID token set changes, web map work</technical_language>

Target:
@Override public WebViewMapFragment build() { if (options == null) { options = new GoogleWebMapType(); } if (options instanceof GoogleWebMapType) { return GoogleWebViewMapFragment.newInstance(options); } if (options instanceof GoogleChinaMapType) { return GoogleChinaWebViewMapFragment.newInstance(options); } return null; }
Source:
<code>private void visitMember(FieldOrMethod member, String signatureFormatString) { JavaClass definingClass = (JavaClass) mDescendingVisitor.predecessor(); mStatus.debug("Visit member %s : %s", member.getName(), member.getSignature()); for (AnnotationEntry a : member.getAnnotationEntries()) { if (mAnnotationType.equals(a.getAnnotationType())) { mStatus.debug("Member has annotation %s", mAnnotationType); boolean bridge = (member <START> instanceof Method) <END> && (member.getAccessFlags() & Const.ACC_BRIDGE) != 0; if (bridge) { mStatus.debug("Member is a bridge", mAnnotationType); } String signature = String.format(Locale.US, signatureFormatString, getClassDescriptor(definingClass), member.getName(), member.getSignature()); Member m = new Member(signature, bridge); for (ElementValuePair property : a.getElementValuePairs()) { switch (property.getNameString()) { case EXPECTED_SIGNATURE: String expected = property.getValue().stringifyValue(); if (!bridge && !signature.equals(expected)) { error(definingClass, member, "Expected signature does not match generated:\n" + "Expected: %s\n" + "Generated: %s", expected, signature); } break; } } if (mGreylistFilter.test(m)) { mStatus.greylistEntry(m.signature); } } } }</code><technical_language>want do this in a separate CL? fine this, if decide revert this for some reason..</technical_language>

Target:
private void visitMember(FieldOrMethod member, String signatureFormatString) { JavaClass definingClass = (JavaClass) mDescendingVisitor.predecessor(); mStatus.debug("Visit member %s : %s", member.getName(), member.getSignature()); for (AnnotationEntry a : member.getAnnotationEntries()) { if (mAnnotationType.equals(a.getAnnotationType())) { mStatus.debug("Member has annotation %s", mAnnotationType); boolean bridge = (member.getAccessFlags() & Const.ACC_BRIDGE) != 0; if (bridge) { mStatus.debug("Member is a bridge", mAnnotationType); } String signature = String.format(Locale.US, signatureFormatString, getClassDescriptor(definingClass), member.getName(), member.getSignature()); for (ElementValuePair property : a.getElementValuePairs()) { switch (property.getNameString()) { case EXPECTED_SIGNATURE: String expected = property.getValue().stringifyValue(); if (!bridge && !signature.equals(expected)) { error(definingClass, member, "Expected signature does not match generated:\n" + "Expected: %s\n" + "Generated: %s", expected, signature); } break; } } if (mMemberFilter.test(new Member(signature, bridge))) { mStatus.greylistEntry(signature); } } } }
Source:
<code>public RowBatch nextBatch(RowBatch previous) throws IOException { MessageType requestedSchema = readContext.getRequestedSchema(); List<ColumnDescriptor> columns = requestedSchema.getColumns(); int nColumns = columns.size(); ColumnVector[] columnVectors; RowBatch rowBatch = previous; if (rowBatch == null) { rowBatch = new RowBatch(new ColumnVector[nColumns]); } columnVectors = rowBatch.getColumns(); MessageType[] columnSchemas = new MessageType[nColumns]; for (int i = 0; i < nColumns; i++) { <START> ColumnVector columnVector = columnVectors[i]; <END> columnSchemas[i] = new MessageType(requestedSchema.getFieldName(i), requestedSchema.getType(i)); if (columnVector == null) { columnVector = ColumnVector.from(columns.get(i)); } rowBatch.getColumns()[i] = columnVector; } boolean hasMoreRecords = readVectors(rowBatch.getColumns(), columnSchemas); return hasMoreRecords ? rowBatch : null; }</code><technical_language>If RowBatch 'previous' is passed non-null number of columns 'requestedSchema', I this line throw ArrayIndexOutOfBoundException. this a public method, validate 'previous' 'requestedSchema' number of columns throw a error message otherwise</technical_language>

Target:
public RowBatch nextBatch(RowBatch previous) throws IOException { MessageType requestedSchema = readContext.getRequestedSchema(); List<ColumnDescriptor> columns = requestedSchema.getColumns(); int nColumns = columns.size(); ColumnVector[] columnVectors; RowBatch rowBatch = previous; if (rowBatch == null) { rowBatch = new RowBatch(new ColumnVector[nColumns]); } columnVectors = rowBatch.getColumns(); checkArgument(columns.size() == columnVectors.length, "Number of columns in the requested schema and the previous row batch don't match."); MessageType[] columnSchemas = new MessageType[nColumns]; for (int i = 0; i < nColumns; i++) { ColumnVector columnVector = columnVectors[i]; columnSchemas[i] = new MessageType(requestedSchema.getFieldName(i), requestedSchema.getType(i)); if (columnVector == null) { columnVector = ColumnVector.from(columns.get(i)); } rowBatch.getColumns()[i] = columnVector; } boolean hasMoreRecords = readVectors(rowBatch.getColumns(), columnSchemas); return hasMoreRecords ? rowBatch : null; }
Source:
<code>public Cluster apply(Cluster original) { requireNonNull(original); Cluster upgraded = original.clone(); List<Stripe> stripes = upgraded.getStripes(); for (int i = 0; i < stripes.size(); i++) { if (stripes.get(i).getName() == null) { stripes.get(i).setName("stripe[" + i + "]"); } } String clusterName = upgraded.getName(); Random random = new Random(clusterName.hashCode()); if (upgraded.getUID() == null) { upgraded.setUID(upgraded.newUID(random)); } upgraded.getStripes().forEach(stripe -> { if (stripe.getUID() == null) { stripe.setUID(upgraded.newUID(random)); } stripe.getNodes().forEach(node -> { if (node.getUID() == null) { node.setUID(upgraded.newUID(random)); } }); }); <START> NameGenerator.assignFriendlyNames(upgraded); <END> new ClusterValidator(upgraded).validate(); return upgraded; }</code><technical_language>@mobasherul : assignFriendlyNames is touching node names right... ? Y ou touch node names upgrade of config format of activated server. stripe names need genwrated</technical_language>

Target:
public Cluster apply(Cluster original) { requireNonNull(original); Cluster upgraded = original.clone(); if(from == Version.V1) { String clusterName = upgraded.getName(); requireNonNull(clusterName); Random random = new Random(clusterName.hashCode()); upgraded.setUID(upgraded.newUID(random)); upgraded.getStripes().forEach(stripe -> { stripe.setUID(upgraded.newUID(random)); stripe.getNodes().forEach(node -> { node.setUID(upgraded.newUID(random)); }); }); NameGenerator.assignFriendlyStripeNames(upgraded, new Random(clusterName.hashCode())); } new ClusterValidator(upgraded).validate(); return upgraded; }
Source:
<code>private void postNicInit() { initSelectedType(); getName().setEntity(getNic().getName()); initMAC(); initLinked(); initProfiles(); getPlugged().setEntity(getNic().isPlugged()); if (!hotPlugSupported) { getPlugged().setChangeProhibitionReason(ConstantsManager.getInstance() .getMessages() .hotPlugNotSupported(getClusterCompatibilityVersion().toString())); } <START> getPlugged().setIsChangable(hotPlugSupported || vmStatus.equals(VMStatus.Down)); <END> initCommands(); }</code><technical_language>added this exact line in NewVmInterfaceModel. Duplication is error prone changes in future, change name of variable hotPlugSupported allowHotPlug set in VmInterfaceModel logical of cluster compatibility version VM status</technical_language>

Target:
private void postNicInit() { initSelectedType(); getName().setEntity(getNic().getName()); initMAC(); initLinked(); initProfiles(); getPlugged().setEntity(getNic().isPlugged()); if (!hotPlugSupported) { getPlugged().setChangeProhibitionReason(ConstantsManager.getInstance() .getMessages() .hotPlugNotSupported(getClusterCompatibilityVersion().toString())); } getPlugged().setIsChangable(allowHotPlug()); initCommands(); }
Source:
<code>private static IMarker[] getMarkersOfView(String viewId, IMarker[] markers) throws CoreException { if (null == viewId) return markers; ArrayList<IMarker> markersOfView = new ArrayList<>(); for (IMarker marker : markers) { <START> if (viewId.equals(getViewId(marker))) <END> markersOfView.add(marker); } return markersOfView.toArray(new IMarker[markersOfView.size()]); }</code><technical_language>please add if(marker != null &&</technical_language>

Target:
private static IMarker[] getMarkersOfView(String viewId, IMarker[] markers) throws CoreException { if (null == viewId) return markers; ArrayList<IMarker> markersOfView = new ArrayList<>(); for (IMarker marker : markers) { if (null != marker && viewId.equals(getViewId(marker))) markersOfView.add(marker); } return markersOfView.toArray(new IMarker[markersOfView.size()]); }
Source:
<code>@Override public void setListener(@Nullable DiscoverySpiListener lsnr) { <START> super.setListener(lsnr == null || discoHooks.isEmpty() ? <END> lsnr : wrap(lsnr, discoHooks.toArray(new DiscoveryHook[0]))); }</code><technical_language>Is flow possible? If no, why? 1. addDiscoveryHook 2. setListener 3. addDiscoveryHook <- this hook ignored</technical_language>

Target:
@Override public void setListener(@Nullable DiscoverySpiListener lsnr) { super.setListener(lsnr == null || discoHook == null ? lsnr : wrap(lsnr, discoHook)); }