auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
NotificationInformation createNotification(final T notificationPayload) { return new NotificationInformation() { @Override public int getId() { if (notificationPayload instanceof DownloadBatchStatus) { return ((DownloadBatchStatus) notificationPayload).getDownloadBatchId().hashCode(); } return notificationPayload.hashCode(); } @Override public Notification getNotification() { int newNotificationId = getId(); NotificationCustomizer.NotificationDisplayState newNotificationDisplayState = notificationDisplayState(); if (builder == null || hasChanged(newNotificationId, newNotificationDisplayState)) { builder = new NotificationCompat.Builder(applicationContext, notificationChannelProvider.channelId()); notificationId = newNotificationId; notificationDisplayState = newNotificationDisplayState; } return notificationCustomizer.customNotificationFrom(builder, notificationPayload); } private boolean hasChanged(int newNotificationId, NotificationCustomizer.NotificationDisplayState newNotificationDisplayState) { return notificationId != newNotificationId && !notificationDisplayState.equals(newNotificationDisplayState); } @Override public NotificationCustomizer.NotificationDisplayState notificationDisplayState() { return notificationCustomizer.notificationDisplayState(notificationPayload); } }; }

Target:
NotificationInformation createNotification(final T notificationPayload) { return new NotificationInformation() { @Override public int getId() { if (notificationPayload instanceof DownloadBatchStatus) { return ((DownloadBatchStatus) notificationPayload).getDownloadBatchId().hashCode(); } return notificationPayload.hashCode(); } @Override public Notification getNotification() { int newNotificationId = getId(); if (builder == null || newNotificationId != notificationId) { builder = new NotificationCompat.Builder(applicationContext, notificationChannelProvider.channelId()); notificationId = newNotificationId; } return notificationCustomizer.customNotificationFrom(builder, notificationPayload); } @Override public NotificationCustomizer.NotificationDisplayState notificationDisplayState() { return notificationCustomizer.notificationDisplayState(notificationPayload); } }; }
Source:
public Credentials(String login, String passwordHash) { this.login = login; this.passwordHash = passwordHash; }

Target:
Credentials(String login, String passwordHash) { this.login = login; this.passwordHash = passwordHash; }
Source:
public static Operation createDeploymentAddOperation(final InputStream content, final String name, final String runtimeName) { Assertions.requiresNotNullParameter(content, "content"); Assertions.requiresNotNullParameter(name, "name"); final ModelNode address = createAddress(DEPLOYMENT, name); final ModelNode addOperation = createAddOperation(address); if (runtimeName != null) { addOperation.get(RUNTIME_NAME).set(runtimeName); } final CompositeOperationBuilder builder = CompositeOperationBuilder.create(true); builder.addStep(addOperation); return builder.build(); }

Target:
public static Operation createDeploymentAddOperation(final InputStream content, final String name, final String runtimeName) { Assertions.requiresNotNullParameter(content, "content"); Assertions.requiresNotNullParameter(name, "name"); final ModelNode address = createAddress(DEPLOYMENT, name); final ModelNode addOperation = createAddOperation(address); if (runtimeName != null) { addOperation.get(RUNTIME_NAME).set(runtimeName); } final CompositeOperationBuilder builder = CompositeOperationBuilder.create(true); builder.addStep(addOperation); DeploymentContent.of(content).addContentToOperation(builder, addOperation); return builder.build(); }
Source:
private Function<PollingContext<OperationResult>, Mono<OperationResult>> receiptStreamActivationOperation( Flux<ByteBuffer> data, long length, FormContentType formContentType, boolean includeTextDetails) { Objects.requireNonNull(data, "'data' is required and cannot be null."); return pollingContext -> { try { if (formContentType != null) { return service.analyzeReceiptAsyncWithResponseAsync( ContentType.fromString(formContentType.toString()), data, length, includeTextDetails) .map(response -> new OperationResult( parseModelId(response.getDeserializedHeaders().getOperationLocation()))); } else { return detectContentType(data) .flatMap(contentType -> service.analyzeReceiptAsyncWithResponseAsync(contentType, data, length, includeTextDetails) .map(response -> new OperationResult( parseModelId(response.getDeserializedHeaders().getOperationLocation())))); } } catch (RuntimeException ex) { return monoError(logger, ex); } }; }

Target:
private Function<PollingContext<OperationResult>, Mono<OperationResult>> receiptStreamActivationOperation( Flux<ByteBuffer> data, long length, FormContentType formContentType, boolean includeTextDetails) { return pollingContext -> { try { Objects.requireNonNull(data, "'data' is required and cannot be null."); if (formContentType != null) { return service.analyzeReceiptAsyncWithResponseAsync( ContentType.fromString(formContentType.toString()), data, length, includeTextDetails) .map(response -> new OperationResult( parseModelId(response.getDeserializedHeaders().getOperationLocation()))); } else { return detectContentType(data) .flatMap(contentType -> service.analyzeReceiptAsyncWithResponseAsync(contentType, data, length, includeTextDetails) .map(response -> new OperationResult( parseModelId(response.getDeserializedHeaders().getOperationLocation())))); } } catch (RuntimeException ex) { return monoError(logger, ex); } }; }
Source:
private void expandToLevel(VirtualItem item, int level) { if (level == ALL_LEVELS || level > 0) { if (!item.hasItems()) { return; } item.setExpanded(true); if (item.getData() == null) { virtualLazyUpdateData(item); return; } if (level == ALL_LEVELS || level > 1) { VirtualItem[] children = item.getItems(); int newLevel = (level == ALL_LEVELS ? ALL_LEVELS : level - 1); for (VirtualItem element : children) { expandToLevel(element, newLevel); } } } }

Target:
private void expandToLevel(VirtualItem item, int level) { if (level == ALL_LEVELS || level > 0) { if (!item.hasItems()) { return; } item.setExpanded(true); if (item.getData() == null) { virtualLazyUpdateData(item); return; } if (level == ALL_LEVELS || level > 1) { int newLevel = (level == ALL_LEVELS ? ALL_LEVELS : level - 1); for (VirtualItem element : item.getItems()) { expandToLevel(element, newLevel); } } } }
Source:
public static void setUp() { POSITIONDTO_LIST_TYPE = new TypeToken<List<PositionDTO>>() {}.getType(); DEVELOPER_ENTITY = PositionEntity.builder().id(DEVELOPER_ID).name(DEVELOPER_NAME).build(); DEVELOPER_DTO = PositionDTO.builder().id(DEVELOPER_ID).name(DEVELOPER_NAME).build(); EXPECTED_POSITION_ENTITY_LIST = Arrays.asList( DEVELOPER_ENTITY, DEVELOPER_ENTITY, DEVELOPER_ENTITY ); EXPECTED_POSITION_DTO_LIST = Arrays.asList( DEVELOPER_DTO, DEVELOPER_DTO, DEVELOPER_DTO ); }

Target:
public void setUp() { developerEntity = PositionEntity.builder().id(DEVELOPER_ID).name(DEVELOPER_NAME).build(); developerDto = PositionDTO.builder().id(DEVELOPER_ID).name(DEVELOPER_NAME).build(); expectedPositionEntityList = Arrays.asList(developerEntity, developerEntity, developerEntity); expectedPositionDtoList = Arrays.asList(developerDto, developerDto, developerDto); }
Source:
public JudgmentType convertToType(String judgmentFormName) { if (StringUtils.isBlank(judgmentFormName)) { return JudgmentType.SENTENCE; } judgmentFormName = judgmentFormName.trim().toUpperCase(); for (Map.Entry<String, JudgmentType> entry : judgmentTypeMap.entrySet()) { if (judgmentFormName.contains(entry.getKey())) { return entry.getValue(); } } return JudgmentType.SENTENCE; }

Target:
public JudgmentType convertToType(String judgmentFormName) { if (StringUtils.isBlank(judgmentFormName)) { return JudgmentType.SENTENCE; } judgmentFormName = judgmentFormName.trim().toUpperCase(Locale.ROOT); for (Map.Entry<String, JudgmentType> entry : judgmentTypeMap.entrySet()) { if (judgmentFormName.contains(entry.getKey())) { return entry.getValue(); } } return JudgmentType.SENTENCE; }
Source:
public Properties trackScreenView(String screenName, String courseId, String action) { SegmentAnalyticsEvent aEvent = new SegmentAnalyticsEvent(); aEvent.setAppNameContext(); if (!TextUtils.isEmpty(action)) { aEvent.properties.put(Keys.ACTION, action); } tracker.screen("", screenName, aEvent.properties); addCategoryToBiEvents(aEvent.properties, Values.SCREEN, screenName); aEvent.properties.put(Keys.COURSE_ID, TextUtils.isEmpty(courseId) ? "" : courseId); return aEvent.properties; }

Target:
public Properties trackScreenView(String screenName, String courseId, String action) { SegmentAnalyticsEvent aEvent = new SegmentAnalyticsEvent(); aEvent.setAppNameContext(); if (!TextUtils.isEmpty(action)) { aEvent.properties.put(Keys.ACTION, action); } if (!TextUtils.isEmpty(courseId)) { aEvent.properties.put(Keys.COURSE_ID, courseId); } tracker.screen("", screenName, aEvent.properties); addCategoryToBiEvents(aEvent.properties, Values.SCREEN, screenName); tracker.track(screenName, aEvent.properties); return aEvent.properties; }
Source:
private static void choosePlayerSample(GlowServer server, PaperServerListPingEvent event) { ThreadLocalRandom random = ThreadLocalRandom.current(); List<Player> players = Arrays.asList(server.getOnlinePlayers()); int sampleCount = server.getPlayerSampleCount(); if (players.size() <= sampleCount) { sampleCount = players.size(); } else { for (int i = 0; i < sampleCount; i++) { Collections.swap(players, i, random.nextInt(i, players.size())); } } for (int i = 0; i < sampleCount; i++) { event.getPlayerSample().add(players.get(i).getPlayerProfile()); } }

Target:
private static void choosePlayerSample(GlowServer server, PaperServerListPingEvent event) { ThreadLocalRandom random = ThreadLocalRandom.current(); List<Player> players = new ArrayList<>(server.getOnlinePlayers()); int sampleCount = server.getPlayerSampleCount(); if (players.size() <= sampleCount) { sampleCount = players.size(); } else { for (int i = 0; i < sampleCount; i++) { Collections.swap(players, i, random.nextInt(i, players.size())); } } for (int i = 0; i < sampleCount; i++) { event.getPlayerSample().add(players.get(i).getPlayerProfile()); } }
Source:
private void ensureStorageFormatInitialized() { StorageDomain sd = getStorageDomain(); if (sd.getStorageFormat() == null) { if (sd.getStorageDomainType().isDataDomain()) { StoragePool sp = getTargetStoragePool(); if (sp != null) { sd.setStorageFormat(VersionStorageFormatUtil.getPreferredForVersion( sp.getcompatibility_version(), sd.getStorageType()) ); } else { sd.setStorageFormat(StorageFormatType.V3); } } else { sd.setStorageFormat(StorageFormatType.V1); } } }

Target:
private void ensureStorageFormatInitialized() { StorageDomain sd = getStorageDomain(); if (sd.getStorageFormat() == null) { if (sd.getStorageDomainType().isDataDomain()) { StoragePool sp = getTargetStoragePool(); if (sp != null) { sd.setStorageFormat(VersionStorageFormatUtil.getPreferredForVersion( sp.getcompatibility_version(), sd.getStorageType()) ); } else { if (sd.getStorageType().isBlockDomain()) { sd.setStorageFormat(StorageFormatType.V2); } else { sd.setStorageFormat(StorageFormatType.V1); } } } else { sd.setStorageFormat(StorageFormatType.V1); } } }
Source:
Page<Book> getDefaultPageable(Pageable pageable) { if (pageable != null) { return new PageImpl<>(Collections.singletonList(new Book()), pageable, 1); } return new PageImpl<>(Collections.emptyList(), pageable, 0); }

Target:
Page<Book> getDefaultPageable(Pageable pageable) { if (pageable != null) { return new PageImpl<Book>(Collections.singletonList(new Book()), pageable, 1); } return new PageImpl<Book>(Collections.emptyList(), pageable, 0); }
Source:
public void visitNode(Tree tree) { if (!hasSemantic()) { return; } ReturnThis returnThis = new ReturnThis(); ClassTree classTree = (ClassTree) tree; Type classType = classTree.symbol().type(); if(!(classType.isSubtypeOf("java.util.Iterator") && classType.isSubtypeOf("java.lang.Iterable"))) { return; } classTree.members().stream().filter(m -> m.is(Tree.Kind.METHOD)).forEach(t -> t.accept(returnThis)); if (!returnThis.issueLocations.isEmpty()) { reportIssue(returnThis.issueLocations.get(0), "", returnThis.issueLocations.stream().skip(1) .map(t -> new JavaFileScannerContext.Location("", t)).collect(Collectors.toList()), null); } }

Target:
public void visitNode(Tree tree) { if (!hasSemantic()) { return; } ReturnThis returnThis = new ReturnThis(); ClassTree classTree = (ClassTree) tree; Type classType = classTree.symbol().type(); if(!(classType.isSubtypeOf("java.util.Iterator") && classType.isSubtypeOf("java.lang.Iterable"))) { return; } classTree.members().stream() .filter(m -> m.is(Tree.Kind.METHOD)) .filter(m -> ITERATOR.matches(((MethodTree) m))) .forEach(t -> t.accept(returnThis)); if (!returnThis.issueLocations.isEmpty()) { reportIssue(returnThis.issueLocations.get(0), "Refactor this code so that the Iterator supports multiple traversal", returnThis.issueLocations.stream().skip(1) .map(t -> new JavaFileScannerContext.Location("", t)).collect(Collectors.toList()), null); } }
Source:
public PackBitmapIndexBuilder(List<ObjectToPack> objects) { super(new ObjectIdOwnerMap<StoredBitmap>()); byOffset = new BlockList<>(objects.size()); sortByOffset(objects); int sizeInWords = Math.max(4, byOffset.size() / 64 / 3); commits = new EWAHCompressedBitmap(sizeInWords); trees = new EWAHCompressedBitmap(sizeInWords); blobs = new EWAHCompressedBitmap(sizeInWords); tags = new EWAHCompressedBitmap(sizeInWords); for (int i = 0; i < objects.size(); i++) { int type = objects.get(i).getType(); switch (type) { case Constants.OBJ_COMMIT: commits.set(i); break; case Constants.OBJ_TREE: trees.set(i); break; case Constants.OBJ_BLOB: blobs.set(i); break; case Constants.OBJ_TAG: tags.set(i); break; default: throw new IllegalArgumentException(MessageFormat.format( JGitText.get().badObjectType, String.valueOf(type))); } } commits.trim(); trees.trim(); blobs.trim(); tags.trim(); }

Target:
public PackBitmapIndexBuilder(List<ObjectToPack> objects) { super(new ObjectIdOwnerMap<StoredBitmap>()); byOffset = new BlockList<>(objects.size()); sortByOffsetAndIndex(byOffset, positionEntries, objects); int sizeInWords = Math.max(4, byOffset.size() / 64 / 3); commits = new EWAHCompressedBitmap(sizeInWords); trees = new EWAHCompressedBitmap(sizeInWords); blobs = new EWAHCompressedBitmap(sizeInWords); tags = new EWAHCompressedBitmap(sizeInWords); for (int i = 0; i < objects.size(); i++) { int type = objects.get(i).getType(); switch (type) { case Constants.OBJ_COMMIT: commits.set(i); break; case Constants.OBJ_TREE: trees.set(i); break; case Constants.OBJ_BLOB: blobs.set(i); break; case Constants.OBJ_TAG: tags.set(i); break; default: throw new IllegalArgumentException(MessageFormat.format( JGitText.get().badObjectType, String.valueOf(type))); } } commits.trim(); trees.trim(); blobs.trim(); tags.trim(); }
Source:
public void clickTemplateQuestionModalCheckBox(int questionNum) { WebElement questionCheckBox = browser.driver.findElement(By.id("addTemplateQuestionModalForm")) .findElement(By.id("addTemplateQuestion-" + questionNum)) .findElement(By.cssSelector("input")); click(questionCheckBox); }

Target:
public void clickTemplateQuestionModalCheckBox(int questionNum) { WebElement questionCheckBox = browser.driver.findElement(By.id("addTemplateQuestion-" + questionNum)) .findElement(By.cssSelector("input")); click(questionCheckBox); }
Source:
public ReplicaMetadataRequestInfo(PartitionId partitionId, FindToken token, String hostName, String replicaPath) { if (partitionId == null || token == null || hostName == null || replicaPath == null) { logger.error( "A parameter in replica metadata request is null: " + "[Partition: " + partitionId + ", token: " + token + ", hostName: " + hostName + ", replicaPath: " + replicaPath); throw new IllegalArgumentException("no parameters of replica metadata request info can be null"); } this.partitionId = partitionId; this.token = token; this.hostName = hostName; this.replicaPath = replicaPath; }

Target:
public ReplicaMetadataRequestInfo(PartitionId partitionId, FindToken token, String hostName, String replicaPath) { if (partitionId == null || token == null || hostName == null || replicaPath == null) { throw new IllegalArgumentException( "A parameter in the replica metadata request is null: " + "[Partition: " + partitionId + ", token: " + token + ", hostName: " + hostName + ", replicaPath: " + replicaPath); } this.partitionId = partitionId; this.token = token; this.hostName = hostName; this.replicaPath = replicaPath; }
Source:
public void testRecursiveImportsMetadata() { try { WDLHandler.checkForRecursiveLocalImports(getSourceFile1().getContent(), getSourceFiles(), new HashSet<>(), "/"); Assert.fail("Should have detected recursive local import"); } catch (Exception e) { Assert.assertEquals("Recursive local import detected: /first-import.wdl", e.getMessage()); } }

Target:
public void testRecursiveImportsMetadata() { try { WDLHandler.checkForRecursiveLocalImports(getSourceFile1().getContent(), getSourceFiles(), new HashSet<>(), "/"); Assert.fail("Should have detected recursive local import"); } catch (ParseException e) { Assert.assertEquals("Recursive local import detected: /first-import.wdl", e.getMessage()); } }
Source:
private String getFilterCommandDefinition(String filterDriverName, String filterCommandType) { String key = filterDriverName + "." + filterCommandType; String filterCommand = filterCommandsByNameDotType.get(key); if (filterCommand != null) return filterCommand; filterCommand = config.getString(Constants.ATTR_FILTER, filterDriverName, filterCommandType); boolean useBuiltin = config.getBoolean(Constants.ATTR_FILTER, filterDriverName, Constants.ATTR_FILTER_USE_BUILTIN, false); if (useBuiltin) { String builtinFilterCommand = Constants.BUILTIN_FILTER_PREFIX + filterDriverName + "/" + filterCommandType; if (registeredCommands != null && registeredCommands.contains(builtinFilterCommand)) { filterCommand = builtinFilterCommand; } } if (filterCommand != null) { filterCommandsByNameDotType.put(key, filterCommand); } return filterCommand; }

Target:
private String getFilterCommandDefinition(String filterDriverName, String filterCommandType) { String key = filterDriverName + "." + filterCommandType; String filterCommand = filterCommandsByNameDotType.get(key); if (filterCommand != null) return filterCommand; filterCommand = config.getString(Constants.ATTR_FILTER, filterDriverName, filterCommandType); boolean useBuiltin = config.getBoolean(Constants.ATTR_FILTER, filterDriverName, Constants.ATTR_FILTER_USE_BUILTIN, false); if (useBuiltin) { String builtinFilterCommand = Constants.BUILTIN_FILTER_PREFIX + filterDriverName + "/" + filterCommandType; if (filterCommands != null && filterCommands.contains(builtinFilterCommand)) { filterCommand = builtinFilterCommand; } } if (filterCommand != null) { filterCommandsByNameDotType.put(key, filterCommand); } return filterCommand; }
Source:
public void sendSuccessfullyUpdatedAccountsNotification(List<Account> updatedAccounts) { Map<String, Object> model = new HashMap<>(); model.put("accounts", updatedAccounts); model.put("today", ZonedDateTime.now(UTC).toLocalDate()); String text = mailBuilder.buildMailBody("updated_accounts", model, LOCALE); mailSender.sendEmail(getMailSettings(), RecipientUtil.getMailAddresses( recipientService.getRecipientsWithNotificationType(MailNotification.NOTIFICATION_OFFICE)), getTranslation("subject.account.updatedRemainingDays"), text); sendTechnicalNotification(getTranslation("subject.account.updatedRemainingDays"), text); }

Target:
public void sendSuccessfullyUpdatedAccountsNotification(List<Account> updatedAccounts) { Map<String, Object> model = new HashMap<>(); model.put("accounts", updatedAccounts); model.put("today", LocalDate.now(UTC)); String text = mailBuilder.buildMailBody("updated_accounts", model, LOCALE); mailSender.sendEmail(getMailSettings(), RecipientUtil.getMailAddresses( recipientService.getRecipientsWithNotificationType(MailNotification.NOTIFICATION_OFFICE)), getTranslation("subject.account.updatedRemainingDays"), text); sendTechnicalNotification(getTranslation("subject.account.updatedRemainingDays"), text); }
Source:
public String[] getIdpInitSLOReturnToURLs() { return idpInitSLOReturnToURLs; }

Target:
public String[] getIdpInitSLOReturnToURLs() { if (idpInitSLOReturnToURLs == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } return idpInitSLOReturnToURLs.clone(); }
Source:
public void removeAllExpiredBans() { if(perunBl.isPerunReadOnly()) { log.debug("This instance is just read only so skip removing expired bans."); return; } try { getPerun().getResourcesManagerBl().removeAllExpiredBansOnResources(sess); getPerun().getFacilitiesManagerBl().removeAllExpiredBansOnFacilities(sess); } catch (InternalErrorException ex) { log.error("Synchronizer: removeAllExpiredBans, exception {}", ex); } }

Target:
public void removeAllExpiredBans() { if(perunBl.isPerunReadOnly()) { log.warn("This instance is just read only so skip removing expired bans."); return; } try { getPerun().getResourcesManagerBl().removeAllExpiredBansOnResources(sess); getPerun().getFacilitiesManagerBl().removeAllExpiredBansOnFacilities(sess); } catch (InternalErrorException ex) { log.error("Synchronizer: removeAllExpiredBans, exception {}", ex); } }
Source:
public void setCredentialsRefreshInterval( Integer credentialsRefreshInterval) { this.credentialsRefreshInterval = credentialsRefreshInterval * 1000; }

Target:
public void setCredentialsRefreshInterval( Integer credentialsRefreshInterval) { this.credentialsRefreshInterval = credentialsRefreshInterval; }
Source:
public Collection<ClassDefinition> generate(ExtensionContext input) throws UnableToCompleteException { PrintWriter printWriter = tryCreate(); if (printWriter != null) { mergeTemplate(printWriter); commit(printWriter); registerGinBinding(); } else { getLogger().debug("Jackson Mapper Provider already generated. Returning."); } return Lists.newArrayList(getClassDefinition()); }

Target:
public Collection<ClassDefinition> generate(ExtensionContext input) throws UnableToCompleteException { PrintWriter printWriter = tryCreate(); if (printWriter != null) { mergeTemplate(printWriter); commit(printWriter); registerGinBinding(); } else { getLogger().debug("Jackson Mapper Provider already generated. Returning."); } return Arrays.asList(getClassDefinition()); }
Source:
public void testConcatDoesNotSkipDuplicateSequencesInSameStream() { DomainEventStream concat = new ConcatenatingDomainEventStream(DomainEventStream.of(event1, event1, event2), DomainEventStream.of(event2, event2, event3), DomainEventStream.of(event3, event4)); assertTrue(concat.hasNext()); assertSame(event1.getPayload(), concat.next().getPayload()); assertSame(event1.getPayload(), concat.next().getPayload()); assertSame(event2.getPayload(), concat.next().getPayload()); assertSame(event3.getPayload(), concat.peek().getPayload()); assertSame(event3.getPayload(), concat.next().getPayload()); assertSame(event4.getPayload(), concat.peek().getPayload()); assertSame(event4.getPayload(), concat.next().getPayload()); assertFalse(concat.hasNext()); }

Target:
public void testConcatDoesNotSkipDuplicateSequencesInSameStream() { DomainEventStream concat = new ConcatenatingDomainEventStream(DomainEventStream.of(event1, event1, event2), DomainEventStream.of(event2, event2, event3), DomainEventStream.of(event3, event4)); assertTrue(concat.hasNext()); assertSame(event1.getPayload(), concat.next().getPayload()); assertSame(event1.getPayload(), concat.next().getPayload()); assertSame(event2.getPayload(), concat.next().getPayload()); assertSame(event3.getPayload(), concat.next().getPayload()); assertSame(event4.getPayload(), concat.next().getPayload()); assertFalse(concat.hasNext()); }
Source:
public boolean isModified(DirCacheEntry entry, boolean forceContentCheck, boolean checkFilemode, FS fs) { if (entry.isAssumeValid()) return false; if (entry.isUpdateNeeded()) return true; if (getEntryLength() != entry.getLength()) return true; int modeDiff = getEntryRawMode() ^ entry.getRawMode(); if (!checkFilemode) modeDiff &= ~FileMode.EXECUTABLE_FILE.getBits(); if (modeDiff != 0) return true; long cacheLastModified = entry.getLastModified(); long fileLastModified = getEntryLastModified(); if (cacheLastModified % 1000 == 0) fileLastModified = fileLastModified - fileLastModified % 1000; if ((fileLastModified != cacheLastModified) && !forceContentCheck) return true; if (forceContentCheck) { if (fileLastModified == cacheLastModified) return false; else return !getEntryObjectId().equals(entry.getObjectId()); } else { return fileLastModified != cacheLastModified; } }

Target:
public boolean isModified(DirCacheEntry entry, boolean forceContentCheck, boolean checkFilemode, FS fs) { if (entry.isAssumeValid()) return false; if (entry.isUpdateNeeded()) return true; if (getEntryLength() != entry.getLength()) return true; int modeDiff = getEntryRawMode() ^ entry.getRawMode(); if (!checkFilemode) modeDiff &= ~FileMode.EXECUTABLE_FILE.getBits(); if (modeDiff != 0) return true; long cacheLastModified = entry.getLastModified(); long fileLastModified = getEntryLastModified(); if (cacheLastModified % 1000 == 0) fileLastModified = fileLastModified - fileLastModified % 1000; if (forceContentCheck) { if (fileLastModified == cacheLastModified) return false; else return !getEntryObjectId().equals(entry.getObjectId()); } else { return fileLastModified != cacheLastModified; } }
Source:
private CompletableFuture<JobMasterGateway> getJobMasterGateway(JobID jobId) throws FlinkJobNotFoundException, UnavailableDispatcherOperationException { DispatcherJob job = runningJobs.get(jobId); if (job == null) { throw new FlinkJobNotFoundException(jobId); } if (!job.isRunning()) { throw new UnavailableDispatcherOperationException("Unable to get JobMasterGateway for initializing job. " + "The requested operation is not available while the JobManager is still initializing."); } return job.getJobMasterGateway(); }

Target:
private CompletableFuture<JobMasterGateway> getJobMasterGateway(JobID jobId) { DispatcherJob job = runningJobs.get(jobId); if (job == null) { return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)); } if (!job.isInitialized()) { return FutureUtils.completedExceptionally(new UnavailableDispatcherOperationException("Unable to get JobMasterGateway for initializing job. " + "The requested operation is not available while the JobManager is initializing.")); } return job.getJobMasterGateway(); }
Source:
public PermissionCollection getUserPermissions(Caller caller, Environment callEnvironment, JmxAction action, JmxTarget target) { return getUserPermissions(roleMapper.mapRoles(caller, callEnvironment, action == null ? null: action.composeAction(),(TargetResource) null)); }

Target:
public PermissionCollection getUserPermissions(Caller caller, Environment callEnvironment, JmxAction action, JmxTarget target) { return getUserPermissions(roleMapper.mapRoles(caller, callEnvironment, action, target)); }
Source:
public void testImportVMFromConfigurationWhenStorageDomainIsInMaintenance() { initCommand(getOvfEntityData()); StorageDomain storageDomain = createStorageDomain(); storageDomain.setStatus(StorageDomainStatus.Maintenance); doReturn(storageDomain).when(cmd).getStorageDomain(); assertFalse(cmd.canDoAction()); }

Target:
public void testImportVMFromConfigurationWhenStorageDomainIsInMaintenance() { initCommand(getOvfEntityData()); StorageDomain storageDomain = createStorageDomain(); storageDomain.setStatus(StorageDomainStatus.Maintenance); doReturn(storageDomain).when(cmd).getStorageDomain(); CanDoActionTestUtils.runAndAssertCanDoActionFailure(cmd, VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2); }
Source:
public void startDialog(KSService ks, STTService stt, TTSService tts, HumanLanguageInterpreter hli, AudioSource source, AudioSink sink, Locale locale, String keyword) { ks = (ks == null) ? getKS() : ks; stt = (stt == null) ? getSTT() : stt; tts = (tts == null) ? getTTS() : tts; hli = (hli == null) ? getHLI() : hli; source = (source == null) ? getSource() : source; sink = (sink == null) ? getSink() : sink; locale = (locale == null) ? localeProvider.getLocale() : locale; if (ks != null && stt != null && tts != null && hli != null && source != null && sink != null) { DialogProcessor processor = new DialogProcessor(getKS(), getSTT(), getTTS(), getHLI(), getSource(), getSink(), localeProvider.getLocale(), keyword); processor.start(); } else { String msg = "Cannot start dialog as services are missing."; logger.error(msg); throw new IllegalStateException(msg); } }

Target:
public void startDialog(KSService ks, STTService stt, TTSService tts, HumanLanguageInterpreter hli, AudioSource source, AudioSink sink, Locale locale, String keyword) { ks = (ks == null) ? getKS() : ks; stt = (stt == null) ? getSTT() : stt; tts = (tts == null) ? getTTS() : tts; hli = (hli == null) ? getHLI() : hli; source = (source == null) ? getSource() : source; sink = (sink == null) ? getSink() : sink; locale = (locale == null) ? localeProvider.getLocale() : locale; if (ks != null && stt != null && tts != null && hli != null && source != null && sink != null) { DialogProcessor processor = new DialogProcessor(ks, stt, tts, hli, source, sink, localeProvider.getLocale(), keyword); processor.start(); } else { String msg = "Cannot start dialog as services are missing."; logger.error(msg); throw new IllegalStateException(msg); } }
Source:
public Image bottomLayerMotiveMarkerFor(Entity entity) { Image marker = null; String weightSuffix = EntityWreckHelper.getWeightSuffix(entity); String motivePrefix = EntityWreckHelper.getMotivePrefix(entity); if(motivePrefix != null) { String filename = String.format("%s_decal_%s.png", motivePrefix, weightSuffix); String path = String.format("%s/%s", DIR_NAME_WRECKS, DIR_NAME_BOTTOM_DECALS); int rotationKey = entity.getId() % 4; String imageKey = String.format("%s%s", filename, rotationKey); if(!wreckageDecals.containsKey(imageKey)) { Image baseImage = TilesetManager.LoadSpecificImage(new File(Configuration.unitImagesDir(), path), filename); for(double x = 0; x < 4; x++) { RotateFilter rf = new RotateFilter(x * 90); String newImageKey = String.format("%s%s", filename, (int) x); ImageProducer ip = new FilteredImageSource(baseImage.getSource(), rf); Image resultImage = Toolkit.getDefaultToolkit().createImage(ip); wreckageDecals.put(newImageKey, resultImage); } } marker = wreckageDecals.get(imageKey); } return marker; }

Target:
public Image bottomLayerMotiveMarkerFor(Entity entity) { Image marker = null; String weightSuffix = EntityWreckHelper.getWeightSuffix(entity); String motivePrefix = EntityWreckHelper.getMotivePrefix(entity); if(motivePrefix != null) { String filename = String.format("%s_decal_%s.png", motivePrefix, weightSuffix); String path = String.format("%s/%s", DIR_NAME_WRECKS, DIR_NAME_BOTTOM_DECALS); int rotationKey = entity.getId() % NUM_DECAL_ROTATIONS; String imageKey = String.format("%s%s", filename, rotationKey); if(!wreckageDecals.containsKey(imageKey)) { Image baseImage = TilesetManager.LoadSpecificImage(new File(Configuration.unitImagesDir(), path), filename); for(double x = 0; x < NUM_DECAL_ROTATIONS; x++) { RotateFilter rf = new RotateFilter(x * 90); String newImageKey = String.format("%s%s", filename, (int) x); ImageProducer ip = new FilteredImageSource(baseImage.getSource(), rf); Image resultImage = Toolkit.getDefaultToolkit().createImage(ip); wreckageDecals.put(newImageKey, resultImage); } } marker = wreckageDecals.get(imageKey); } return marker; }
Source:
public void saveAs(OpenWorkpiece openWorkpiece, URI uri) throws IOException { if (uri.equals(openWorkpiece.getUri())) { save(openWorkpiece); } else { LockResult lockResult = openWorkpiece.getLockResult(); if (Objects.isNull(lockResult)) { lockResult = ServiceManager.getFileService().tryLock(uri, LockingMode.EXCLUSIVE); if (!lockResult.isSuccessful()) { throw new IOException(createLockErrorMessage(uri, lockResult.getConflicts())); } openWorkpiece.setLockResult(lockResult); } else { Map<URI, LockingMode> requests = new HashMap<>(2); requests.put(uri, LockingMode.EXCLUSIVE); Map<URI, Collection<String>> conflicts = lockResult.tryLock(requests); if (!conflicts.isEmpty()) { throw new IOException(createLockErrorMessage(uri, conflicts)); } } try (OutputStream out = ServiceManager.getFileService().write(uri, lockResult)) { logger.info("Saving {}", uri.toString()); metsXmlElementAccess.save(openWorkpiece.getWorkpiece(), out); } lockResult.close(openWorkpiece.getUri()); openWorkpiece.setUri(uri); } }

Target:
public void saveAs(OpenWorkpiece openWorkpiece, URI uri) throws IOException { if (uri.equals(openWorkpiece.getUri())) { save(openWorkpiece); } else { LockResult lockResult = openWorkpiece.getLockResult(); if (Objects.isNull(lockResult)) { lockResult = ServiceManager.getFileService().tryLock(uri, LockingMode.EXCLUSIVE); if (!lockResult.isSuccessful()) { throw new IOException(createLockErrorMessage(uri, lockResult.getConflicts())); } openWorkpiece.setLockResult(lockResult); } else { Map<URI, LockingMode> requests = new HashMap<>(2); requests.put(uri, LockingMode.EXCLUSIVE); Map<URI, Collection<String>> conflicts = lockResult.tryLock(requests); if (!conflicts.isEmpty()) { throw new IOException(createLockErrorMessage(uri, conflicts)); } } try (OutputStream out = ServiceManager.getFileService().write(uri, lockResult)) { logger.info("Saving {}", uri.toString()); write(openWorkpiece.getWorkpiece(), out); } lockResult.close(openWorkpiece.getUri()); openWorkpiece.setUri(uri); } }
Source:
public void run() { FileManifest manifest = server.fetchManifest(); Gui_JavaFX.getStackMainPane().getPaneSync().getObservMods().clear(); Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().getProgressBar().setProgress(0); double n = manifest.entries.size(); double count = 0; for(ManifestEntry entry : manifest.entries){ Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().getProgressBar().setProgress(count/n); Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().setPathText(entry.path); Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().setStatusText("Files updated : " +(int)count+"/"+(int)n); Platform.runLater(() -> Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().updateGUI()); Path file = entry.resolvePath(); Logger.debug(String.format("Starting check for file: %s", file)); if (!entry.redirectTo.equals("")) { Logger.debug(String.format( "File: %s, redirected from: %s to %s", file.getFileName(), entry.path, file )); } if (Files.exists(file)) { String hash = FileHash.hashFile(file); if (entry.hash.equals(hash)) { Logger.debug("File already exists"); }else{ server.updateIndividualFile(entry, file); } }else{ server.updateIndividualFile(entry, file); } Gui_JavaFX.getStackMainPane().getPaneSync().getObservMods().add(new Mod(entry.path, EValid.UPTODATE,false)); count++; }; Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().getProgressBar().setProgress(count/n); Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().setStatusText("Files updated : " +(int)count+"/"+(int)n); Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().setPathText("Done!"); Platform.runLater(() -> Gui_JavaFX.getStackMainPane().getPaneSync().getPaneProgressBar().updateGUI()); }

Target:
public void run() { FileManifest manifest = server.fetchManifest(); manifest.files .forEach(entry -> { Path file = entry.resolvePath(); Logger.debug(String.format("Starting check for file: %s", file)); if (!entry.redirectTo.equals("")) { Logger.debug(String.format( "File: %s, redirected from: %s to %s", file.getFileName(), entry.path, file )); } if (Files.exists(file)) { String hash = FileHash.hashFile(file); if (entry.hash.equals(hash)) { Logger.debug("File already exists"); } } }); }
Source:
public void testMap() throws Exception { String[] tableNames = getUniqueNames(2); String table1 = tableNames[0]; String table2 = tableNames[1]; try (AccumuloClient c = getAccumuloClient()) { c.tableOperations().create(table1); c.tableOperations().create(table2); BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig()); BatchWriter bw2 = c.createBatchWriter(table2, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation t1m = new Mutation(new Text(String.format("%s_%09x", table1, i + 1))); t1m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table1, i).getBytes())); bw.addMutation(t1m); Mutation t2m = new Mutation(new Text(String.format("%s_%09x", table2, i + 1))); t2m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table2, i).getBytes())); bw2.addMutation(t2m); } bw.close(); bw2.close(); MRTester.main(new String[] {table1, table2}); assertNull(e1); assertNull(e2); } }

Target:
public void testMap() throws Exception { String[] tableNames = getUniqueNames(2); String table1 = tableNames[0]; String table2 = tableNames[1]; try (AccumuloClient c = createAccumuloClient()) { c.tableOperations().create(table1); c.tableOperations().create(table2); BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig()); BatchWriter bw2 = c.createBatchWriter(table2, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation t1m = new Mutation(new Text(String.format("%s_%09x", table1, i + 1))); t1m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table1, i).getBytes())); bw.addMutation(t1m); Mutation t2m = new Mutation(new Text(String.format("%s_%09x", table2, i + 1))); t2m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table2, i).getBytes())); bw2.addMutation(t2m); } bw.close(); bw2.close(); MRTester.main(new String[] {table1, table2}); assertNull(e1); assertNull(e2); } }
Source:
protected long getEngineSessionSeqId() { return SessionDataContainer.getInstance().getEngineSessionSeqId(engineContext.getSessionId()); }

Target:
protected long getEngineSessionSeqId() { if (engineContext.getSessionId() == null) { throw new RuntimeException("No sessionId found for query " + getClass().getName()); } return SessionDataContainer.getInstance().getEngineSessionSeqId(engineContext.getSessionId()); }
Source:
protected void assertIsLegalCell(final int row, final int column) { int rowCount = rowCount(); int columnCount = columnCount(); Assert.isLegal(row < rowCount, "The row number (" + row + ") is more than the number of rows(" + rowCount + ") in the table."); Assert.isLegal((column < columnCount) || ((columnCount == 0) && (column == 0)), "The column number (" + column + ") is more than the number of column(" + columnCount + ") in the table."); }

Target:
protected void assertIsLegalCell(final int row, final int column) { int rowCount = rowCount(); int columnCount = columnCount(); Assert.isLegal(row < rowCount, "The row number (" + row + ") is more than the number of rows (" + rowCount + ") in the table."); Assert.isLegal((column < columnCount) || ((columnCount == 0) && (column == 0)), "The column number (" + column + ") is more than the number of columns (" + columnCount + ") in the table."); }
Source:
public EntityVampirism(World world) { super(world); moveTowardsRestriction = new EntityAIMoveTowardsRestriction(this, 1.0F); this.actionTasks = new EntityAITasks(world != null && world.profiler != null ? world.profiler : null); setAvailableActions(); if (world != null && !world.isRemote) { this.initEntityAI1(); } }

Target:
public EntityVampirism(World world) { super(world); setupEntityClass(); moveTowardsRestriction = new EntityAIMoveTowardsRestriction(this, 1.0F); }
Source:
public void testCompareWithTrackChanges() throws Exception { File tmpFile1 = File.createTempFile("File1", ".xml"); File tmpFile2 = File.createTempFile("File2", ".xml"); File diffFile = File.createTempFile("Diff", ".xml"); File scriptFile = File.createTempFile("script", ".vbs"); try { FileOutputStream stream1 = new FileOutputStream(tmpFile1); FileOutputStream stream2 = new FileOutputStream(tmpFile2); String content = Lib.fileToString(getClass(), TEST_WORD_EDIT_FILE_NAME); byte[] bytes = content.getBytes(); stream1.write(bytes); stream1.close(); content = content.replace("methods", "functions"); bytes = content.getBytes(); stream2.write(bytes); stream2.close(); CompareData compareData = new CompareData(diffFile.getAbsolutePath(), scriptFile.getAbsolutePath()); compareData.add(tmpFile1.getAbsolutePath(), tmpFile2.getAbsolutePath()); VbaWordDiffGenerator diff = new VbaWordDiffGenerator(false, false, false, true, false); diff.generate(compareData); InputStream diffStream = new FileInputStream(diffFile); String theDiff = Lib.inputStreamToString(diffStream); diffStream.close(); theDiff = removeDynamicInformation(theDiff); String expected = Lib.fileToString(getClass(), EXPECTED_WORD_DIFF_FILE_NAME); Assert.assertEquals(expected, theDiff); } finally { tmpFile1.delete(); tmpFile2.delete(); scriptFile.delete(); diffFile.delete(); } }

Target:
public void testCompareWithTrackChanges() throws Exception { TemporaryFolder tempFolder = new TemporaryFolder(); File tmpFile1 = tempFolder.newFile("File1.xml"); File tmpFile2 = tempFolder.newFile("File2.xml"); File diffFile = tempFolder.newFile("Diff.xml"); File scriptFile = tempFolder.newFile("script.vbs"); String content = Lib.fileToString(getClass(), TEST_WORD_EDIT_FILE_NAME); Lib.writeStringToFile(content, tmpFile1); content = content.replace("methods", "functions"); Lib.writeStringToFile(content, tmpFile2); CompareData compareData = new CompareData(diffFile.getAbsolutePath(), scriptFile.getAbsolutePath()); compareData.add(tmpFile1.getAbsolutePath(), tmpFile2.getAbsolutePath()); VbaWordDiffGenerator diff = new VbaWordDiffGenerator(false, false, false, true, false); diff.generate(compareData); String theDiff = Lib.fileToString(diffFile); theDiff = removeDynamicInformation(theDiff); String expected = Lib.fileToString(getClass(), EXPECTED_WORD_DIFF_FILE_NAME); Assert.assertEquals(expected, theDiff); }
Source:
private void updateActionEnablement(ISelection selection) { if (!(selection instanceof IStructuredSelection)) return; IStructuredSelection sel = (IStructuredSelection) selection; boolean allSelected = !sel.isEmpty() && sel.size() == getTable().getItemCount(); boolean submoduleSelected = false; for (Object item : sel.toArray()) if (((FileDiff) item).isSubmodule()) { submoduleSelected = true; break; } selectAll.setEnabled(!allSelected); copy.setEnabled(!sel.isEmpty()); if (!submoduleSelected) { boolean oneOrMoreSelected = !sel.isEmpty(); open.setEnabled(oneOrMoreSelected); compare.setEnabled(sel.size() == 1); blame.setEnabled(oneOrMoreSelected); if (sel.size() == 1) { FileDiff diff = (FileDiff) sel.getFirstElement(); boolean workTreeFileExists = false; if (diff.getChange() != ChangeType.DELETE) { String path = new Path(getRepository().getWorkTree() .getAbsolutePath()).append(diff.getNewPath()) .toOSString(); workTreeFileExists = new File(path).exists(); } compareWorkingTreeVersion.setEnabled(workTreeFileExists); openWorkingTreeVersion.setEnabled(workTreeFileExists); } else { compareWorkingTreeVersion.setEnabled(false); openWorkingTreeVersion.setEnabled(oneOrMoreSelected); } } else { open.setEnabled(false); openWorkingTreeVersion.setEnabled(false); compare.setEnabled(false); blame.setEnabled(false); compareWorkingTreeVersion.setEnabled(false); } }

Target:
private void updateActionEnablement(ISelection selection) { if (!(selection instanceof IStructuredSelection)) return; IStructuredSelection sel = (IStructuredSelection) selection; boolean allSelected = !sel.isEmpty() && sel.size() == getTable().getItemCount(); boolean submoduleSelected = false; for (Object item : sel.toArray()) if (((FileDiff) item).isSubmodule()) { submoduleSelected = true; break; } selectAll.setEnabled(!allSelected); copy.setEnabled(!sel.isEmpty()); if (!submoduleSelected) { boolean oneOrMoreSelected = !sel.isEmpty(); open.setEnabled(oneOrMoreSelected); compare.setEnabled(sel.size() == 1); blame.setEnabled(oneOrMoreSelected); if (sel.size() == 1) { FileDiff diff = (FileDiff) sel.getFirstElement(); String path = new Path(getRepository().getWorkTree() .getAbsolutePath()).append(diff.getPath()) .toOSString(); boolean workTreeFileExists = new File(path).exists(); compareWorkingTreeVersion.setEnabled(workTreeFileExists); openWorkingTreeVersion.setEnabled(workTreeFileExists); } else { compareWorkingTreeVersion.setEnabled(false); openWorkingTreeVersion.setEnabled(oneOrMoreSelected); } } else { open.setEnabled(false); openWorkingTreeVersion.setEnabled(false); compare.setEnabled(false); blame.setEnabled(false); compareWorkingTreeVersion.setEnabled(false); } }
Source:
public void testSetupActions() { Context context = getInstrumentation().getTargetContext(); View layout = mock(View.class); View view1 = new View(context); view1.setId(1); View view3 = new View(context); view3.setId(3); ListView listView = new ListView(context); listView.setId(2); setupActionList(); setupActionGetViewId(); setupTriggerType(); when(layout.findViewById(1)).thenReturn(view1); when(layout.findViewById(2)).thenReturn(listView); when(layout.findViewById(3)).thenReturn(view3); ComponentActionManager actionManager = new ComponentActionManager(actionList); actionManager.setupActions(layout); }

Target:
public void testSetupActions() { Context context = getInstrumentation().getTargetContext(); View layout = mock(View.class); View view1 = new View(context); view1.setId(1); View view3 = new View(context); view3.setId(3); ListView listView = new ListView(context); listView.setId(2); setupActionList(); when(layout.findViewById(1)).thenReturn(view1); when(layout.findViewById(2)).thenReturn(listView); when(layout.findViewById(3)).thenReturn(view3); ComponentActionManager actionManager = new ComponentActionManager(actionList); actionManager.setupActions(layout); }