auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void process(Element element, EFragmentHolder holder) throws Exception { ExecutableElement executableElement = (ExecutableElement) element; JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder); JBlock previousMethodBody = codeModelHelper.removeBody(delegatingMethod); IgnoreWhen ignoreWhen = element.getAnnotation(IgnoreWhen.class); switch (ignoreWhen.value()) { case VIEW_DESTROYED: String viewDestroyedFieldName = "viewDestroyed" + generationSuffix(); JFieldVar viewDestroyed = holder.getGeneratedClass().fields().get(viewDestroyedFieldName); if (viewDestroyed == null) { viewDestroyed = holder.getGeneratedClass().field(PRIVATE | VOLATILE, getCodeModel().BOOLEAN, viewDestroyedFieldName); holder.getSetContentViewBlock().assign(viewDestroyed, FALSE); holder.getOnDestroyViewAfterSuperBlock().assign(viewDestroyed, TRUE); } delegatingMethod.body()._if(viewDestroyed.not())._then().add(previousMethodBody); break; case DETACHED: delegatingMethod.body()._if(invoke(holder.getGeneratedClass().staticRef("this"), "getActivity").ne(_null()))._then().add(previousMethodBody); break; } }

Target:
public void process(Element element, EFragmentHolder holder) throws Exception { ExecutableElement executableElement = (ExecutableElement) element; JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder); JBlock previousMethodBody = codeModelHelper.removeBody(delegatingMethod); IgnoreWhen ignoreWhen = element.getAnnotation(IgnoreWhen.class); JBlock methodBody = delegatingMethod.body(); JConditional conditional = null; switch (ignoreWhen.value()) { case VIEW_DESTROYED: conditional = methodBody._if(holder.getViewDestroyedField().not()); break; case DETACHED: conditional = methodBody._if(invoke(holder.getGeneratedClass().staticRef("this"), "getActivity").ne(_null())); break; } conditional._then().add(previousMethodBody); }
Source:
public <T> T getConfiguration(final Class<T> clazz) { if (configuration == null) { return null; } if (!clazz.isAssignableFrom(configuration.getClass())) { throw new IllegalStateException("Can not cast configuration " + configuration + " to class " + clazz); } return (T) configuration; }

Target:
public <T> T getConfiguration(final Class<T> clazz) { if (!clazz.isAssignableFrom(configuration.getClass())) { throw new IllegalStateException("Can not cast configuration " + configuration + " to class " + clazz); } return (T) configuration; }
Source:
public List<AttestationValue> parsePostedResp(String str){ JsonFactory jfactory = new JsonFactory(); JsonParser jParser; List<AttestationValue> values = new ArrayList<AttestationValue>(); try { jParser = jfactory.createJsonParser(str); jParser.nextToken(); while (jParser.nextToken() != JsonToken.END_OBJECT){ if(jParser.getCurrentName().equalsIgnoreCase(HEADER_HOSTS)){ while(jParser.nextToken() != JsonToken.END_ARRAY && jParser.getCurrentToken() != JsonToken.END_OBJECT){ AttestationValue value = new AttestationValue(); if (jParser.getCurrentName().equalsIgnoreCase(HEADER_HOST_NAME)){ jParser.nextToken(); value.setHostName(jParser.getText()); jParser.nextToken(); } if (jParser.getCurrentName().equalsIgnoreCase(HEADER_RESULT)){ jParser.nextToken(); value.setTrustLevel(AttestationResult.valueOf(jParser.getText().toUpperCase())); jParser.nextToken(); } if(jParser.getCurrentName().equalsIgnoreCase(HEADER_VTIME)){ jParser.nextToken(); value.setVtime(DateUtils.parse(jParser.getText())); jParser.nextToken(); } if (value.getHostName() != null){ log.debug("host_name:" +value.getHostName() +", trustLevel:" +value.getTrustLevel() +",vtime:" +value.getVtime()); values.add(value); } jParser.nextToken(); } break; } } jParser.close(); } catch (JsonParseException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } return values; }

Target:
public List<AttestationValue> parsePostedResp(String str) throws JsonParseException, IOException { JsonFactory jfactory = new JsonFactory(); List<AttestationValue> values = new ArrayList<AttestationValue>(); JsonParser jParser = jfactory.createJsonParser(str); try { jParser.nextToken(); while (jParser.nextToken() != JsonToken.END_OBJECT) { if (jParser.getCurrentName().equalsIgnoreCase(HEADER_HOSTS)) { while (jParser.nextToken() != JsonToken.END_ARRAY && jParser.getCurrentToken() != JsonToken.END_OBJECT) { AttestationValue value = new AttestationValue(); if (jParser.getCurrentName().equalsIgnoreCase(HEADER_HOST_NAME)) { jParser.nextToken(); value.setHostName(jParser.getText()); jParser.nextToken(); } if (jParser.getCurrentName().equalsIgnoreCase(HEADER_RESULT)) { jParser.nextToken(); value.setTrustLevel(AttestationResultEnum.valueOf(jParser.getText().toUpperCase())); jParser.nextToken(); } if (jParser.getCurrentName().equalsIgnoreCase(HEADER_VTIME)) { jParser.nextToken(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); value.setVtime(df.parse(jParser.getText().replace("T", " "))); jParser.nextToken(); } if (value.getHostName() != null) { log.debug("host_name:" + value.getHostName() + ", trustLevel:" + value.getTrustLevel() + ",vtime:" + value.getVtime()); values.add(value); } jParser.nextToken(); } break; } } } catch (ParseException e) { log.error(String.format("Failed to set attestation time, time format is correct? [%s]", e.getMessage()), e); } finally { jParser.close(); } return values; }
Source:
public DiscussionPostsAdapter(Context context, IEdxEnvironment environment) { super(context, R.layout.row_discussion_thread, environment); edx_brand_primary_base = context.getResources().getColor(R.color.edx_brand_primary_base); edx_grayscale_neutral_dark = context.getResources().getColor(R.color.edx_brand_gray_base); edx_brand_secondary_dark = context.getResources().getColor(R.color.edx_brand_secondary_dark); edx_utility_success_dark = context.getResources().getColor(R.color.edx_success_text); openSansSemiBoldFont = ResourcesCompat.getFont(context, R.font.inter_semi_bold); }

Target:
public DiscussionPostsAdapter(Context context, IEdxEnvironment environment) { super(context, R.layout.row_discussion_thread, environment); edx_brand_primary_base = context.getResources().getColor(R.color.edx_brand_primary_base); edx_grayscale_neutral_dark = context.getResources().getColor(R.color.edx_brand_gray_base); edx_brand_secondary_dark = context.getResources().getColor(R.color.edx_brand_secondary_dark); edx_utility_success_dark = context.getResources().getColor(R.color.edx_success_text); semiBoldFont = ResourcesCompat.getFont(context, R.font.inter_semi_bold); }
Source:
private void configureNetworksOnHosts(Map<Guid, List<Network>> networksByHost, Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost) { ArrayList<VdcActionParametersBase> parameters = new ArrayList<>(); for (Guid hostId : networksByHost.keySet()) { AddNetworksByLabelParametersBuilder builder = new AddNetworksByLabelParametersBuilder(); builder.buildParameters(hostId, networksByHost.get(hostId), labelsToNicsByHost.get(hostId)); } getBackend().runInternalMultipleActions(VdcActionType.PersistentSetupNetworks, parameters); }

Target:
private void configureNetworksOnHosts(Map<Guid, List<Network>> networksByHost, Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost) { ArrayList<VdcActionParametersBase> parameters = new ArrayList<>(); for (Guid hostId : networksByHost.keySet()) { AddNetworksByLabelParametersBuilder builder = new AddNetworksByLabelParametersBuilder(); parameters.add(builder.buildParameters(hostId, networksByHost.get(hostId), labelsToNicsByHost.get(hostId))); } getBackend().runInternalMultipleActions(VdcActionType.PersistentSetupNetworks, parameters); }
Source:
public static int findContainerQuarkWithInode(ITmfStateSystemBuilder ssb, int containerINode) { int rootQuark = getRootContainerQuark(ssb); int parentContainerQuark = fCONTAINER_QUARK_NOT_FOUND; try { List<Integer> ContainerINodeList = ssb.getSubAttributes(rootQuark, true, ContainerAttributes.CONTAINER_INODE); if (ContainerINodeList.size() >= 1) { for (Integer quarkContainerINode : ContainerINodeList) { int iNode = ssb.queryOngoingState(quarkContainerINode).unboxInt(); if (iNode == containerINode) { int containerInfoQuark = ssb.getParentAttributeQuark(quarkContainerINode); parentContainerQuark = ssb.getParentAttributeQuark(containerInfoQuark); break; } } } } catch (AttributeNotFoundException e) { e.printStackTrace(); } return parentContainerQuark; }

Target:
public static int findContainerQuarkWithInode(ITmfStateSystemBuilder ssb, int containerINode) { int rootQuark = getRootContainerQuark(ssb); int parentContainerQuark = CONTAINER_QUARK_NOT_FOUND; try { List<Integer> containerINodeList = ssb.getSubAttributes(rootQuark, true, ContainerAttributes.CONTAINER_INODE); if (!containerINodeList.isEmpty()) { for (Integer quarkContainerINode : containerINodeList) { int iNode = ssb.queryOngoingState(quarkContainerINode).unboxInt(); if (iNode == containerINode) { int containerInfoQuark = ssb.getParentAttributeQuark(quarkContainerINode); parentContainerQuark = ssb.getParentAttributeQuark(containerInfoQuark); break; } } } } catch (AttributeNotFoundException e) { throw new IllegalStateException(); } return parentContainerQuark; }
Source:
private void initListView(@NonNull View view) { initAdapter(); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (deleteMode != null) { deleteMode.finish(); } listView.clearChoices(); final CourseComponent component = adapter.getItem(position).component; if (component.isContainer()) { environment.getRouter().showCourseContainerOutline(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, component.getId(), null, isVideoMode); } else { environment.getRouter().showCourseUnitDetail(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, component.getId(), isVideoMode); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { IconImageView bulkDownload = (IconImageView) view.findViewById(R.id.bulk_download); if (bulkDownload != null && bulkDownload.getIcon() == FontAwesomeIcons.fa_check) { ((AppCompatActivity) getActivity()).startSupportActionMode(deleteModelCallback); listView.setItemChecked(position, true); return true; } return false; } }); }

Target:
private void initListView(@NonNull View view) { initAdapter(); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (deleteMode != null) { deleteMode.finish(); } listView.clearChoices(); final CourseComponent component = adapter.getItem(position).component; if (component.isContainer()) { environment.getRouter().showCourseContainerOutline(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, component.getId(), null, isVideoMode); } else { environment.getRouter().showCourseUnitDetail(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, component.getId(), isVideoMode); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final IconImageView bulkDownloadIcon = (IconImageView) view.findViewById(R.id.bulk_download); if (bulkDownloadIcon != null && bulkDownloadIcon.getIcon() == FontAwesomeIcons.fa_check) { ((AppCompatActivity) getActivity()).startSupportActionMode(deleteModelCallback); listView.setItemChecked(position, true); return true; } return false; } }); }
Source:
public void testExecuteOn() throws Exception { when(config.hasToNotifyStash()).thenReturn(true); SonarQubeIssuesReport report = mock(SonarQubeIssuesReport.class); when(report.countIssues()).thenReturn(10); when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report); int issueThreshold = 100; when(stashRequestFacade.getIssueThreshold()).thenReturn(issueThreshold); StashIssueReportingPostJob job = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade); job.executeOn(project, context); verify(stashRequestFacade, times(1)).postCommentPerIssue(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(report), (StashClient) Mockito.anyObject()); verify(stashRequestFacade, times(1)).postAnalysisOverview(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(issueThreshold), eq(report), (StashClient) Mockito.anyObject()); }

Target:
public void testExecuteOn() throws Exception { when(config.hasToNotifyStash()).thenReturn(true); SonarQubeIssuesReport report = mock(SonarQubeIssuesReport.class); when(report.countIssues()).thenReturn(10); when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report); int issueThreshold = 100; when(stashRequestFacade.getIssueThreshold()).thenReturn(issueThreshold); myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade); myJob.executeOn(project, context); verify(stashRequestFacade, times(1)).postCommentPerIssue(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(report), (StashClient) Mockito.anyObject()); verify(stashRequestFacade, times(1)).postAnalysisOverview(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(issueThreshold), eq(report), (StashClient) Mockito.anyObject()); }
Source:
protected void ProceedProxyReturnValue() { VdcBllErrors returnStatus = GetReturnValueFromStatus(getReturnStatus()); if (returnStatus != VdcBllErrors.Done) { getVDSReturnValue().setSucceeded(false); InitializeVdsError(returnStatus); } }

Target:
protected void ProceedProxyReturnValue() { VdcBllErrors returnStatus = GetReturnValueFromStatus(getReturnStatus()); switch (returnStatus) { case Done: return; default: VDSExceptionBase outEx = createDefaultConcreteException(getReturnStatus().mMessage); InitializeVdsError(returnStatus); outEx.setVdsError(getVDSReturnValue().getVdsError()); throw outEx; } }
Source:
public FileWriter getOrCreateWriter(LogFilePath path, CompressionCodec codec) throws Exception { FileWriter writer = mWriters.get(path); if (writer == null) { FileUtil.delete(path.getLogFilePath()); FileUtil.delete(path.getLogFileCrcPath()); TopicPartition topicPartition = new TopicPartition(path.getTopic(), path.getKafkaPartition()); HashSet<LogFilePath> files = mFiles.get(topicPartition); if (files == null) { files = new HashSet<LogFilePath>(); mFiles.put(topicPartition, files); } if (!files.contains(path)) { files.add(path); } writer = ReflectionUtil.createFileWriter(mConfig.getFileReaderWriterFactory(), path, codec); mWriters.put(path, writer); mCreationTimes.put(path, System.currentTimeMillis() / 1000L); LOG.debug("created writer for path {}", path.getLogFilePath()); LOG.debug("Register deleteOnExit for path {}", path.getLogFilePath()); FileUtil.deleteOnExit(path.getLogFilePath()); FileUtil.deleteOnExit(path.getLogFileCrcPath()); } return writer; }

Target:
public FileWriter getOrCreateWriter(LogFilePath path, CompressionCodec codec) throws Exception { FileWriter writer = mWriters.get(path); if (writer == null) { FileUtil.delete(path.getLogFilePath()); FileUtil.delete(path.getLogFileCrcPath()); TopicPartition topicPartition = new TopicPartition(path.getTopic(), path.getKafkaPartition()); HashSet<LogFilePath> files = mFiles.get(topicPartition); if (files == null) { files = new HashSet<LogFilePath>(); mFiles.put(topicPartition, files); } if (!files.contains(path)) { files.add(path); } writer = ReflectionUtil.createFileWriter(mConfig.getFileReaderWriterFactory(), path, codec); mWriters.put(path, writer); mCreationTimes.put(path, System.currentTimeMillis() / 1000L); LOG.debug("created writer for path {}", path.getLogFilePath()); LOG.debug("Register deleteOnExit for path {}", path.getLogFilePath()); FileUtil.deleteOnExit(path.getLogFileParentDir()); FileUtil.deleteOnExit(path.getLogFileDir()); FileUtil.deleteOnExit(path.getLogFilePath()); FileUtil.deleteOnExit(path.getLogFileCrcPath()); } return writer; }
Source:
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("Usage: WebServer <[hostname:]port> <yaml configuration file>"); System.exit(1); } String[] hostnamePort = args[0].split(":"); int port; if (hostnamePort.length == 2) { port = Integer.parseInt(hostnamePort[1]); } else { port = Integer.parseInt(hostnamePort[0]); } JmxCollector jc = new JmxCollector(new File(args[1])).register(); HTTPServer server = new HTTPServer(port); }

Target:
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("Usage: WebServer <[hostname:]port> <yaml configuration file>"); System.exit(1); } String[] hostnamePort = args[0].split(":"); int port; InetSocketAddress socket; if (hostnamePort.length == 2) { port = Integer.parseInt(hostnamePort[1]); socket = new InetSocketAddress(hostnamePort[0], port); } else { port = Integer.parseInt(hostnamePort[0]); socket = new InetSocketAddress(port); } new JmxCollector(new File(args[1])).register(); new HTTPServer(socket, CollectorRegistry.defaultRegistry); }
Source:
public void test_simple_version_with_refresh() throws Exception { execute("create table test (id integer primary key, value string)"); ensureGreen(); execute("insert into test (id, value) values (?, ?) returning _seq_no", new Object[]{1, "value1_1"}); long seqNo = (long) response.rows()[0][0]; assertThat(seqNo, equalTo(0L)); execute("refresh table test"); execute("update test set value = 'value1_2' where id = 1 returning _seq_no, _primary_term"); seqNo = (long) response.rows()[0][0]; assertThat(seqNo, equalTo(1L)); execute("update test set value = 'value1_1' where id = 1 and _seq_no = 0 and _primary_term = 1 returning _seq_no, _primary_term"); assertThat(response.rowCount(), equalTo(0L)); execute("delete from test where id = 1 and _seq_no = 0 and _primary_term = 1"); assertThat(response.rowCount(), equalTo(0L)); execute("select _version from test where id=1"); assertThat(response.rows()[0][0], equalTo(2L)); execute("refresh table test"); execute("select _version, _seq_no from test"); assertThat(response.rows()[0][0], equalTo(2L)); assertThat(response.rows()[0][1], equalTo(1L)); }

Target:
public void test_simple_version_with_refresh() throws Exception { execute("create table test (id integer primary key, value string)"); ensureGreen(); execute("insert into test (id, value) values (?, ?) returning _seq_no", new Object[]{1, "value1_1"}); long seqNo = (long) response.rows()[0][0]; assertThat(seqNo, equalTo(0L)); execute("refresh table test"); execute("update test set value = 'value1_2' where id = 1 returning _seq_no, _primary_term"); seqNo = (long) response.rows()[0][0]; assertThat(seqNo, equalTo(1L)); execute("refresh table test"); execute("update test set value = 'value1_1' where id = 1 and _seq_no = 0 and _primary_term = 1 returning _seq_no, _primary_term"); assertThat(response.rowCount(), equalTo(0L)); execute("refresh table test"); execute("delete from test where id = 1 and _seq_no = 0 and _primary_term = 1"); assertThat(response.rowCount(), equalTo(0L)); for (int i = 0; i < 10; i++) { execute("select _version from test where id=1"); assertThat(response.rows()[0][0], equalTo(2L)); } execute("refresh table test"); for (int i = 0; i < 10; i++) { execute("select _version, _seq_no from test"); assertThat(response.rowCount(), equalTo(1L)); assertThat(response.rows()[0][0], equalTo(2L)); assertThat(response.rows()[0][1], equalTo(1L)); } }
Source:
public BlobProperties(long blobSize, String serviceId, String ownerId, String contentType, boolean isPrivate, long timeToLiveInSeconds, long creationTimeInMs) { this.blobSize = blobSize; this.serviceId = serviceId; this.ownerId = ownerId; this.contentType = contentType; this.isPrivate = isPrivate; this.creationTimeInMs = creationTimeInMs; long maxAllowedTTLInMs = Utils.getMaxSupportedTimeInMs() - creationTimeInMs; if (TimeUnit.SECONDS.toMillis(timeToLiveInSeconds) > maxAllowedTTLInMs) { this.timeToLiveInSeconds = -1; } else { this.timeToLiveInSeconds = timeToLiveInSeconds; } }

Target:
public BlobProperties(long blobSize, String serviceId, String ownerId, String contentType, boolean isPrivate, long timeToLiveInSeconds, long creationTimeInMs) { this.blobSize = blobSize; this.serviceId = serviceId; this.ownerId = ownerId; this.contentType = contentType; this.isPrivate = isPrivate; this.creationTimeInMs = creationTimeInMs; if (timeToLiveInSeconds + TimeUnit.MILLISECONDS.toSeconds(creationTimeInMs) > Integer.MAX_VALUE) { this.timeToLiveInSeconds = Utils.Infinite_Time; } else { this.timeToLiveInSeconds = timeToLiveInSeconds; } }
Source:
public DynamicConfigurationProvider(String name, ExtensionModel extension, ConfigurationModel config, ResolverSet resolverSet, ConnectionProviderValueResolver connectionProviderResolver, ExpirationPolicy expirationPolicy, ReflectionCache reflectionCache, ExpressionManager expressionManager, MuleContext muleContext) { super(name, extension, config, muleContext); this.configurationInstanceFactory = new ConfigurationInstanceFactory<>(extension, config, resolverSet, reflectionCache, expressionManager, muleContext); this.reflectionCache = reflectionCache; this.expressionManager = expressionManager; this.resolverSet = resolverSet; this.connectionProviderResolver = connectionProviderResolver; this.expirationPolicy = expirationPolicy; cache = Caffeine.newBuilder().expireAfterWrite(expirationPolicy.getMaxIdleTime(), expirationPolicy.getTimeUnit()).build(); }

Target:
public DynamicConfigurationProvider(String name, ExtensionModel extension, ConfigurationModel config, ResolverSet resolverSet, ConnectionProviderValueResolver connectionProviderResolver, ExpirationPolicy expirationPolicy, ReflectionCache reflectionCache, ExpressionManager expressionManager, MuleContext muleContext) { super(name, extension, config, muleContext); this.configurationInstanceFactory = new ConfigurationInstanceFactory<>(extension, config, resolverSet, reflectionCache, expressionManager, muleContext); this.reflectionCache = reflectionCache; this.expressionManager = expressionManager; this.resolverSet = resolverSet; this.connectionProviderResolver = connectionProviderResolver; this.expirationPolicy = expirationPolicy; this.extensionManager = (DefaultExtensionManager) muleContext.getExtensionManager(); cache = Caffeine.newBuilder().expireAfterAccess(expirationPolicy.getMaxIdleTime(), expirationPolicy.getTimeUnit()) .removalListener((key, value, cause) -> extensionManager .disposeConfiguration(((ResolverResultAndEvent) key).getResolverSetResult().toString(), (ConfigurationInstance) value)) .build(key -> createConfiguration(key.getResolverSetResult(), key.getEvent())); }
Source:
private void hookFillMenu(Menu menu) { ScenarioParser parser = new ScenarioParser(); Bundle bundle = Platform.getBundle(Constants.BUNDLE_ID); File stateLocation = Platform.getStateLocation(bundle).toFile(); hookDirectoryScenarios(menu, parser, stateLocation); new MenuItem(menu, SWT.SEPARATOR); MenuItem menuItemCategory = new MenuItem(menu, SWT.CASCADE); menuItemCategory.setText("Open scenarios directory\u2026"); menuItemCategory.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch(stateLocation.getAbsolutePath()); } }); new MenuItem(menu, SWT.SEPARATOR); hookPredefinedScenarios(menu); }

Target:
private void hookFillMenu(Menu menu) { ScenarioParser parser = new ScenarioParser(); Bundle bundle = FrameworkUtil.getBundle(getClass()); File stateLocation = Platform.getStateLocation(bundle).toFile(); hookDirectoryScenarios(menu, parser, stateLocation); new MenuItem(menu, SWT.SEPARATOR); MenuItem menuItemCategory = new MenuItem(menu, SWT.CASCADE); menuItemCategory.setText("Open scenarios directory\u2026"); menuItemCategory.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch(stateLocation.getAbsolutePath()); } }); new MenuItem(menu, SWT.SEPARATOR); hookPredefinedScenarios(menu); }
Source:
static WorkloadClockConfiguration generateLoad(JLoadProfile jLoadProfile) { WorkloadClockConfiguration clockConfiguration = null; if (jLoadProfile instanceof JLoadProfileRps) { clockConfiguration = new RpsClockConfiguration(); ((RpsClockConfiguration) clockConfiguration).setValue(((JLoadProfileRps) jLoadProfile).getRequestsPerSecond()); ((RpsClockConfiguration) clockConfiguration).setWarmUpTime(((JLoadProfileRps) jLoadProfile).getWarmUpTimeInSeconds()); ((RpsClockConfiguration) clockConfiguration).setMaxThreadNumber((int) ((JLoadProfileRps) jLoadProfile).getMaxLoadThreads()); } else if (jLoadProfile instanceof JLoadProfileUserGroups) { clockConfiguration = new UserGroupsClockConfiguration(); List<User> users = ((JLoadProfileUserGroups) jLoadProfile).getUserGroups().stream() .map(jLoadUser -> new User(String.valueOf(jLoadUser.getNumberOfUsers()), String.valueOf(jLoadUser.getSlewRateUsersPerSecond()), jLoadUser.getStartDelayInSeconds() + "s", "1s", jLoadUser.getLifeTimeInSeconds() + "s")) .collect(toList()); ((UserGroupsClockConfiguration) clockConfiguration).setUsers(users); FixedDelay delay = new FixedDelay(((JLoadProfileUserGroups) jLoadProfile).getDelayBetweenInvocationsInSeconds()); ((UserGroupsClockConfiguration) clockConfiguration).setDelay(delay); int tickInterval = ((JLoadProfileUserGroups) jLoadProfile).getTickInterval(); ((UserGroupsClockConfiguration) clockConfiguration).setTickInterval(tickInterval); } return clockConfiguration; }

Target:
static WorkloadClockConfiguration generateLoad(JLoadProfile jLoadProfile) { WorkloadClockConfiguration clockConfiguration = null; if (jLoadProfile instanceof JLoadProfileRps) { clockConfiguration = new RpsClockConfiguration(); ((RpsClockConfiguration) clockConfiguration).setValue(((JLoadProfileRps) jLoadProfile).getRequestsPerSecond()); ((RpsClockConfiguration) clockConfiguration).setWarmUpTime(((JLoadProfileRps) jLoadProfile).getWarmUpTimeInSeconds()); ((RpsClockConfiguration) clockConfiguration).setMaxThreadNumber((int) ((JLoadProfileRps) jLoadProfile).getMaxLoadThreads()); } else if (jLoadProfile instanceof JLoadProfileUserGroups) { JLoadProfileUserGroups profileUserGroups = (JLoadProfileUserGroups) jLoadProfile; List<User> users = profileUserGroups.getUserGroups().stream() .map(userGroup -> new User(String.valueOf(userGroup.getNumberOfUsers()), String.valueOf(userGroup.getSlewRateUsersPerSecond()), userGroup.getStartDelayInSeconds() + "s", "1s", userGroup.getLifeTimeInSeconds() + "s")) .collect(toList()); UserGroupsClockConfiguration userGroupsClockConfiguration = new UserGroupsClockConfiguration(); userGroupsClockConfiguration.setUsers(users); userGroupsClockConfiguration.setDelay(new FixedDelay(profileUserGroups.getDelayBetweenInvocationsInSeconds())); userGroupsClockConfiguration.setTickInterval(profileUserGroups.getTickInterval()); clockConfiguration = userGroupsClockConfiguration; } return clockConfiguration; }
Source:
public ForemanHostProviderProxy(Provider hostProvider) { this.hostProvider = hostProvider; try { URL hostUrl = new URL(hostProvider.getUrl()); if (hostUrl.getProtocol().equalsIgnoreCase(HTTPS_PROTOCOL)) { String trustStorePath = FILE_URL_PREFIX + EngineLocalConfig.getInstance().getPKIExternalTrustStore(); String trustStorePassword = EngineLocalConfig.getInstance().getPKIExternalTrustStorePassword(); httpClient = new SecuredHostHttpClient(hostUrl, new URL(trustStorePath), trustStorePassword, false); } else { httpClient = new HttpClient(); } objectMapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); Credentials hostProviderCredentials = new UsernamePasswordCredentials(hostProvider.getUsername(), hostProvider.getPassword()); httpClient.getState().setCredentials(AuthScope.ANY, hostProviderCredentials); httpClient.getState().setAuthenticationPreemptive(true); } catch (MalformedURLException e) { throw new VdcBLLException(VdcBllErrors.PROVIDER_FAILURE, e.getMessage()); } }

Target:
public ForemanHostProviderProxy(Provider hostProvider) { this.hostProvider = hostProvider; initHttpClient(hostProvider.getUrl()); }
Source:
public Construct exec(Target t, com.laytonsmith.core.environments.Environment environment, Construct... args ) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); if(loc.getBlock().isCommandBlock()) { MCCommandBlock cb = loc.getBlock().getCommandBlock(); String name = ""; if(args.length == 2) { if(!(args[1] instanceof CString)) { throw new ConfigRuntimeException("Parameter 2 of " + getName() + " must be a string", ExceptionType.CastException, t); } name = args[1].val(); } cb.setName(name); return new CVoid(t); } else { throw new ConfigRuntimeException("The block at the specified location is not a command block", ExceptionType.FormatException, t); } }

Target:
public Construct exec(Target t, com.laytonsmith.core.environments.Environment environment, Construct... args ) throws ConfigRuntimeException { String name = null; if(args.length == 2 && !(args[1] instanceof CNull)) { if(!(args[1] instanceof CString)) { throw new ConfigRuntimeException("Parameter 2 of " + getName() + " must be a string or null", ExceptionType.CastException, t); } name = args[1].val(); } MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); if(loc.getBlock().isCommandBlock()) { MCCommandBlock cb = loc.getBlock().getCommandBlock(); cb.setName(name); return new CVoid(t); } else { throw new ConfigRuntimeException("The block at the specified location is not a command block", ExceptionType.FormatException, t); } }
Source:
public IStatus openTraceFromPath(String projectRoot, String path, Shell shell, String tracetypeHint) throws CoreException { TmfTraceType tt = TmfTraceType.getInstance(); TraceTypeHelper traceTypeToSet = null; try { traceTypeToSet = TmfTraceTypeUIUtils.selectTraceType(tt, path, shell, tracetypeHint); } catch (TmfTraceImportException e) { MessageBox mb = new MessageBox(shell); mb.setMessage(e.getMessage()); mb.open(); return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()); } if (traceTypeToSet == null) { return Status.CANCEL_STATUS; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectRoot); IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); String traceName = getTraceName(path, folder); if (traceExists(path, folder)) { return openTraceFromProject(projectRoot, traceName); } final IPath tracePath = folder.getFullPath().append(traceName); final IPath pathString = Path.fromOSString(path); IResource linkedTrace = TmfImportHelper.createLink(folder, pathString, traceName); if (linkedTrace != null && linkedTrace.exists()) { IStatus ret = TmfTraceTypeUIUtils.setTraceType(tracePath, traceTypeToSet); if (ret.isOK()) { ret = openTraceFromProject(projectRoot, traceName); } return ret; } return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TmfOpenTraceHelper_LinkFailed); }

Target:
public IStatus openTraceFromPath(String projectRoot, String path, Shell shell, String tracetypeHint) throws CoreException { TraceTypeHelper traceTypeToSet = null; try { traceTypeToSet = TmfTraceTypeUIUtils.selectTraceType(path, shell, tracetypeHint); } catch (TmfTraceImportException e) { MessageBox mb = new MessageBox(shell); mb.setMessage(e.getMessage()); mb.open(); return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()); } if (traceTypeToSet == null) { return Status.CANCEL_STATUS; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectRoot); IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); String traceName = getTraceName(path, folder); if (traceExists(path, folder)) { return openTraceFromProject(projectRoot, traceName); } final IPath tracePath = folder.getFullPath().append(traceName); final IPath pathString = Path.fromOSString(path); IResource linkedTrace = TmfImportHelper.createLink(folder, pathString, traceName); if (linkedTrace != null && linkedTrace.exists()) { IStatus ret = TmfTraceTypeUIUtils.setTraceType(tracePath, traceTypeToSet); if (ret.isOK()) { ret = openTraceFromProject(projectRoot, traceName); } return ret; } return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TmfOpenTraceHelper_LinkFailed); }
Source:
public static long getTtlInSecsFromExpiryMs(long expiresAtMs, long creationTimeMs) { if (expiresAtMs == Utils.Infinite_Time) { return Utils.Infinite_Time; } return Math.max(0, TimeUnit.MILLISECONDS.toSeconds(expiresAtMs - creationTimeMs)); }

Target:
public static long getTtlInSecsFromExpiryMs(long expiresAtMs, long creationTimeMs) { return expiresAtMs == Utils.Infinite_Time ? Utils.Infinite_Time : Math.max(0, TimeUnit.MILLISECONDS.toSeconds(expiresAtMs - creationTimeMs)); }
Source:
public void setPost(@NonNull ReaderPost post) { mPost = post; TextView txtBlogName = (TextView) findViewById(R.id.text_header_blog_name); TextView txtAuthorName = (TextView) findViewById(R.id.text_header_author_name); boolean hasBlogName = mPost.hasBlogName(); boolean hasAuthorName = mPost.hasAuthorName(); if (hasBlogName && hasAuthorName) { txtBlogName.setText(mPost.getBlogName()); if (mPost.getAuthorName().equals(mPost.getBlogName())) { txtAuthorName.setVisibility(View.GONE); } else { txtAuthorName.setText(mPost.getAuthorName()); txtAuthorName.setVisibility(View.VISIBLE); } } else if (hasBlogName) { txtBlogName.setText(mPost.getBlogName()); txtAuthorName.setVisibility(View.GONE); } else if (hasAuthorName) { txtAuthorName.setText(mPost.getAuthorName()); txtBlogName.setVisibility(View.GONE); } else { txtBlogName.setText(R.string.untitled); txtAuthorName.setVisibility(View.GONE); } txtBlogName.setOnClickListener(mClickListener); txtAuthorName.setOnClickListener(mClickListener); if (ReaderUtils.isLoggedOutReader()) { mFollowButton.setVisibility(View.GONE); } else { mFollowButton.setVisibility(View.VISIBLE); mFollowButton.setIsFollowed(mPost.isFollowedByCurrentUser); mFollowButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleFollowStatus(); } }); } ReaderBlog blogInfo = mPost.isExternal ? ReaderBlogTable.getFeedInfo(mPost.feedId) : ReaderBlogTable.getBlogInfo(mPost.blogId); if (blogInfo != null) { showBlogInfo(blogInfo); } if (blogInfo == null || ReaderBlogTable.isTimeToUpdateBlogInfo(blogInfo)) { updateBlogInfo(); } }

Target:
public void setPost(@NonNull ReaderPost post) { mPost = post; TextView txtTitle = (TextView) findViewById(R.id.text_header_title); TextView txtSubtitle = (TextView) findViewById(R.id.text_header_subtitle); boolean hasBlogName = mPost.hasBlogName(); boolean hasAuthorName = mPost.hasAuthorName(); if (hasBlogName && hasAuthorName) { if (mPost.getAuthorName().equals(mPost.getBlogName())) { txtTitle.setText(mPost.getAuthorName()); txtSubtitle.setVisibility(View.GONE); } else { txtTitle.setText(mPost.getAuthorName()); txtSubtitle.setText(mPost.getBlogName()); } } else if (hasBlogName) { txtTitle.setText(mPost.getBlogName()); txtSubtitle.setVisibility(View.GONE); } else if (hasAuthorName) { txtTitle.setText(mPost.getAuthorName()); txtSubtitle.setVisibility(View.GONE); } else { txtTitle.setText(R.string.untitled); txtSubtitle.setVisibility(View.GONE); } txtTitle.setOnClickListener(mClickListener); txtSubtitle.setOnClickListener(mClickListener); if (ReaderUtils.isLoggedOutReader()) { mFollowButton.setVisibility(View.GONE); } else { mFollowButton.setVisibility(View.VISIBLE); mFollowButton.setIsFollowed(mPost.isFollowedByCurrentUser); mFollowButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleFollowStatus(); } }); } ReaderBlog blogInfo = mPost.isExternal ? ReaderBlogTable.getFeedInfo(mPost.feedId) : ReaderBlogTable.getBlogInfo(mPost.blogId); if (blogInfo != null) { showBlogInfo(blogInfo); } if (blogInfo == null || ReaderBlogTable.isTimeToUpdateBlogInfo(blogInfo)) { updateBlogInfo(); } }
Source:
private void handleBulkWriteError(List<BulkWriteError> errors, List<DocCtx> docs) { docUpdateActual.addAll(docs); for (BulkWriteError e : errors) { DocCtx doc = docs.get(e.getIndex()); if (e.getCode() == 11000 || e.getCode() == 11001) { doc.addError(Error.get("update", MongoCrudConstants.ERR_DUPLICATE, e.getMessage())); } else { doc.addError(Error.get("update", MongoCrudConstants.ERR_SAVE_ERROR, e.getMessage())); } } numFailed += (int) errors.stream().map(e -> e.getIndex()).distinct().count(); }

Target:
private void handleBulkWriteError(List<BulkWriteError> errors, List<DocCtx> docs) { for (BulkWriteError e : errors) { DocCtx doc = docs.get(e.getIndex()); if (e.getCode() == 11000 || e.getCode() == 11001) { doc.addError(Error.get("update", MongoCrudConstants.ERR_DUPLICATE, e.getMessage())); } else { doc.addError(Error.get("update", MongoCrudConstants.ERR_SAVE_ERROR, e.getMessage())); } } }
Source:
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Announcement announcement = null; mType = ORIGINAL; ObjectMapper mapper = new ObjectMapper(); try { announcement = mapper.readValue(getIntent().getStringExtra("Announcement"), Announcement.class); FragUtils.replace(R.id.container, AnnouncementFragment.newInstance(announcement), this); } catch (IOException exception) { String error = "Announcement"; Toast.makeText(this, getString(R.string.cannot_be_displayed, error), Toast.LENGTH_SHORT).show(); onBackPressed(); } }

Target:
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Announcement announcement = null; ObjectMapper mapper = new ObjectMapper(); try { announcement = mapper.readValue(getIntent().getStringExtra("Announcement"), Announcement.class); FragUtils.replace(R.id.container, AnnouncementFragment.newInstance(announcement), this); } catch (IOException exception) { String error = "Announcement"; Toast.makeText(this, getString(R.string.cannot_be_displayed, error), Toast.LENGTH_SHORT).show(); onBackPressed(); } }
Source:
protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) { ISelection selection = getSite().getSelectionProvider().getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection sSel = (StructuredSelection) selection; if (sSel.getFirstElement() instanceof ControlFlowEntry) { ControlFlowEntry entry = (ControlFlowEntry) sSel.getFirstElement(); if (fShowFollowThreadAction) { menuManager.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), entry.getThreadId(), entry.getTrace())); } } } }

Target:
protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) { ISelection selection = getSite().getSelectionProvider().getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection sSel = (StructuredSelection) selection; if (sSel.getFirstElement() instanceof ControlFlowEntry) { ControlFlowEntry entry = (ControlFlowEntry) sSel.getFirstElement(); menuManager.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), entry.getThreadId(), entry.getTrace())); } } }
Source:
public VALUE get(KEY key) throws IOException { if (cache != null) { CacheValue<VALUE> cacheValue = cache.get(new CacheKey<>(key)); if (cacheValue == null) { return getFromTable(key); } else { if (cacheValue.getLastOperation() != CacheValue.OperationType.DELETED) { return cacheValue.getValue(); } else { return null; } } } else { return getFromTable(key); } }

Target:
public VALUE get(KEY key) throws IOException { CacheValue< VALUE > cacheValue = cache.get(new CacheKey<>(key)); if (cacheValue == null) { return getFromTable(key); } else { return cacheValue.getValue(); } }
Source:
public ServletInputStream getInputStream() throws IOException { if (stream == null) { stream = createInputStream(); } return (stream); }

Target:
public ServletInputStream getInputStream() throws IOException { return stream; }
Source:
public void verify(Text text, final EStructuralFeature feature) { final VerifyListener verifyListener = new VerifyListener() { @Override public void verifyText(VerifyEvent e) { final String currentText = Text.class.cast(e.widget).getText(); final String changedText = currentText.substring(0, e.start) + e.text + currentText.substring(e.end); final Diagnostic diag = preSetValidationService.validate(feature, changedText); if (diag.getSeverity() == Diagnostic.OK) { return; } e.doit = false; } }; if (preSetValidationService != null) { text.addVerifyListener(verifyListener); } }

Target:
public void verify(Text text, final EStructuralFeature feature) { if (preSetValidationService != null) { final VerifyListener verifyListener = new VerifyListener() { @Override public void verifyText(VerifyEvent e) { final String currentText = Text.class.cast(e.widget).getText(); final String changedText = currentText.substring(0, e.start) + e.text + currentText.substring(e.end); final Diagnostic diag = preSetValidationService.validate(feature, changedText); if (diag.getSeverity() == Diagnostic.OK) { return; } e.doit = false; } }; text.addVerifyListener(verifyListener); } }
Source:
private int getIndexForKey(String key) { int index = 0; for (DataSnapshot snapshot : mSnapshots) { if (snapshot.getKey().equals(key)) { return index; } index++; } throw new IllegalArgumentException("Key not found"); }

Target:
private int getIndexForKey(String key) { int index = 0; for (DataSnapshot snapshot : mSnapshots) { if (snapshot.getKey().equals(key)) { return index; } else { index++; } } throw new IllegalArgumentException("Key not found"); }
Source:
private void reloadUrl(String url, @Nullable String pdfFilePath) { mIsPdf = false; if (mPdfAndroidJavascriptBridge != null) { mPdfAndroidJavascriptBridge.cleanUp(); mWebView.removeJavascriptInterface("PdfAndroidJavascriptBridge"); } if (pdfFilePath != null && isPdfRenderingSupported() && TextUtils.equals(PDF_LOADER_URL, url)) { mProgressBar.setProgress(80); mIsPdf = true; mPdfAndroidJavascriptBridge = new PdfAndroidJavascriptBridge(pdfFilePath, new PdfAndroidJavascriptBridge.Callbacks() { @Override public void onFailure() { offerExternalApp(); } @Override public void onLoad() { mProgressBar.setProgress(100); mProgressBar.setVisibility(GONE); } }); mWebView.addJavascriptInterface(mPdfAndroidJavascriptBridge, "PdfAndroidJavascriptBridge"); mWebView.setInitialScale(1); } mWebView.reloadUrl(url); }

Target:
private void reloadUrl(String url, @Nullable String pdfFilePath) { mIsPdf = false; if (mPdfAndroidJavascriptBridge != null) { mPdfAndroidJavascriptBridge.cleanUp(); mWebView.removeJavascriptInterface("PdfAndroidJavascriptBridge"); } if (pdfFilePath != null && isPdfRenderingSupported() && TextUtils.equals(PDF_LOADER_URL, url)) { setProgress(80); mIsPdf = true; mPdfAndroidJavascriptBridge = new PdfAndroidJavascriptBridge(pdfFilePath, new PdfAndroidJavascriptBridge.Callbacks() { @Override public void onFailure() { offerExternalApp(); setProgress(100); } @Override public void onLoad() { setProgress(100); } }); mWebView.addJavascriptInterface(mPdfAndroidJavascriptBridge, "PdfAndroidJavascriptBridge"); mWebView.setInitialScale(1); } mWebView.reloadUrl(url); }
Source:
public void addRepresentation (String fileName, int zoom) { if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); int imageSelectorIndex = DPIUtil.mapZoomToImageSelectorIndex(zoom); if (imageSelectorIndex == device.getImageSelector ()) { initNative (fileName); } dpiFilename [imageSelectorIndex] = fileName; addRepresentation (new ImageData(fileName), zoom); }

Target:
public void addRepresentation (String fileName, int zoom) { if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); int imageSelectorIndex = DPIUtil.mapZoomToImageSelectorIndex(zoom); if (imageSelectorIndex == getImageSelector ()) { initNative (fileName); } imageRepFileNames [imageSelectorIndex] = fileName; addRepresentation (new ImageData(fileName), zoom); }
Source:
public void add(int index, T element) { if (comparingSet.add(element)) { try { super.add(index, element); } catch (IndexOutOfBoundsException ioobException) { comparingSet.remove(element); throw new IndexOutOfBoundsException(); } } }

Target:
public void add(int index, T element) { if (comparingSet.add(element)) { try { super.add(index, element); } catch (IndexOutOfBoundsException ioobException) { comparingSet.remove(element); throw ioobException; } } }
Source:
public void add(EntityType entity) { validateAddAllowed(entity); createAcl(entity); super.add(entity); }

Target:
public void add(EntityType entity) { createAcl(entity); super.add(entity); }
Source:
private boolean contains(CodeSource codeSource) { if (codeSource == null) return false; URL url = codeSource.getLocation(); if (url == null) return false; for (URL url1 : urls) { if (url1 == url) { return true; } } return false; }

Target:
private boolean contains(CodeSource codeSource) { if (codeSource == null) return false; URL location = codeSource.getLocation(); if (location == null) return false; for (URL url : urls) { if (url == location) { return true; } } return false; }
Source:
public void run() { Column column = _project.columnModel.getColumnByName(_baseColumnName); if (column == null) { _project.processManager.onFailedProcess(this, new Exception("No column named " + _baseColumnName)); return; } if (_project.columnModel.getColumnByName(_newColumnName) != null) { _project.processManager.onFailedProcess(this, new Exception("Another column already named " + _newColumnName)); return; } List<CellAtRow> urls = new ArrayList<CellAtRow>(_project.rows.size()); FilteredRows filteredRows = _engine.getAllFilteredRows(); filteredRows.accept(_project, createRowVisitor(urls)); List<CellAtRow> responseBodies = new ArrayList<CellAtRow>(urls.size()); for (int i = 0; i < urls.size(); i++) { CellAtRow urlData = urls.get(i); CellAtRow cellAtRow = cachedFetch(urlData); if (cellAtRow != null) { responseBodies.add(cellAtRow); } _progress = i * 100 / urls.size(); if (_canceled) { break; } } _urlCache.clear(); if (!_canceled) { HistoryEntry historyEntry = new HistoryEntry( _historyEntryID, _project, _description, ColumnAdditionByFetchingURLsOperation.this, new ColumnAdditionChange( _newColumnName, _columnInsertIndex, responseBodies) ); _project.history.addEntry(historyEntry); _project.processManager.onDoneProcess(this); } }

Target:
public void run() { Column column = _project.columnModel.getColumnByName(_baseColumnName); if (column == null) { _project.processManager.onFailedProcess(this, new Exception("No column named " + _baseColumnName)); return; } if (_project.columnModel.getColumnByName(_newColumnName) != null) { _project.processManager.onFailedProcess(this, new Exception("Another column already named " + _newColumnName)); return; } List<CellAtRow> urls = new ArrayList<CellAtRow>(_project.rows.size()); FilteredRows filteredRows = _engine.getAllFilteredRows(); filteredRows.accept(_project, createRowVisitor(urls)); List<CellAtRow> responseBodies = new ArrayList<CellAtRow>(urls.size()); for (int i = 0; i < urls.size(); i++) { CellAtRow urlData = urls.get(i); String urlString = urlData.cell.value.toString(); Serializable response = null; if (_urlCache != null) { response = cachedFetch(urlString); } else { response = fetch(urlString); } if (response != null) { CellAtRow cellAtRow = new CellAtRow( urlData.row, new Cell(response, null)); responseBodies.add(cellAtRow); } _progress = i * 100 / urls.size(); if (_canceled) { break; } } if (!_canceled) { HistoryEntry historyEntry = new HistoryEntry( _historyEntryID, _project, _description, ColumnAdditionByFetchingURLsOperation.this, new ColumnAdditionChange( _newColumnName, _columnInsertIndex, responseBodies) ); _project.history.addEntry(historyEntry); _project.processManager.onDoneProcess(this); } }
Source:
private List<String> revList(ObjectId initialObjectId) throws IOException { ArrayList<String> revs = new ArrayList<>(); Repository repo = git.getRepository(); try (RevWalk walk = new RevWalk(repo)) { walk.setRetainBody(false); RevCommit head = walk.parseCommit(initialObjectId); while (true) { revs.add(head.getName()); RevCommit[] parents = head.getParents(); if (parents == null || parents.length == 0) { break; } head = walk.parseCommit(parents[0]); } walk.close(); } return revs; }

Target:
private List<String> revList(ObjectId initialObjectId) throws IOException { ArrayList<String> revs = new ArrayList<>(); Repository repo = git.getRepository(); try (RevWalk walk = new RevWalk(repo)) { walk.setRetainBody(false); RevCommit head = walk.parseCommit(initialObjectId); while (true) { revs.add(head.getName()); RevCommit[] parents = head.getParents(); if (parents == null || parents.length == 0) { break; } head = walk.parseCommit(parents[0]); } } return revs; }