auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public InterpreterResult interpret(String st, InterpreterContext context) throws InterpreterException { String algorithmPath = properties.getProperty( SubmarineConstants.SUBMARINE_ALGORITHM_HDFS_PATH, ""); if (algorithmPath.contains(SubmarineConstants.USERNAME_SYMBOL)) { algorithmPath = algorithmPath.replace(SubmarineConstants.USERNAME_SYMBOL, userName); properties.setProperty(SubmarineConstants.SUBMARINE_ALGORITHM_HDFS_PATH, algorithmPath); } String checkpointPath = properties.getProperty( SubmarineConstants.TF_CHECKPOINT_PATH, ""); if (checkpointPath.contains(SubmarineConstants.USERNAME_SYMBOL)) { checkpointPath = checkpointPath.replace(SubmarineConstants.USERNAME_SYMBOL, userName); properties.setProperty(SubmarineConstants.TF_CHECKPOINT_PATH, checkpointPath); } if (null == submarineInterpreter) { submarineInterpreter = getInterpreterInTheSameSessionByClassName( SubmarineInterpreter.class); submarineInterpreter.setPythonWorkDir(context.getNoteId(), getPythonWorkDir()); } SubmarineJob submarineJob = submarineContext.addOrGetSubmarineJob(this.properties, context); if (null != submarineJob && null != submarineJob.getHdfsClient()) { try { String noteId = context.getNoteId(); List<ParagraphInfo> paragraphInfos = context.getIntpEventClient() .getParagraphList(userName, noteId); submarineJob.getHdfsClient().saveParagraphToFiles( noteId, paragraphInfos, getPythonWorkDir().getAbsolutePath(), properties); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } return super.interpret(st, context); }

Target:
public InterpreterResult interpret(String st, InterpreterContext context) throws InterpreterException { setParagraphConfig(context); String algorithmPath = properties.getProperty( SubmarineConstants.SUBMARINE_ALGORITHM_HDFS_PATH, ""); if (algorithmPath.contains(SubmarineConstants.USERNAME_SYMBOL)) { algorithmPath = algorithmPath.replace(SubmarineConstants.USERNAME_SYMBOL, userName); properties.setProperty(SubmarineConstants.SUBMARINE_ALGORITHM_HDFS_PATH, algorithmPath); } String checkpointPath = properties.getProperty( SubmarineConstants.TF_CHECKPOINT_PATH, ""); if (checkpointPath.contains(SubmarineConstants.USERNAME_SYMBOL)) { checkpointPath = checkpointPath.replace(SubmarineConstants.USERNAME_SYMBOL, userName); properties.setProperty(SubmarineConstants.TF_CHECKPOINT_PATH, checkpointPath); } if (null == submarineInterpreter) { submarineInterpreter = getInterpreterInTheSameSessionByClassName(SubmarineInterpreter.class); if (null != submarineInterpreter) { submarineInterpreter.setPythonWorkDir(context.getNoteId(), getPythonWorkDir()); } } SubmarineJob submarineJob = submarineContext.addOrGetSubmarineJob(this.properties, context); if (null != submarineJob && null != submarineJob.getHdfsClient()) { try { String noteId = context.getNoteId(); List<ParagraphInfo> paragraphInfos = context.getIntpEventClient() .getParagraphList(userName, noteId); submarineJob.getHdfsClient().saveParagraphToFiles( noteId, paragraphInfos, getPythonWorkDir().getAbsolutePath(), properties); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } return super.interpret(st, context); }
Source:
public void testCreateFileHeader_Binary() throws Exception { ObjectId adId = blob("a\nd\n"); ObjectId binId = blob("a\nb\nc\n\0\0\0\0d\n"); String diffHeader = makeDiffHeader(PATH_A, PATH_B, adId, binId) + "Binary files differ\n"; DiffEntry ad = DiffEntry.delete(PATH_A, adId); DiffEntry abcd = DiffEntry.add(PATH_B, binId); DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 50); FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }

Target:
public void testCreateFileHeader_Binary() throws Exception { ObjectId adId = blob("a\nd\n"); ObjectId binId = blob("a\nb\nc\n\0\0\0\0d\n"); String diffHeader = makeDiffHeader(PATH_A, PATH_B, adId, binId) + "Binary files differ\n"; DiffEntry ad = DiffEntry.delete(PATH_A, adId); DiffEntry abcd = DiffEntry.add(PATH_B, binId); DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 0); FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }
Source:
public ResultSubpartitionStateHandle deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { final boolean hasResultSubpartitionStateHandle = dis.readInt() != 0; return hasResultSubpartitionStateHandle ? channelStateHandleSerializer.deserializeResultSubpartitionStateHandle(dis) : null; }

Target:
public StateObjectCollection<ResultSubpartitionStateHandle> deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { return deserializeCollection(dis, channelStateHandleSerializer::deserializeResultSubpartitionStateHandle); }
Source:
public <T extends Assignable> T createFromZipFile(final Class<T> type, final File archiveFile) throws IllegalArgumentException, ArchiveImportException { if (type == null) { throw new IllegalArgumentException("Type must be specified"); } if (archiveFile == null) { throw new IllegalArgumentException("File must be specified"); } if (!archiveFile.exists()) { throw new IllegalArgumentException("File for import does not exist: " + archiveFile.getAbsolutePath()); } if (archiveFile.isDirectory()) { throw new IllegalArgumentException("File for import must not be a directory: " + archiveFile.getAbsolutePath()); } ZipFile zipFile = null; try { zipFile = new ZipFile(archiveFile); return ShrinkWrap.create(type, archiveFile.getName()).as(ZipImporter.class).importFrom(zipFile).as(type); } catch (final ZipException ze) { throw new IllegalArgumentException("Does not appear to be a valid ZIP file: " + archiveFile.getAbsolutePath()); } catch (final IOException ioe) { throw new RuntimeException("I/O Error in importing new archive from ZIP: " + archiveFile.getAbsolutePath(), ioe); }finally { if(null != zipFile){ try { zipFile.close(); } catch (final IOException e) { } } } }

Target:
public <T extends Assignable> T createFromZipFile(final Class<T> type, final File archiveFile) throws IllegalArgumentException, ArchiveImportException { if (type == null) { throw new IllegalArgumentException("Type must be specified"); } if (archiveFile == null) { throw new IllegalArgumentException("File must be specified"); } if (!archiveFile.exists()) { throw new IllegalArgumentException("File for import does not exist: " + archiveFile.getAbsolutePath()); } if (archiveFile.isDirectory()) { throw new IllegalArgumentException("File for import must not be a directory: " + archiveFile.getAbsolutePath()); } try { return ShrinkWrap.create(type, archiveFile.getName()).as(ZipImporter.class).importFrom(new ZipFile(archiveFile)).as(type); } catch (final ZipException ze) { throw new IllegalArgumentException("Does not appear to be a valid ZIP file: " + archiveFile.getAbsolutePath()); } catch (final IOException ioe) { throw new RuntimeException("I/O Error in importing new archive from ZIP: " + archiveFile.getAbsolutePath(), ioe); } }
Source:
public List<String> getAttribute(final String key) { return attributes.containsKey(key)? attributes.get(key) : Collections.emptyList(); }

Target:
public List<String> getAttribute(final String key) { return attributes.getOrDefault(key, Collections.emptyList()); }
Source:
public boolean deleteImage(String id) { try { Integer imageId = Ints.tryParse(id); if (imageId != null) { api.getImageApi().delete(imageId); } else { api.getImageApi().delete(id); } return true; } catch (Exception ex) { return false; } }

Target:
public boolean deleteImage(String id) { try { Integer imageId = Ints.tryParse(id); if (imageId != null) { logger.debug(">> image does not have a slug. Using the id to delete the image..."); api.getImageApi().delete(imageId); } else { logger.debug(">> image has a slug. Using it to delete the image..."); api.getImageApi().delete(id); } return true; } catch (Exception ex) { return false; } }
Source:
public void testIndexersProduceSameIndexes() throws Exception { long bamFileSize = BAM_FILE.length(); for (long g : new long[] { 1, 2, 10, SBIIndexWriter.DEFAULT_GRANULARITY }) { SBIIndex index1 = fromBAMFile(BAM_FILE, g); SBIIndex index2 = fromSAMRecords(BAM_FILE, g); Assert.assertEquals(index1, index2); Assert.assertEquals(index1.dataFileLength(), bamFileSize); Assert.assertEquals(index2.dataFileLength(), bamFileSize); } }

Target:
public void testIndexersProduceSameIndexes() throws Exception { final long bamFileSize = BAM_FILE.length(); for (final long g : new long[] { 1, 2, 10, SBIIndexWriter.DEFAULT_GRANULARITY }) { final SBIIndex index1 = fromBAMFile(BAM_FILE, g); final SBIIndex index2 = fromSAMRecords(BAM_FILE, g); Assert.assertEquals(index1, index2); Assert.assertEquals(index1.dataFileLength(), bamFileSize); Assert.assertEquals(index2.dataFileLength(), bamFileSize); } }
Source:
protected boolean canAddVm(ArrayList<String> reasons, Collection<StorageDomain> destStorages) { VmStatic vmStaticFromParams = getParameters().getVmStaticData(); if (!canAddVm(reasons, vmStaticFromParams.getName(), getStoragePoolId(), vmStaticFromParams.getPriority())) { return false; } if (!validateCustomProperties(vmStaticFromParams, reasons)) { return false; } if (shouldCheckSpaceInStorageDomains()) { if (!getStoragePoolId().equals(getStoragePoolIdFromSourceImageContainer())) { reasons.add(EngineMessage.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH.toString()); return false; } for (StorageDomain domain : destStorages) { StorageDomainValidator storageDomainValidator = new StorageDomainValidator(domain); if (!validate(storageDomainValidator.isDomainExistAndActive())) { return false; } } if (!validateSpaceRequirements()) { return false; } } return VmHandler.validateDedicatedVdsExistOnSameCluster(vmStaticFromParams, getReturnValue().getValidateMessages()); }

Target:
protected boolean canAddVm(ArrayList<String> reasons, Collection<StorageDomain> destStorages) { VmStatic vmStaticFromParams = getParameters().getVmStaticData(); if (!canAddVm(reasons, vmStaticFromParams.getName(), getStoragePoolId(), vmStaticFromParams.getPriority())) { return false; } if (!validateCustomProperties(vmStaticFromParams, reasons)) { return false; } if (shouldCheckSpaceInStorageDomains()) { if (!getStoragePoolId().equals(getStoragePoolIdFromSourceImageContainer())) { reasons.add(EngineMessage.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH.toString()); return false; } for (StorageDomain domain : destStorages) { StorageDomainValidator storageDomainValidator = new StorageDomainValidator(domain); if (!validate(storageDomainValidator.isDomainExistAndActive())) { return false; } } if (!validateSpaceRequirements()) { return false; } } return VmHandler.validateDedicatedVdsExistOnSameCluster(vmStaticFromParams, getReturnValue().getValidationMessages()); }
Source:
public <T> List<T> getList(String key, Class<T> type) { List value = config.getList(key); if (value == null) { return notFound(key); } ; List<T> result = new ArrayList<T>(); for (Object part : value) { result.add(getDecoder().decode(type, part.toString())); } return result; }

Target:
public <T> List<T> getList(String key, Class<T> type) { List value = config.getList(key); if (value == null) { return notFound(key); } ; List<T> result = new ArrayList<T>(); for (Object part : value) { if (type.isInstance(part)) { result.add((T)part); } else if (part instanceof String) { result.add(getDecoder().decode(type, (String) part)); } else { throw new UnsupportedOperationException( "Property values other than " + type.getCanonicalName() +" or String not supported"); } } return result; }
Source:
public void handleDefaultDeviceResponse(final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleDefaultDeviceResponse for MessageType: {}", messageType); ResponseMessageResultType result = deviceResult; OsgpException osgpException = exception; if (deviceResult == ResponseMessageResultType.NOT_OK && exception == null) { LOGGER.error("Incorrect response received, exception should not be null when result is not ok"); osgpException = new TechnicalException(ComponentType.DOMAIN_PUBLIC_LIGHTING, "An unknown error occurred"); } if (deviceResult == ResponseMessageResultType.OK && exception != null) { LOGGER.error("Incorrect response received, result should be set to not ok when exception is not null"); result = ResponseMessageResultType.NOT_OK; } this.webServiceResponseMessageSender.send(ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException) .build()); }

Target:
public void handleDefaultDeviceResponse(final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleDefaultDeviceResponse for MessageType: {}", messageType); ResponseMessageResultType result = deviceResult; OsgpException osgpException = exception; if (deviceResult == ResponseMessageResultType.NOT_OK && exception == null) { LOGGER.error("Incorrect response received, exception should not be null when result is not ok"); osgpException = new TechnicalException(ComponentType.DOMAIN_PUBLIC_LIGHTING, "An unknown error occurred"); } if (deviceResult == ResponseMessageResultType.OK && exception != null) { LOGGER.error("Incorrect response received, result should be set to not ok when exception is not null"); result = ResponseMessageResultType.NOT_OK; } ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException) .build(); this.webServiceResponseMessageSender.send(responseMessage); }
Source:
public List<Task> getTasks(String username, String clientId, TaskStatus taskStatus, String offset, String limit) throws MambuApiException { ParamsMap paramsMap = new ParamsMap(); paramsMap.addParam(APIData.USERNAME, username); paramsMap.addParam(APIData.CLIENT_ID, clientId); paramsMap.addParam(APIData.STATUS, taskStatus.name()); paramsMap.put(APIData.OFFSET, offset); paramsMap.put(APIData.LIMIT, limit); String urlString = new String(mambuAPIService.createUrl(TASKS + "/")); String jsonResponse = mambuAPIService.executeRequest(urlString, paramsMap, Method.GET); Type collectionType = new TypeToken<List<Task>>() {}.getType(); List<Task> tasks = (List<Task>) GsonUtils.createGson().fromJson(jsonResponse, collectionType); return tasks; }

Target:
public List<Task> getTasks(String username, String clientId, TaskStatus taskStatus, String offset, String limit) throws MambuApiException { ParamsMap paramsMap = new ParamsMap(); paramsMap.addParam(APIData.USERNAME, username); paramsMap.addParam(APIData.CLIENT_ID, clientId); if (taskStatus != null) { paramsMap.addParam(APIData.STATUS, taskStatus.name()); } paramsMap.put(APIData.OFFSET, offset); paramsMap.put(APIData.LIMIT, limit); String urlString = new String(mambuAPIService.createUrl(TASKS + "/")); String jsonResponse = mambuAPIService.executeRequest(urlString, paramsMap, Method.GET); Type collectionType = new TypeToken<List<Task>>() {}.getType(); List<Task> tasks = (List<Task>) GsonUtils.createGson().fromJson(jsonResponse, collectionType); return tasks; }
Source:
public NotificationProcessor(Environment env){ int numThreads = env.getConfiguration().getWorkerThreads(); this.env = env; this.semaphore = new Semaphore(3 * numThreads); this.executor = Executors.newFixedThreadPool(numThreads); this.queue = new LinkedBlockingQueue<>(); this.executor = new ThreadPoolExecutor(numThreads, numThreads, 0L, TimeUnit.MILLISECONDS, queue); this.queuedWork = new HashSet<>(); this.observers = new Observers(env); }

Target:
public NotificationProcessor(Environment env){ int numThreads = env.getConfiguration().getWorkerThreads(); this.env = env; this.queue = new LinkedBlockingQueue<>(); this.executor = new ThreadPoolExecutor(numThreads, numThreads, 0L, TimeUnit.MILLISECONDS, queue); this.tracker = new NotificationTracker(); this.observers = new Observers(env); }
Source:
private static void saveEslintError(SensorContext context, EslintError eslintError, InputFile inputFile, String originalFilePath) { String eslintKey = eslintError.ruleId; if (eslintKey == null) { LOG.warn("Parse error issue from ESLint will not be imported, file " + inputFile.uri()); return; } TextRange location = getLocation(eslintError, inputFile); TextPointer start = location.start(); ExternalRuleLoader ruleLoader = EslintRulesDefinition.loader(eslintKey); RuleType ruleType = ruleLoader.ruleType(eslintKey); Severity severity = ruleLoader.ruleSeverity(eslintKey); Long effortInMinutes = ruleLoader.ruleConstantDebtMinutes(eslintKey); LOG.debug("External Eslint issue { file:\"{}\", id:{}, message:\"{}\", line:{}, offset:{}, type: {}, severity:{}, remediation:{} }", originalFilePath, eslintKey, eslintError.message, start.line(), start.lineOffset(), ruleType, severity, effortInMinutes); NewExternalIssue newExternalIssue = context.newExternalIssue(); NewIssueLocation primaryLocation = newExternalIssue.newLocation() .message(eslintError.message) .on(inputFile) .at(location); newExternalIssue .at(primaryLocation) .engineId(EslintRulesDefinition.REPOSITORY_KEY) .ruleId(eslintKey) .type(ruleType) .severity(severity) .remediationEffortMinutes(effortInMinutes) .save(); }

Target:
private static void saveEslintError(SensorContext context, EslintError eslintError, InputFile inputFile, String originalFilePath) { String eslintKey = eslintError.ruleId; if (eslintKey == null) { LOG.warn("Parse error issue from ESLint will not be imported, file " + inputFile.uri()); return; } TextRange location = getLocation(eslintError, inputFile); TextPointer start = location.start(); ExternalRuleLoader ruleLoader = EslintRulesDefinition.loader(eslintKey); RuleType ruleType = ruleLoader.ruleType(eslintKey); Severity severity = ruleLoader.ruleSeverity(eslintKey); Long effortInMinutes = ruleLoader.ruleConstantDebtMinutes(eslintKey); LOG.debug("Saving external ESLint issue { file:\"{}\", id:{}, message:\"{}\", line:{}, offset:{}, type: {}, severity:{}, remediation:{} }", originalFilePath, eslintKey, eslintError.message, start.line(), start.lineOffset(), ruleType, severity, effortInMinutes); NewExternalIssue newExternalIssue = context.newExternalIssue(); NewIssueLocation primaryLocation = newExternalIssue.newLocation() .message(eslintError.message) .on(inputFile) .at(location); newExternalIssue .at(primaryLocation) .engineId(EslintRulesDefinition.REPOSITORY_KEY) .ruleId(eslintKey) .type(ruleType) .severity(severity) .remediationEffortMinutes(effortInMinutes) .save(); }
Source:
protected Build createBuild(List<Artifact> artifacts, List<Dependency> dependencies) { ModuleBuilder moduleBuilder = new ModuleBuilder().id(moduleName); if (artifacts != null) { moduleBuilder.artifacts(artifacts); } if (dependencies != null) { moduleBuilder.dependencies(dependencies); } List<Module> modules = Lists.newArrayList(moduleBuilder.build()); Build build = new Build(); build.setModules(modules); return build; }

Target:
protected Build createBuild(List<Artifact> artifacts, List<Dependency> dependencies) { ModuleBuilder moduleBuilder = new ModuleBuilder().id(moduleName); if (artifacts != null) { moduleBuilder.artifacts(artifacts); } if (dependencies != null) { moduleBuilder.dependencies(dependencies); } List<Module> modules = Arrays.asList(moduleBuilder.build()); Build build = new Build(); build.setModules(modules); return build; }
Source:
public void doRegistration(final SchedulerDriver driver, Protos.FrameworkID id) { _driver = driver; _stormScheduler = new StormSchedulerImpl(_driver); _state.put(FRAMEWORK_ID, id.getValue()); _offers = new HashMap<Protos.OfferID, Protos.Offer>(); _timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Collection<TaskStatus> taskStatuses = new ArrayList<TaskStatus>(); _driver.reconcileTasks(taskStatuses); LOG.info("Performing tasking reconciliation between scheduler and master"); } }, TASK_RECONCILIATION_INTERVAL, TASK_RECONCILIATION_INTERVAL); }

Target:
public void doRegistration(final SchedulerDriver driver, Protos.FrameworkID id) { _driver = driver; _stormScheduler = new StormSchedulerImpl(_driver); _state.put(FRAMEWORK_ID, id.getValue()); _offers = new HashMap<Protos.OfferID, Protos.Offer>(); _timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Collection<TaskStatus> taskStatuses = new ArrayList<TaskStatus>(); List<String> logviewerPaths = _zkClient.getChildren(_logviewerZkDir); if (logviewerPaths == null) { _driver.reconcileTasks(taskStatuses); return; } for (String path : logviewerPaths) { TaskID logviewerTaskId = TaskID.newBuilder() .setValue(new String(_zkClient.getNodeData(String.format("%s/%s", _logviewerZkDir, path)))) .build(); TaskStatus logviewerTaskStatus = TaskStatus.newBuilder() .setTaskId(logviewerTaskId) .setState(TaskState.TASK_RUNNING) .build(); taskStatuses.add(logviewerTaskStatus); } _driver.reconcileTasks(taskStatuses); LOG.info("Performing task reconciliation between scheduler and master on following tasks: {}", taskStatuses.toString()); } }, 0, TASK_RECONCILIATION_INTERVAL); }
Source:
protected int compareSecure(Value v, CompareMode mode) { return compare(valueType, this, v); }

Target:
protected int compareSecure(Value v, CompareMode mode) { return compare(this, v); }
Source:
public Token appendCheckpoint(Token snapshotTimestamp) { long start = System.currentTimeMillis(); rt.getObjectsView().TXBuild() .type(TransactionType.SNAPSHOT) .snapshot(snapshotTimestamp) .build() .begin(); try (Stream<Map.Entry> entries = this.map.entryStream()) { log.info("appendCheckpoint: Started checkpoint for at snapshot {}", streamId, snapshotTimestamp); startCheckpoint(snapshotTimestamp); int entryCount = appendObjectState(entries); finishCheckpoint(); long cpDuration = System.currentTimeMillis() - start; log.info("appendCheckpoint: completed checkpoint for {}, entries({}), " + "cpSize({}) bytes at snapshot in ms", streamId, entryCount, numBytes, snapshotTimestamp, cpDuration); } finally { rt.getObjectsView().TXEnd(); } return snapshotTimestamp; }

Target:
public Token appendCheckpoint(Token snapshotTimestamp) { long start = System.currentTimeMillis(); rt.getObjectsView().TXBuild() .type(TransactionType.SNAPSHOT) .snapshot(snapshotTimestamp) .build() .begin(); log.info("appendCheckpoint: Started checkpoint for at snapshot {}", streamId, snapshotTimestamp); try (Stream<Map.Entry> entries = this.map.entryStream()) { startCheckpoint(snapshotTimestamp); int entryCount = appendObjectState(entries); finishCheckpoint(); long cpDuration = System.currentTimeMillis() - start; log.info("appendCheckpoint: completed checkpoint for {}, entries({}), " + "cpSize({}) bytes at snapshot in ms", streamId, entryCount, numBytes, snapshotTimestamp, cpDuration); } finally { rt.getObjectsView().TXEnd(); } return snapshotTimestamp; }
Source:
static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final JChannel channel, final String channelName) throws Exception { final long refreshTimeout = config.getRefreshTimeout(); final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout(); final BroadcastEndpointFactory endpointFactory = new ForkChannelBroadcastEndpointFactory(channel, channelName); return new DiscoveryGroupConfiguration() .setName(name) .setRefreshTimeout(refreshTimeout) .setDiscoveryInitialWaitTimeout(initialWaitTimeout) .setBroadcastEndpointFactory(endpointFactory); }

Target:
static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final JChannel channel, final String channelName) throws Exception { final long refreshTimeout = config.getRefreshTimeout(); final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout(); final BroadcastEndpointFactory endpointFactory = new ClosingChannelBroadcastEndpointFactory(channel, channelName); return new DiscoveryGroupConfiguration() .setName(name) .setRefreshTimeout(refreshTimeout) .setDiscoveryInitialWaitTimeout(initialWaitTimeout) .setBroadcastEndpointFactory(endpointFactory); }
Source:
public boolean validate(boolean customBondNameSupported) { getBond().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), new LengthValidation(BusinessEntitiesDefinitions.HOST_NIC_NAME_LENGTH), customBondNameSupported ? new CustomBondNameValidation() : new NumberOnlyBondNameValidation() }); getCustomBondEditor().setIsValid(true); if (getBondingOptions().getSelectedItem().getKey().equals(CUSTOM_BONDING_MODE)) { getCustomBondEditor().validateEntity(new IValidation[] { new KeyValueFormatValidation() }); } return getBond().getIsValid() && getCustomBondEditor().getIsValid(); }

Target:
public boolean validate(boolean customBondNameSupported) { getBond().validateSelectedItem(new IValidation[] { new NotEmptyValidation(), new LengthValidation(BusinessEntitiesDefinitions.HOST_NIC_NAME_LENGTH), customBondNameSupported ? CUSTOM_BOND_NAME_VALIDATION : NUM_ONLY_BOND_NAME_VALIDATION }); getCustomBondEditor().setIsValid(true); if (getBondingOptions().getSelectedItem().getKey().equals(CUSTOM_BONDING_MODE)) { getCustomBondEditor().validateEntity(new IValidation[] { new KeyValueFormatValidation() }); } return getBond().getIsValid() && getCustomBondEditor().getIsValid(); }
Source:
public void loopProcessRedirectIntoFile() throws IOException, InterruptedException { final File file = temporaryFolder.newFile(); final ProcessBuilder pb = new ProcessBuilder(commands); final Process process = ProcessBuilderExecutor.asyncExecute(pb, file); Thread.sleep(3000); log.info("Terminate process"); process.destroy(); assertEquals(0, process.waitFor()); assertThat(FileUtils.readFileToString(file), allOf(containsString("Sleep over"))); }

Target:
public void loopProcessRedirectIntoFile() throws IOException, InterruptedException { final File file = temporaryFolder.newFile(); final ProcessBuilder pb = new ProcessBuilder(commands); final Process process = ProcessBuilderExecutor.asyncExecute(pb, file); Thread.sleep(3000); log.info("Terminate process"); process.destroy(); assertEquals(0, process.waitFor()); assertThat(FileUtils.readFileToString(file), is(containsString("Sleep over"))); }
Source:
public static AccessModifier getAccessModifierFromModifiersToken(DetailAST modifiersToken) { if (modifiersToken == null || modifiersToken.getType() != TokenTypes.MODIFIERS) { throw new IllegalArgumentException("expected non-null AST-token with type 'MODIFIERS'"); } AccessModifier accessModifier = AccessModifier.PACKAGE_LOCAL; for (AST token = modifiersToken.getFirstChild(); token != null; token = token.getNextSibling()) { if ("public".equals(token.getText())) { accessModifier = AccessModifier.PUBLIC; } else if ("protected".equals(token.getText())) { accessModifier = AccessModifier.PROTECTED; } else if ("private".equals(token.getText())) { accessModifier = AccessModifier.PRIVATE; } } return accessModifier; }

Target:
public static AccessModifier getAccessModifierFromModifiersToken(DetailAST modifiersToken) { if (modifiersToken == null || modifiersToken.getType() != TokenTypes.MODIFIERS) { throw new IllegalArgumentException("expected non-null AST-token with type 'MODIFIERS'"); } AccessModifier accessModifier = AccessModifier.PACKAGE; for (AST token = modifiersToken.getFirstChild(); token != null; token = token.getNextSibling()) { final int tokenType = token.getType(); if (tokenType == TokenTypes.LITERAL_PUBLIC) { accessModifier = AccessModifier.PUBLIC; } else if (tokenType == TokenTypes.LITERAL_PROTECTED) { accessModifier = AccessModifier.PROTECTED; } else if (tokenType == TokenTypes.LITERAL_PRIVATE) { accessModifier = AccessModifier.PRIVATE; } } return accessModifier; }
Source:
public LayerNormBp(INDArray input, INDArray gain, INDArray bias, INDArray grad, INDArray dLdx, INDArray dLdg, INDArray dLdb, int... dimensions) { super("layer_norm_bp", new INDArray[]{input, gain, bias, grad}, new INDArray[]{dLdx, dLdg, dLdb}); this.dimensions = dimensions; addIArgument(dimensions); }

Target:
public LayerNormBp(INDArray input, INDArray gain, INDArray bias, INDArray grad, INDArray dLdx, INDArray dLdg, INDArray dLdb, int... dimensions) { super("layer_norm_bp", new INDArray[]{input, gain, bias, grad}, new INDArray[]{dLdx, dLdg, dLdb}); Preconditions.checkArgument(bias != null, "LayerNormBp: Use constructor without bias argument if bias is null / not available."); setDimensions(dimensions); }
Source:
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IMAGE_REQUEST){ if(resultCode == Activity.RESULT_OK) { patientPhoto = getPortraitImage(output.getPath()); Bitmap bitmap = ThumbnailUtils.extractThumbnail(patientPhoto, patientImageView.getWidth(), patientImageView.getHeight()); patientImageView.setImageBitmap(bitmap); patientImageView.invalidate(); }else if(resultCode == Activity.RESULT_CANCELED) { output = null; } } }

Target:
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IMAGE_REQUEST){ if(resultCode == Activity.RESULT_OK) { patientPhoto = getPortraitImage(output.getPath()); Bitmap bitmap = ThumbnailUtils.extractThumbnail(patientPhoto, patientImageView.getWidth(), patientImageView.getHeight()); patientImageView.setImageBitmap(bitmap); patientImageView.invalidate(); }else { output = null; } } }
Source:
long getNumberRunsScratch(Map<byte[], byte[]> rawFamily) { long numberRuns = 0L; if (rawFamily != null) { numberRuns = rawFamily.size(); } if(numberRuns == 0L) { LOG.error("Number of runs in scratch column family can't be 0," +" if processing within TTL"); } LOG.trace("number of runs in getNumberRunsScratch " + numberRuns); return numberRuns; }

Target:
long getNumberRunsScratch(Map<byte[], byte[]> rawFamily) { long numberRuns = 0L; if (rawFamily != null) { numberRuns = rawFamily.size(); } if(numberRuns == 0L) { LOG.error("Number of runs in scratch column family can't be 0," +" if processing within TTL"); throw new ProcessingException("Number of runs is 0"); } return numberRuns; }
Source:
private static void validatePropertySection(String fileName, String sectionName, Node subSection, Object instance) throws Exception { final Set<String> properties = getProperties(instance.getClass()); final Class<?> clss = instance.getClass(); fixCapturedProperties(sectionName, instance, clss, properties); if (subSection != null) { Assert.assertTrue(fileName + " section '" + sectionName + "' should have no properties to show", !properties.isEmpty()); final Set<Node> nodes = XmlUtil.getChildrenElements(subSection); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' should have one child node", 1, nodes.size()); final Node div = nodes.iterator().next(); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' has unexpected child node", "div", div.getNodeName()); final Node table = XmlUtil.getFirstChildElement(div); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' has unexpected child node", "table", table.getNodeName()); validatePropertySectionProperties(fileName, sectionName, table, instance, properties); } Assert.assertTrue(fileName + " section '" + sectionName + "' should show properties: " + properties, properties.isEmpty()); }

Target:
private static void validatePropertySection(String fileName, String sectionName, Node subSection, Object instance) throws Exception { final Set<String> properties = getProperties(instance.getClass()); final Class<?> clss = instance.getClass(); fixCapturedProperties(sectionName, instance, clss, properties); if (subSection != null) { Assert.assertTrue(fileName + " section '" + sectionName + "' should have no properties to show", !properties.isEmpty()); final Set<Node> nodes = XmlUtil.getChildrenElements(subSection); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' should have one child node", 1, nodes.size()); final Node div = nodes.iterator().next(); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' has unexpected child node", "div", div.getNodeName()); final String wrapperMessage = fileName + " section '" + sectionName + "' subsection 'Properties' wrapping div for table needs the" + " class 'wrapper'"; Assert.assertTrue(wrapperMessage, div.hasAttributes()); Assert.assertNotNull(wrapperMessage, div.getAttributes().getNamedItem("class").getNodeValue()); Assert.assertTrue(wrapperMessage, div.getAttributes().getNamedItem("class").getNodeValue().contains("wrapper")); final Node table = XmlUtil.getFirstChildElement(div); Assert.assertEquals(fileName + " section '" + sectionName + "' subsection 'Properties' has unexpected child node", "table", table.getNodeName()); validatePropertySectionProperties(fileName, sectionName, table, instance, properties); } Assert.assertTrue(fileName + " section '" + sectionName + "' should show properties: " + properties, properties.isEmpty()); }
Source:
public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem itemAsSlimefunItem) { if (SlimefunTag.SHULKER_BOXES.isTagged(item.getType())) { return false; } if (SlimefunItem.getByID(getId()) instanceof HazmatBackpack && !(itemAsSlimefunItem instanceof Radioactive)) { return false; } if (itemAsSlimefunItem instanceof Radioactive && !(SlimefunItem.getByID(getId()) instanceof HazmatBackpack)) { return false; } return !(itemAsSlimefunItem instanceof SlimefunBackpack); }

Target:
public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem itemAsSlimefunItem) { if (SlimefunTag.SHULKER_BOXES.isTagged(item.getType())) { return false; } if (this instanceof HazmatBackpack && !(itemAsSlimefunItem instanceof Radioactive)) { return false; } if (itemAsSlimefunItem instanceof Radioactive && !(this instanceof HazmatBackpack)) { return false; } return !(itemAsSlimefunItem instanceof SlimefunBackpack); }
Source:
private boolean init(ChangeBoundsRequest request, GraphicalEditPart hostGraphicalEditPart) { List<?> editParts = request.getEditParts(); boolean isInLayoutingMode = isInLayoutingMode(hostGraphicalEditPart); for (Object editPart : editParts) { if (editPart instanceof DragAndDropWrapper) { DragAndDropWrapper dragAndDropWrapperToDrop = (DragAndDropWrapper) editPart; elementsFromEclipseViewToDrop.add(dragAndDropWrapperToDrop); } else if (editPart instanceof IGraphicalEditPart) { IGraphicalEditPart graphicalEditPartToDrop = (IGraphicalEditPart) editPart; if (!(graphicalEditPartToDrop.getParent() == hostGraphicalEditPart || hostGraphicalEditPart instanceof CompartmentEditPart && graphicalEditPartToDrop.getParent() == hostGraphicalEditPart.getParent()) && graphicalEditPartToDrop.resolveSemanticElement() instanceof DSemanticDecorator) { EObject elementFromDiagramToDrop = graphicalEditPartToDrop.resolveSemanticElement(); DDiagramElement dDiagramElementTopDrop = (DDiagramElement) elementFromDiagramToDrop; elementsFromDiagramToDrop.add(dDiagramElementTopDrop); editPartsFromDiagramToDrop.add(graphicalEditPartToDrop); if (isInLayoutingMode && (graphicalEditPartToDrop instanceof IDiagramBorderNodeEditPart || graphicalEditPartToDrop instanceof INodeEditPart)) { return false; } } } } return true; }

Target:
private boolean init(ChangeBoundsRequest request, GraphicalEditPart hostGraphicalEditPart) { List<?> editParts = request.getEditParts(); boolean isInLayoutingMode = new EditPartQuery(hostGraphicalEditPart).isInLayoutingMode(); for (Object editPart : editParts) { if (editPart instanceof DragAndDropWrapper) { DragAndDropWrapper dragAndDropWrapperToDrop = (DragAndDropWrapper) editPart; elementsFromEclipseViewToDrop.add(dragAndDropWrapperToDrop); } else if (editPart instanceof IGraphicalEditPart) { IGraphicalEditPart graphicalEditPartToDrop = (IGraphicalEditPart) editPart; if (!(graphicalEditPartToDrop.getParent() == hostGraphicalEditPart || hostGraphicalEditPart instanceof CompartmentEditPart && graphicalEditPartToDrop.getParent() == hostGraphicalEditPart.getParent()) && graphicalEditPartToDrop.resolveSemanticElement() instanceof DSemanticDecorator) { EObject elementFromDiagramToDrop = graphicalEditPartToDrop.resolveSemanticElement(); DDiagramElement dDiagramElementTopDrop = (DDiagramElement) elementFromDiagramToDrop; elementsFromDiagramToDrop.add(dDiagramElementTopDrop); editPartsFromDiagramToDrop.add(graphicalEditPartToDrop); if (isInLayoutingMode && graphicalEditPartToDrop instanceof IAbstractDiagramNodeEditPart) { return false; } } } } return true; }
Source:
public void verifyStatus(String expectedStatus) { for (int i = 0; i < VERIFICATION_RETRY_COUNT; i++) { try { waitForElementVisibility(statusMessage); if (expectedStatus.equals(getStatus())) { break; } } catch (StaleElementReferenceException e) { } if (i == VERIFICATION_RETRY_COUNT - 1) { assertEquals(expectedStatus, getStatus()); break; } ThreadHelper.waitFor(VERIFICATION_RETRY_DELAY_IN_MS); } }

Target:
public AppPage verifyStatus(String expectedStatus){ for (int i = 0; i < VERIFICATION_RETRY_COUNT; i++) { if (i == VERIFICATION_RETRY_COUNT - 1) { waitForElementVisibility(statusMessage); assertEquals(expectedStatus, getStatus()); break; } try { waitForElementVisibility(statusMessage); if (expectedStatus.equals(getStatus())) { break; } } catch (StaleElementReferenceException e) { } ThreadHelper.waitFor(VERIFICATION_RETRY_DELAY_IN_MS); } return this; }
Source:
protected void init() { getNameTextField().setText(scanner.getName()); getConfigurationTextField().setText(scanner.getConf()); getConfigurationTextField().discardAllEdits(); getRequestUrlRegexTextField().setText(scanner.getRequestUrlRegex()); getRequestUrlRegexTextField().discardAllEdits(); getRequestHeaderRegexTextField().setText(scanner.getRequestHeaderRegex()); getRequestHeaderRegexTextField().discardAllEdits(); getResponseHeaderRegexTextField().setText(scanner.getResponseHeaderRegex()); getResponseHeaderRegexTextField().discardAllEdits(); getResponseBodyRegexTextField().setText(scanner.getResponseBodyRegex()); getResponseBodyRegexTextField().discardAllEdits(); getEnabledCheckBox().setSelected(scanner.isEnabled()); }

Target:
protected void init() { getNameTextField().setText(scanner.getName()); getNameTextField().discardAllEdits(); getConfigurationTextField().setText(scanner.getConf()); getConfigurationTextField().discardAllEdits(); getRequestUrlRegexTextField().setText(scanner.getRequestUrlRegex()); getRequestUrlRegexTextField().discardAllEdits(); getRequestHeaderRegexTextField().setText(scanner.getRequestHeaderRegex()); getRequestHeaderRegexTextField().discardAllEdits(); getResponseHeaderRegexTextField().setText(scanner.getResponseHeaderRegex()); getResponseHeaderRegexTextField().discardAllEdits(); getResponseBodyRegexTextField().setText(scanner.getResponseBodyRegex()); getResponseBodyRegexTextField().discardAllEdits(); getEnabledCheckBox().setSelected(scanner.isEnabled()); }
Source:
private void expandConcepts(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSet theTermValueSet, int theOffset, int theCount) { int conceptsExpanded = 0; int toIndex = theOffset + theCount; Supplier<Slice<TermValueSetConcept>> loader = () -> myValueSetConceptDao.findByTermValueSetIdAndPreFetchDesignations(SearchCoordinatorSvcImpl.toPage(theOffset, toIndex), theTermValueSet.getId()); Slice<TermValueSetConcept> slice = loader.get(); if (!slice.hasContent()) { logConceptsExpanded(theTermValueSet, conceptsExpanded); return; } for (TermValueSetConcept concept : slice.getContent()) { ValueSet.ValueSetExpansionContainsComponent containsComponent = theExpansionComponent.addContains(); containsComponent.setSystem(concept.getSystem()); containsComponent.setCode(concept.getCode()); containsComponent.setDisplay(concept.getDisplay()); expandDesignations(theTermValueSet, concept, containsComponent); if (++conceptsExpanded % 250 == 0) { logConceptsExpanded(theTermValueSet, conceptsExpanded); } } logConceptsExpanded(theTermValueSet, conceptsExpanded); }

Target:
private void expandConcepts(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSet theTermValueSet, int theOffset, int theCount) { int conceptsExpanded = 0; int toIndex = theOffset + theCount; Slice<TermValueSetConcept> slice = myValueSetConceptDao.findByTermValueSetIdAndPreFetchDesignations(SearchCoordinatorSvcImpl.toPage(theOffset, toIndex), theTermValueSet.getId()); if (!slice.hasContent()) { logConceptsExpanded(theTermValueSet, conceptsExpanded); return; } for (TermValueSetConcept concept : slice.getContent()) { ValueSet.ValueSetExpansionContainsComponent containsComponent = theExpansionComponent.addContains(); containsComponent.setSystem(concept.getSystem()); containsComponent.setCode(concept.getCode()); containsComponent.setDisplay(concept.getDisplay()); expandDesignations(theTermValueSet, concept, containsComponent); if (++conceptsExpanded % 250 == 0) { logConceptsExpanded(theTermValueSet, conceptsExpanded); } } logConceptsExpanded(theTermValueSet, conceptsExpanded); }
Source:
private void validateSupportedHostGroup(Cluster cluster, String requestHostGroup, AlertType alertType) { Set<String> supportedHostGroups = Optional.ofNullable( recommendationService.getAutoscaleRecommendations(cluster.getStackCrn())).map( recommendation -> { if (AlertType.LOAD.equals(alertType)) { return recommendation.getLoadBasedHostGroups(); } if (AlertType.TIME.equals(alertType)) { return recommendation.getTimeBasedHostGroups(); } return Set.of(""); }).orElse(Set.of("")); if (!supportedHostGroups.contains(requestHostGroup)) { throw new BadRequestException(messagesService.getMessage(MessageCode.UNSUPPORTED_AUTOSCALING_HOSTGROUP, List.of(requestHostGroup, alertType, cluster.getStackName(), supportedHostGroups))); } }

Target:
private void validateSupportedHostGroup(Cluster cluster, String requestHostGroup, AlertType alertType) { Set<String> supportedHostGroups = Optional.ofNullable( recommendationService.getAutoscaleRecommendations(cluster.getStackCrn())).map( recommendation -> { if (AlertType.LOAD.equals(alertType)) { return Optional.ofNullable(recommendation.getLoadBasedHostGroups()).orElse(Set.of()); } if (AlertType.TIME.equals(alertType)) { return Optional.ofNullable(recommendation.getTimeBasedHostGroups()).orElse(Set.of()); } return Set.of(""); }).orElse(Set.of("")); if (!supportedHostGroups.contains(requestHostGroup)) { throw new BadRequestException(messagesService.getMessage(MessageCode.UNSUPPORTED_AUTOSCALING_HOSTGROUP, List.of(requestHostGroup, alertType, cluster.getStackName(), supportedHostGroups))); } }
Source:
public void testGetSlashValidSlashDotGitSlashHumanishName() { String humanishName = URIish.getHumanishName("/abc/.git"); assertEquals("abc", humanishName); }

Target:
public void testGetSlashValidSlashDotGitSlashHumanishName() throws IllegalArgumentException, URISyntaxException { String humanishName = new URIish("/abc/.git").getHumanishName(); assertEquals("abc", humanishName); }
Source:
public boolean equals(Object o) { if(this == o) return true; if(o == null || getClass() != o.getClass()) return false; MCItemStack that = (MCItemStack) o; return internal.equals(that.internal); }

Target:
public boolean equals(Object o) { if(this == o) return true; if(o == null || getClass() != o.getClass()) return false; final ItemStack thatStack = ((MCItemStack) o).internal; final ItemStack thisStack = this.internal; if(thisStack.isEmpty()) { return thatStack.isEmpty(); } if(thisStack.getCount() != thatStack.getCount()) { return false; } if(!Objects.equals(thisStack.getItem(), thatStack.getItem())) { return false; } if(!Objects.equals(thisStack.getTag(), thatStack.getTag())) { return false; } return thisStack.areCapsCompatible(thatStack); }
Source:
public PrefetchableAndPredicate( Collection<? extends Predicate<ChangeData>> that) { super(that); }

Target:
PrefetchableAndPredicate( Collection<? extends Predicate<ChangeData>> that) { super(that); }
Source:
public VariantSourceEntry convert(DBObject object) { BasicDBObject mongoGenotypes = (BasicDBObject) object.get(SAMPLES_FIELD); VariantSourceEntry fileWithSamples = new VariantSourceEntry(object.get(FILEID_FIELD).toString(), object.get(STUDYID_FIELD).toString()); for (Object gtToIndexesObj: mongoGenotypes.entrySet()) { Map.Entry<String, Object> gtToIndexes = (Map.Entry) gtToIndexesObj; if (gtToIndexes.getKey().equals("def")) { fileWithSamples = addGenotypeToVariantSourceEntry(fileWithSamples, "def", (String) gtToIndexes.getValue()); } else { String gtString = (String) gtToIndexes.getKey(); List<Integer> indexes = (List<Integer>) gtToIndexes.getValue(); for (Integer index : indexes) { fileWithSamples = addGenotypeToVariantSourceEntry(fileWithSamples, Integer.toString(index), gtString); } } } return fileWithSamples; }

Target:
public VariantSourceEntry convert(DBObject object) { BasicDBObject mongoGenotypes = (BasicDBObject) object.get(SAMPLES_FIELD); VariantSourceEntry fileWithSamples = new VariantSourceEntry(object.get(FILEID_FIELD).toString(), object.get(STUDYID_FIELD).toString()); for (Map.Entry<String, Object> gtToIndexes: mongoGenotypes.entrySet()) { String gtString = gtToIndexes.getKey(); if (gtString.equals("def")) { fileWithSamples = addGenotypeToVariantSourceEntry(fileWithSamples, "def", (String) gtToIndexes.getValue()); } else { List<Integer> indexes = (List<Integer>) gtToIndexes.getValue(); for (Integer index : indexes) { fileWithSamples = addGenotypeToVariantSourceEntry(fileWithSamples, Integer.toString(index), gtString); } } } return fileWithSamples; }
Source:
public ResourceUtils(ClassLoader loader, Object contextObject, String contextMessage) { }

Target:
public ResourceUtils(ClassLoader loader, Object contextObject, String contextMessage) { this(new JavaBrooklynClassLoadingContext(null, loader), contextObject, contextMessage); }
Source:
protected CheckoutCommand checkoutPaths() throws IOException, RefNotFoundException { RevWalk revWalk = new RevWalk(repo); DirCache dc = repo.lockDirCache(); try { TreeWalk treeWalk = new TreeWalk(revWalk.getObjectReader()); treeWalk.addTree(new DirCacheIterator(dc)); treeWalk.setFilter(PathFilterGroup.createFromStrings(paths)); List<String> files = new LinkedList<String>(); while (treeWalk.next()) files.add(treeWalk.getPathString()); if (startCommit != null || startPoint != null) { DirCacheEditor editor = dc.editor(); TreeWalk startWalk = new TreeWalk(revWalk.getObjectReader()); startWalk.setFilter(treeWalk.getFilter()); startWalk.addTree(revWalk.parseCommit(getStartPoint()) .getTree()); while (startWalk.next()) { final ObjectId blobId = startWalk.getObjectId(0); editor.add(new PathEdit(startWalk.getPathString()) { public void apply(DirCacheEntry ent) { ent.setObjectId(blobId); } }); } editor.commit(); } File workTree = repo.getWorkTree(); for (String file : files) DirCacheCheckout.checkoutEntry(repo, new File(workTree, file), dc.getEntry(file)); } finally { dc.unlock(); revWalk.release(); } return this; }

Target:
protected CheckoutCommand checkoutPaths() throws IOException, RefNotFoundException { RevWalk revWalk = new RevWalk(repo); DirCache dc = repo.lockDirCache(); try { TreeWalk treeWalk = new TreeWalk(revWalk.getObjectReader()); treeWalk.addTree(new DirCacheIterator(dc)); treeWalk.setFilter(PathFilterGroup.createFromStrings(paths)); List<String> files = new LinkedList<String>(); while (treeWalk.next()) if (treeWalk.isSubtree()) treeWalk.enterSubtree(); else files.add(treeWalk.getPathString()); if (startCommit != null || startPoint != null) { DirCacheEditor editor = dc.editor(); TreeWalk startWalk = new TreeWalk(revWalk.getObjectReader()); startWalk.setFilter(treeWalk.getFilter()); startWalk.addTree(revWalk.parseCommit(getStartPoint()) .getTree()); while (startWalk.next()) if (startWalk.isSubtree()) startWalk.enterSubtree(); else { final ObjectId blobId = startWalk.getObjectId(0); editor.add(new PathEdit(startWalk.getPathString()) { public void apply(DirCacheEntry ent) { ent.setObjectId(blobId); } }); } editor.commit(); } File workTree = repo.getWorkTree(); for (String file : files) DirCacheCheckout.checkoutEntry(repo, new File(workTree, file), dc.getEntry(file)); } finally { dc.unlock(); revWalk.release(); } return this; }