auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void foo(java.util.Properties props) { try { Cipher c0 = Cipher.getInstance("AES"); Cipher c100 = Cipher.getInstance("AES/ECB/NoPadding"); Cipher c101 = Cipher.getInstance("AES" + "/ECB/NoPadding"); Cipher c102 = Cipher.getInstance("AES/ECB/NoPadding", getProvider()); Cipher c103 = Cipher.getInstance("AES/ECB/NoPadding", "someProvider"); Cipher c3 = Cipher.getInstance("Blowfish/ECB/PKCS5Padding"); Cipher c4 = Cipher.getInstance("DES/ECB/PKCS5Padding"); Cipher c41 = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); Cipher c5 = Cipher.getInstance("AES/GCM/NoPadding"); Cipher c6 = Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher c7 = Cipher.getInstance("Blowfish/CBC/PKCS5Padding"); Cipher c8 = Cipher.getInstance("DES/CBC/PKCS5Padding"); Cipher c9 = Cipher.getInstance("AES/CBC/PKCS7Padding"); Cipher c10 = Cipher.getInstance("Blowfish/CBC/PKCS7Padding"); Cipher c11 = Cipher.getInstance("DES/CBC/PKCS7Padding"); Cipher c112 = Cipher.getInstance("DES/CBC/NoPadding"); Cipher c12 = Cipher.getInstance("AES/GCM/NoPadding"); Cipher c13 = Cipher.getInstance("Blowfish/GCM/NoPadding"); Cipher c14 = Cipher.getInstance("RSA/NONE/NoPadding"); Cipher c142 = Cipher.getInstance("RSA/GCM/NoPadding"); Cipher c15 = Cipher.getInstance("RSA/NONE/OAEPWithSHA-1AndMGF1Padding"); Cipher c16 = Cipher.getInstance("RSA/NONE/OAEPWITHSHA-256ANDMGF1PADDING"); Cipher.getInstance(null); Cipher.getInstance(""); String algo = props.getProperty("myAlgo", "AES/ECB/PKCS5Padding"); Cipher c17 = Cipher.getInstance(algo); String s = "RSA/NONE/NoPadding"; } catch(NoSuchAlgorithmException|NoSuchPaddingException e) catch (NoSuchProviderException e) }

Target:
public void foo(java.util.Properties props) { try { Cipher.getInstance("AES"); Cipher.getInstance("AES/ECB/NoPadding"); Cipher.getInstance("AES" + "/ECB/NoPadding"); Cipher.getInstance("AES/ECB/NoPadding", getProvider()); Cipher.getInstance("AES/ECB/NoPadding", "someProvider"); Cipher.getInstance("Blowfish/ECB/PKCS5Padding"); Cipher.getInstance("DES/ECB/PKCS5Padding"); Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); Cipher.getInstance("AES/GCM/NoPadding"); Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher.getInstance("Blowfish/CBC/PKCS5Padding"); Cipher.getInstance("DES/CBC/PKCS5Padding"); Cipher.getInstance("AES/CBC/PKCS7Padding"); Cipher.getInstance("Blowfish/CBC/PKCS7Padding"); Cipher.getInstance("DES/CBC/PKCS7Padding"); Cipher.getInstance("DES/CBC/NoPadding"); Cipher.getInstance("AES/GCM/NoPadding"); Cipher.getInstance("Blowfish/GCM/NoPadding"); Cipher.getInstance("RSA/NONE/NoPadding"); Cipher.getInstance("RSA/GCM/NoPadding"); Cipher.getInstance("RSA/NONE/OAEPWithSHA-1AndMGF1Padding"); Cipher.getInstance("RSA/NONE/OAEPWITHSHA-256ANDMGF1PADDING"); Cipher.getInstance(null); Cipher.getInstance(""); String algo = props.getProperty("myAlgo", "AES/ECB/PKCS5Padding"); Cipher.getInstance(algo); String s = "RSA/NONE/NoPadding"; } catch (Exception e) { } }
Source:
public <T> T getStore(final StoreQueryParameters<T> storeQueryParameters) { final String storeName = storeQueryParameters.storeName(); final QueryableStoreType<T> queryableStoreType = storeQueryParameters.queryableStoreType(); final List<T> globalStore = globalStoreProvider.stores(storeName, queryableStoreType); if (!globalStore.isEmpty()) { return queryableStoreType.create(globalStoreProvider, storeName); } final List<T> allStores = new ArrayList<>(); for (final StreamThreadStateStoreProvider storeProvider : storeProviders) { final List<T> stores = storeProvider.stores(storeQueryParameters); if (stores != null && !stores.isEmpty()) { allStores.addAll(stores); if (storeQueryParameters.partition() != null) { break; } } } if (allStores.isEmpty()) { if (storeQueryParameters.partition() != null) { throw new InvalidStateStoreException( String.format("The specified partition %d for store %s does not exist.", storeQueryParameters.partition(), storeName)); } throw new InvalidStateStoreException("The state store, " + storeName + ", may have migrated to another instance."); } return queryableStoreType.create( new WrappingStoreProvider(storeProviders, storeQueryParameters), storeName ); }

Target:
public <T> T getStore(final StoreQueryParameters<T> storeQueryParameters) { final String storeName = storeQueryParameters.storeName(); final QueryableStoreType<T> queryableStoreType = storeQueryParameters.queryableStoreType(); final List<T> globalStore = globalStoreProvider.stores(storeName, queryableStoreType); if (!globalStore.isEmpty()) { return queryableStoreType.create(globalStoreProvider, storeName); } final List<T> allStores = new ArrayList<>(); for (final StreamThreadStateStoreProvider storeProvider : storeProviders) { final List<T> stores = storeProvider.stores(storeQueryParameters); if (!stores.isEmpty()) { allStores.addAll(stores); if (storeQueryParameters.partition() != null) { break; } } } if (allStores.isEmpty()) { if (storeQueryParameters.partition() != null) { throw new InvalidStateStoreException( String.format("The specified partition %d for store %s does not exist.", storeQueryParameters.partition(), storeName)); } throw new InvalidStateStoreException("The state store, " + storeName + ", may have migrated to another instance."); } return queryableStoreType.create( new WrappingStoreProvider(storeProviders, storeQueryParameters), storeName ); }
Source:
public CompletableFuture<Bytes> get(Bytes row, Column column, Bytes defaultValue) { AsyncGet curAsyncGet = new AsyncGet(row, column, defaultValue); asyncGetsQueue.add(curAsyncGet); executorService.submit(() -> { List<AsyncGet> getsList = new ArrayList<>(); asyncGetsQueue.drainTo(getsList); try { Collection<RowColumn> rowColumns = Collections2.transform(getsList, ag -> ag.rc); Map<RowColumn, Bytes> getsMap = tx.get(rowColumns); for (AsyncGet asyncGet : getsList) { Bytes result = getsMap.get(asyncGet.rc); asyncGet.res.complete(result == null ? defaultValue : result); } } catch (Exception e) { for (AsyncGet asyncGet : getsList) { asyncGet.res.completeExceptionally(e); } } }); return curAsyncGet.res; }

Target:
public CompletableFuture<Bytes> get(Bytes row, Column column, Bytes defaultValue) { AsyncGet curAsyncGet = new AsyncGet(row, column, defaultValue); asyncGetsQueue.add(curAsyncGet); executorService.submit(() -> { List<AsyncGet> getsList = new ArrayList<>(); asyncGetsQueue.drainTo(getsList); try { Collection<RowColumn> rowColumns = Collections2.transform(getsList, ag -> ag.rc); Map<RowColumn, Bytes> getsMap = tx.get(rowColumns); for (AsyncGet asyncGet : getsList) { Bytes result = getsMap.get(asyncGet.rc); asyncGet.res.complete(result == null ? asyncGet.defaultValue : result); } } catch (Exception e) { for (AsyncGet asyncGet : getsList) { asyncGet.res.completeExceptionally(e); } } }); return curAsyncGet.res; }
Source:
protected static boolean isAllowedAttributeValue(final Object value) { if (value instanceof String || value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Character || value instanceof Float || value instanceof byte[] || value instanceof short[] || value instanceof int[] || value instanceof float[]) { return true; } if (value instanceof Long) { return SAMUtils.isValidUnsignedIntegerAttribute((Long) value) || ((Long) value >= Integer.MIN_VALUE && (Long) value <= Integer.MAX_VALUE); } return false; }

Target:
protected static boolean isAllowedAttributeValue(final Object value) { if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof String || value instanceof Character || value instanceof Float || value instanceof byte[] || value instanceof short[] || value instanceof int[] || value instanceof float[]) { return true; } if (value instanceof Long) { return SAMUtils.isValidUnsignedIntegerAttribute((Long) value) || ((Long) value >= Integer.MIN_VALUE && (Long) value <= Integer.MAX_VALUE); } return false; }
Source:
private S3StorageProvider getS3StorageProvider() { if (!storageAccountManager.isInitialized()) { throw new DuraCloudRuntimeException("storageAccountManager is not initialized!!!"); } StorageAccount account = storageAccountManager.getPrimaryStorageAccount(); StorageProviderType type = account.getType(); if (!type.equals(StorageProviderType.AMAZON_S3)) { throw new DuraCloudRuntimeException( "The type of primary storage provider on " + storageAccountManager.getAccountName() + " must be " + StorageProviderType.AMAZON_S3); } return new S3StorageProvider(account.getUsername(), account.getPassword(), account.getOptions()); }

Target:
private S3StorageProvider getS3StorageProvider() { if (!storageAccountManager.isInitialized()) { throw new DuraCloudRuntimeException("storageAccountManager is not initialized!!!"); } StorageAccount account = storageAccountManager.getPrimaryStorageAccount(); StorageProviderType type = account.getType(); return new S3StorageProvider(account.getUsername(), account.getPassword(), account.getOptions()); }
Source:
public static Set<String> getPluginsWithFilesystem(@NotNull Project project) { CachedValue<Set<String>> cachedPluginFilesystem = project.getUserData(PLUGIN_FILESYSTEM_KEY); if (cachedPluginFilesystem != null && cachedPluginFilesystem.hasUpToDateValue()) { return cachedPluginFilesystem.getValue(); } CachedValue<Set<String>> cachedValue = CachedValuesManager.getManager(project).createCachedValue(() -> { Set<String> plugins = new HashSet<>(); Collection<PhpClass> prefixFilesystem = PhpIndex.getInstance(project).getClassesByFQN("\\Shopware\\Components\\Filesystem\\PrefixFilesystem"); if (!prefixFilesystem.isEmpty()) { for(PhpClass phpClass: PhpIndex.getInstance(project).getAllSubclasses("\\Shopware\\Components\\Plugin")) { plugins.add(phpClass.getName()); } } return CachedValueProvider.Result.create(plugins, PsiModificationTracker.MODIFICATION_COUNT); }, false); project.putUserData(PLUGIN_FILESYSTEM_KEY, cachedValue); return cachedValue.getValue(); }

Target:
public static Set<String> getPluginsWithFilesystem(@NotNull Project project) { CachedValue<Set<String>> cachedPluginFilesystem = project.getUserData(PLUGIN_FILESYSTEM_KEY); if (cachedPluginFilesystem != null && cachedPluginFilesystem.hasUpToDateValue()) { return cachedPluginFilesystem.getValue(); } CachedValue<Set<String>> cachedValue = CachedValuesManager.getManager(project).createCachedValue(() -> { Set<String> plugins = new HashSet<>(); Collection<PhpClass> prefixFilesystem = PhpIndex.getInstance(project).getClassesByFQN(ShopwareFQDN.PREFIX_FILESYSTEM); if (!prefixFilesystem.isEmpty()) { for(PhpClass phpClass: PhpIndex.getInstance(project).getAllSubclasses(ShopwareFQDN.PLUGIN_BOOTSTRAP)) { plugins.add(phpClass.getName()); } } return CachedValueProvider.Result.create(plugins, PsiModificationTracker.MODIFICATION_COUNT); }, false); project.putUserData(PLUGIN_FILESYSTEM_KEY, cachedValue); return cachedValue.getValue(); }
Source:
private void fetchSiteSettingsAndUpdateDefaultPostFormatIfNecessary() { if (!TextUtils.isEmpty(getEditPostRepository().getPostFormat())) { return; } mSiteSettings = SiteSettingsInterface.getInterface( getActivity(), getSite(), new SiteSettingsListener() { @Override public void onSaveError(Exception error) { } @Override public void onFetchError(Exception error) { } @Override public void onSettingsUpdated() { if (getEditPostActivityHook() != null) { mAnalyticsTrackerWrapper.track(Stat.EDITOR_POST_FORMAT_CHANGED); updatePostFormat( mSiteSettings.getDefaultPostFormat()); } } @Override public void onSettingsSaved() { } @Override public void onCredentialsValidated(Exception error) { } }); if (mSiteSettings != null) { mSiteSettings.init(true); } }

Target:
private void fetchSiteSettingsAndUpdateDefaultPostFormatIfNecessary() { if (!TextUtils.isEmpty(getEditPostRepository().getPostFormat())) { return; } mSiteSettings = SiteSettingsInterface.getInterface( getActivity(), getSite(), new SiteSettingsListener() { @Override public void onSaveError(Exception error) { } @Override public void onFetchError(Exception error) { } @Override public void onSettingsUpdated() { if (getEditPostActivityHook() != null) { updatePostFormat( mSiteSettings.getDefaultPostFormat()); } } @Override public void onSettingsSaved() { } @Override public void onCredentialsValidated(Exception error) { } }); if (mSiteSettings != null) { mSiteSettings.init(true); } }
Source:
public static void updateToTable(Connection connection, String tableName, Persistable persistable, int id) { String query = "UPDATE " + tableName + " SET " + DatabaseHelper.DATA_COL + " = ? " + " WHERE " + DatabaseHelper.ID_COL + " = ?;"; PreparedStatement preparedStatement = null; try { preparedStatement = connection.prepareStatement(query); byte[] blob = org.commcare.modern.database.TableBuilder.toBlob(persistable); preparedStatement.setBinaryStream(1, new ByteArrayInputStream(blob), blob.length); preparedStatement.setInt(2, id); preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { if (preparedStatement != null) { try { preparedStatement.close(); } catch (SQLException e) { e.printStackTrace(); } } } }

Target:
public static void updateToTable(Connection connection, String tableName, Persistable persistable, int id) { String query = "UPDATE " + tableName + " SET " + DatabaseHelper.DATA_COL + " = ? " + " WHERE " + DatabaseHelper.ID_COL + " = ?;"; PreparedStatement preparedStatement = null; try { preparedStatement = connection.prepareStatement(query); byte[] blob = org.commcare.modern.database.TableBuilder.toBlob(persistable); preparedStatement.setBinaryStream(1, new ByteArrayInputStream(blob), blob.length); preparedStatement.setInt(2, id); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } finally { if (preparedStatement != null) { try { preparedStatement.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
Source:
public InternalSinkRecord(ConsumerRecord<byte[], byte[]> originalRecord, String topic, int partition, Schema keySchema, Object key, Schema valueSchema, Object value, long kafkaOffset, Long timestamp, TimestampType timestampType, Iterable<Header> headers) { super(topic, partition, keySchema, key, valueSchema, value, kafkaOffset, timestamp, timestampType, headers); this.originalRecord = originalRecord; }

Target:
protected InternalSinkRecord(ConsumerRecord<byte[], byte[]> originalRecord, String topic, int partition, Schema keySchema, Object key, Schema valueSchema, Object value, long kafkaOffset, Long timestamp, TimestampType timestampType, Iterable<Header> headers) { super(topic, partition, keySchema, key, valueSchema, value, kafkaOffset, timestamp, timestampType, headers); this.originalRecord = originalRecord; }
Source:
public void cancelReservation() { Part replacement = findReplacement(false); if (hasReplacementPart() && null != replacement) { setReplacementPart(null); replacement.setReserveId(null); if (replacement.isSpare()) { Part spare = campaign.checkForExistingSparePart(replacement); if (null != spare) { spare.incrementQuantity(); campaign.removePart(replacement); } } } }

Target:
public void cancelReservation() { Part replacement = findReplacement(false); if (hasReplacementPart() && (null != replacement)) { setReplacementPart(null); replacement.setReserveId(null); if (replacement.isSpare()) { Part spare = campaign.checkForExistingSparePart(replacement); if (null != spare) { spare.incrementQuantity(); campaign.removePart(replacement); } } } }
Source:
private void deleteAllElements(BreakpointContainer container, ModelDelta containerDelta) { for (Object element : container.getChildren()) { if (element instanceof BreakpointContainer) { BreakpointContainer.removeAll((BreakpointContainer) element, containerDelta); } else { BreakpointContainer.removeBreakpoint(container, (IBreakpoint) element, containerDelta); } } }

Target:
private void deleteAllElements(BreakpointContainer container, ModelDelta containerDelta) { for (Object childElement : container.getChildren()) { if (childElement instanceof BreakpointContainer) { BreakpointContainer.removeAll((BreakpointContainer) childElement, containerDelta); } else { BreakpointContainer.removeBreakpoint(container, (IBreakpoint) childElement, containerDelta); } } }
Source:
public String getCommandUsage(ICommandSender sender) { return "Displays the version of this SpongeModded server"; }

Target:
public String getCommandUsage(ICommandSender sender) { return "Displays the Sponge and Minecraft version of this server."; }
Source:
void put(SystemStreamPartition ssp, Object key, Object message) { List<IncomingMessageEnvelope> messages = bufferedMessages.get(ssp); String offset = String.valueOf(messages.size()); if (message instanceof EndOfStreamMessage) { offset = IncomingMessageEnvelope.END_OF_STREAM_OFFSET; } IncomingMessageEnvelope messageEnvelope = new IncomingMessageEnvelope(ssp, offset, key, message, 0, Instant.now().toEpochMilli(), 0L); bufferedMessages.get(ssp) .add(messageEnvelope); }

Target:
void put(SystemStreamPartition ssp, Object key, Object message) { List<IncomingMessageEnvelope> messages = bufferedMessages.get(ssp); String offset = String.valueOf(messages.size()); if (message instanceof EndOfStreamMessage) { offset = IncomingMessageEnvelope.END_OF_STREAM_OFFSET; } IncomingMessageEnvelope messageEnvelope = new IncomingMessageEnvelope(ssp, offset, key, message, 0, 0L, Instant.now().toEpochMilli()); bufferedMessages.get(ssp) .add(messageEnvelope); }
Source:
public void before() throws IOException,TimeoutException,InterruptedException { dispatcher = new Dispatcher(); statementContext = new DefaultContext(); ResourceAddress addressStats = ADDRESS_TEMPLATE_STATISTICS.resolve(statementContext); dispatcher.execute(new Operation.Builder(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION, addressStats).param("name", "statistics-enabled").param("value", "true").build()); if (cliClient.reloadRequired()) { cliClient.reload(); Library.letsSleep(5000); } if (ConfigUtils.isDomain()) { navigation = new FinderNavigation(browser, DomainRuntimeEntryPoint.class) .addAddress(FinderNames.BROWSE_DOMAIN_BY, FinderNames.HOSTS) .addAddress(FinderNames.HOST, "master") .addAddress(FinderNames.SERVER,"server-one") .addAddress(FinderNames.MONITOR, FinderNames.SUBSYSTEMS) .addAddress(FinderNames.SUBSYSTEM, "Undertow"); } else{ navigation = new FinderNavigation(browser, StandaloneRuntimeEntryPoint.class) .addAddress(FinderNames.SERVER, FinderNames.STANDALONE_SERVER) .addAddress(FinderNames.MONITOR, FinderNames.SUBSYSTEMS) .addAddress(FinderNames.SUBSYSTEM,"HTTP"); } navigation.selectRow().invoke("View"); Application.waitUntilVisible(); wmPage.getResourceManager().viewByName("default-server"); Console.withBrowser(browser).waitUntilLoaded(); }

Target:
public void before() throws IOException, TimeoutException, InterruptedException { dispatcher = new Dispatcher(); statementContext = new DefaultContext(); ResourceAddress addressStats = ADDRESS_TEMPLATE_STATISTICS.resolve(statementContext); dispatcher.execute(new Operation.Builder(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION, addressStats).param("name", "statistics-enabled").param("value", "true").build()); if (ConfigUtils.isDomain()) { new DomainManager(cliClient).reloadAndWaitUntilRunning(60000); navigation = new FinderNavigation(browser, DomainRuntimeEntryPoint.class) .addAddress(FinderNames.BROWSE_DOMAIN_BY, FinderNames.HOSTS) .addAddress(FinderNames.HOST, "master") .addAddress(FinderNames.SERVER, "server-one") .addAddress(FinderNames.MONITOR, FinderNames.SUBSYSTEMS) .addAddress(FinderNames.SUBSYSTEM, "Undertow"); } else { navigation = new FinderNavigation(browser, StandaloneRuntimeEntryPoint.class) .addAddress(FinderNames.SERVER, FinderNames.STANDALONE_SERVER) .addAddress(FinderNames.MONITOR, FinderNames.SUBSYSTEMS) .addAddress(FinderNames.SUBSYSTEM, "HTTP"); } navigation.selectRow().invoke("View"); Application.waitUntilVisible(); wmPage.getResourceManager().viewByName("default-server"); Console.withBrowser(browser).waitUntilLoaded(); }
Source:
private void deleteFrom(SqlDatabaseWrapper database, List<Migration> migrations) { for (Migration migration : migrations) { Batch batch = migration.batch(); database.rawQuery(DELETE_QUERY, batch.getDownloadBatchId().stringValue()); } }

Target:
private void deleteFrom(SqlDatabaseWrapper database, List<Migration> migrations) { for (Migration migration : migrations) { Batch batch = migration.batch(); database.rawQuery(DELETE_BY_ID_QUERY, batch.getDownloadBatchId().stringValue()); } }
Source:
private static String createWorkflowTrsUrl(Workflow workflow, WorkflowVersion workflowVersion, String dockstoreGA4GHBaseUrl) { final String sourceControl = workflow.getSourceControl().toString(); final String organization = workflow.getOrganization(); final String repository = workflow.getRepository(); final String workflowName = workflow.getWorkflowName(); final String versionOfWorkflow = workflowVersion.getName(); final String sourceControlPathPrefix = sourceControl + "/" + organization + "/" + repository; final String sourceControlPath = StringUtils.isEmpty(workflowName) ? sourceControlPathPrefix : sourceControlPathPrefix + "/" + workflowName; final String workflowVersionPrimaryDescriptorPath = "#workflow/" + sourceControlPath; final String workflowVersionPrimaryDescriptorPathPlainText; try { workflowVersionPrimaryDescriptorPathPlainText = ToolsImplCommon.getUrl(workflowVersionPrimaryDescriptorPath, dockstoreGA4GHBaseUrl); } catch (UnsupportedEncodingException e) { LOG.error("Could not create Zenodo related identifier." + " Error is " + e.getMessage(), e); throw new CustomWebApplicationException("Could not create Zenodo related identifier", HttpStatus.SC_INTERNAL_SERVER_ERROR); } final String workflowVersionType = workflow.getDescriptorType().toString(); final String workflowDescriptorName = workflowVersion.getWorkflowPath(); Path p = Paths.get(workflowDescriptorName); final String descriptorFile = p.getFileName().toString(); final String workflowVersionTrsUrl = workflowVersionPrimaryDescriptorPathPlainText + "/versions/" + versionOfWorkflow + "/PLAIN-" + workflowVersionType + "/descriptor/" + descriptorFile; return workflowVersionTrsUrl; }

Target:
protected static String createWorkflowTrsUrl(Workflow workflow, WorkflowVersion workflowVersion, String dockstoreGA4GHBaseUrl) { final String sourceControlPath = workflow.getWorkflowPath(); final String workflowVersionPrimaryDescriptorPath = WORKFLOW_PREFIX + "/" + sourceControlPath; final String workflowVersionPrimaryDescriptorPathPlainText; try { workflowVersionPrimaryDescriptorPathPlainText = ToolsImplCommon.getUrl(workflowVersionPrimaryDescriptorPath, dockstoreGA4GHBaseUrl); } catch (UnsupportedEncodingException e) { LOG.error("Could not create Zenodo related identifier." + " Error is " + e.getMessage(), e); throw new CustomWebApplicationException("Could not create Zenodo related identifier", HttpStatus.SC_INTERNAL_SERVER_ERROR); } final String workflowVersionType = workflow.getDescriptorType().toString(); final String workflowDescriptorName = workflowVersion.getWorkflowPath(); Path p = Paths.get(workflowDescriptorName); final String descriptorFile = p.getFileName().toString(); final String versionOfWorkflow = workflowVersion.getName(); final String workflowVersionTrsUrl = workflowVersionPrimaryDescriptorPathPlainText + "/versions/" + versionOfWorkflow + "/PLAIN-" + workflowVersionType + "/descriptor/" + descriptorFile; return workflowVersionTrsUrl; }
Source:
public void testGetStudies() { String url = "/v2/studies?species=mmusculus&assembly=grcm38&pageNumber=0&pageSize=1"; ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); assertEquals(HttpStatus.OK, response.getStatusCode()); Configuration configuration = Configuration.defaultConfiguration() .jsonProvider(new JacksonJsonProvider()) .mappingProvider(new JacksonMappingProvider(objectMapper)) .addOptions(Option.SUPPRESS_EXCEPTIONS); List<VariantStudySummary> variantList = JsonPath.using(configuration).parse(response.getBody()) .read("$['_embedded']['variantStudySummaryList']", new TypeRef<List<VariantStudySummary>>() { }); assertEquals("PRJX00001", variantList.get(0).getStudyId()); assertEquals("Human Variation Data From dbSNP build 144", variantList.get(0).getStudyName()); assertEquals(1, variantList.size()); Integer totalNumberOfElements = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['totalElements']", Integer.class); Integer pageNumber = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['number']", Integer.class); Integer size = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['size']", Integer.class); Integer totalPages = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['totalPages']", Integer.class); assertEquals(2, totalNumberOfElements.intValue()); assertEquals(0, pageNumber.intValue()); assertEquals(1, size.intValue()); }

Target:
public void testGetStudies() { String url = "/v2/studies?species=mmusculus&assembly=grcm38&pageNumber=0&pageSize=1"; ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); assertEquals(HttpStatus.OK, response.getStatusCode()); Configuration configuration = Configuration.defaultConfiguration() .jsonProvider(new JacksonJsonProvider()) .mappingProvider(new JacksonMappingProvider(objectMapper)) .addOptions(Option.SUPPRESS_EXCEPTIONS); List<VariantStudySummary> variantList = JsonPath.using(configuration).parse(response.getBody()) .read("$['_embedded']['variantStudySummaryList']", new TypeRef<List<VariantStudySummary>>() { }); assertEquals("PRJX00001", variantList.get(0).getStudyId()); assertEquals("Human Variation Data From dbSNP build 144", variantList.get(0).getStudyName()); assertEquals(1, variantList.size()); Integer totalNumberOfElements = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['totalElements']", Integer.class); Integer pageNumber = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['number']", Integer.class); Integer size = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['size']", Integer.class); Integer totalPages = JsonPath.using(configuration).parse(response.getBody()) .read("$['page']['totalPages']", Integer.class); assertEquals(2, totalNumberOfElements.intValue()); assertEquals(0, pageNumber.intValue()); assertEquals(1, size.intValue()); assertEquals(2, totalPages.intValue()); }
Source:
protected String generateCommandKey(Method method) { return method.toString(); }

Target:
private String generateCommandKey(Method method) { return "feign#" + method.toString(); }
Source:
public VoltTable[] run(SystemProcedureExecutionContext ctx, byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); int taskId = buffer.getInt(); TaskType taskType = TaskType.values()[taskId]; switch (taskType) { case SP_JAVA_GET_DRID_TRACKER: ParameterSet params = ParameterSet.fromArrayNoCopy(new Object[] { payload }); int producerClusterId = (int)params.getParam(1); Integer producerPartitionId = (int)params.getParam(2); DRConsumerDrIdTracker tracker; Map<Integer, Map<Integer, DRConsumerDrIdTracker>> drIdTrackers = ctx.getDrAppliedTrackers(); Map<Integer, DRConsumerDrIdTracker> producerPartitionMap = drIdTrackers.get(producerClusterId); if (producerPartitionMap != null) { tracker = producerPartitionMap.get(producerPartitionId); if (tracker == null) { tracker = new DRConsumerDrIdTracker(-1L, Long.MIN_VALUE, Long.MIN_VALUE); } } else { tracker = new DRConsumerDrIdTracker(-1L, Long.MIN_VALUE, Long.MIN_VALUE); } JSONStringer stringer = new JSONStringer(); try { ExtensibleSnapshotDigestData.serializeConsumerDrIdTrackerToJSON(stringer, producerPartitionId, tracker); } catch (JSONException e) { throw new VoltAbortException("DRConsumerDrIdTracker could not be converted to JSON"); } setAppStatusString(stringer.toString()); default: throw new VoltAbortException("Unable to find the task associated with the given task id"); } }

Target:
public VoltTable[] run(SystemProcedureExecutionContext ctx, byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); int taskId = buffer.getInt(); TaskType taskType = TaskType.values()[taskId]; switch (taskType) { case SP_JAVA_GET_DRID_TRACKER: ParameterSet params = ParameterSet.fromArrayNoCopy(new Object[] { payload }); int producerClusterId = (int)params.getParam(1); Integer producerPartitionId = (int)params.getParam(2); DRConsumerDrIdTracker tracker; Map<Integer, Map<Integer, DRConsumerDrIdTracker>> drIdTrackers = ctx.getDrAppliedTrackers(); Map<Integer, DRConsumerDrIdTracker> producerPartitionMap = drIdTrackers.get(producerClusterId); if (producerPartitionMap != null) { tracker = producerPartitionMap.get(producerPartitionId); if (tracker == null) { tracker = new DRConsumerDrIdTracker(DRLogSegmentId.makeEmptyDRId(producerClusterId), Long.MIN_VALUE, Long.MIN_VALUE); } } else { tracker = new DRConsumerDrIdTracker(DRLogSegmentId.makeEmptyDRId(producerClusterId), Long.MIN_VALUE, Long.MIN_VALUE); } JSONStringer stringer = new JSONStringer(); try { ExtensibleSnapshotDigestData.serializeConsumerDrIdTrackerToJSON(stringer, producerPartitionId, tracker); } catch (JSONException e) { throw new VoltAbortException("DRConsumerDrIdTracker could not be converted to JSON"); } setAppStatusString(stringer.toString()); default: throw new VoltAbortException("Unable to find the task associated with the given task id"); } }
Source:
private List<List<String>> verifySubtotalsSpec(List<List<String>> subtotalsSpec, List<DimensionSpec> dimensions) { if (subtotalsSpec != null) { for (List<String> subtotalSpec : subtotalsSpec) { int i = 0; for (String s : subtotalSpec) { boolean found = false; for (; i < dimensions.size(); i++) { if (s.equals(dimensions.get(i).getOutputName())) { found = true; break; } } if (!found) { throw new IAE( "Subtotal spec %s is either not a subset or items are in different order than in dimensiosn spec.", subtotalSpec ); } } } } return subtotalsSpec; }

Target:
private List<List<String>> verifySubtotalsSpec(List<List<String>> subtotalsSpec, List<DimensionSpec> dimensions) { if (subtotalsSpec != null) { for (List<String> subtotalSpec : subtotalsSpec) { int i = 0; for (String s : subtotalSpec) { boolean found = false; for (; i < dimensions.size(); i++) { if (s.equals(dimensions.get(i).getOutputName())) { found = true; break; } } if (!found) { throw new IAE( "Subtotal spec %s is either not a subset or items are in different order than in dimensions.", subtotalSpec ); } } } } return subtotalsSpec; }
Source:
public PersonalFavouritePoint(@NonNull Context ctx, @NonNull String typeName, double latitude, double longitude) throws IllegalArgumentException { this(ctx, PointType.valueOf(typeName), latitude, longitude); }

Target:
PersonalFavouritePoint(@NonNull Context ctx, @NonNull String typeName, double latitude, double longitude) throws IllegalArgumentException { this(ctx, PointType.valueOfTypeName(typeName), latitude, longitude); }
Source:
public void testContinuousQuery() throws Exception { try(IgniteEx g0 = startGrid(0); IgniteEx g1 = startGrid(1)) { IgniteCache<Integer, Integer> cache = g0.createCache("cache-1"); QueryCursor qry = cache.query(new ContinuousQuery<>() .setInitialQuery(new ScanQuery<>()) .setPageSize(100) .setTimeInterval(1000) .setLocalListener(evts -> { }) .setRemoteFilterFactory(() -> evt -> true) ); for (int i=0; i<100; i++) cache.put(i, i); SystemView<ContinuousQueryView> qrys = g0.context().systemView().view(CQ_SYS_VIEW); assertEquals(1, qrys.size()); for (ContinuousQueryView cq : qrys) { assertEquals("cache-1", cq.cacheName()); assertEquals(100, cq.bufferSize()); assertEquals(1000, cq.interval()); assertEquals(g0.localNode().id(), cq.nodeId()); assertTrue(cq.localListener().startsWith(getClass().getName())); assertTrue(cq.remoteFilter().startsWith(getClass().getName())); assertNull(cq.localTransformedListener()); assertNull(cq.remoteTransformer()); } qrys = g1.context().systemView().view(CQ_SYS_VIEW); assertEquals(1, qrys.size()); for (ContinuousQueryView cq : qrys) { assertEquals("cache-1", cq.cacheName()); assertEquals(100, cq.bufferSize()); assertEquals(1000, cq.interval()); assertEquals(g0.localNode().id(), cq.nodeId()); assertNull(cq.localListener()); assertTrue(cq.remoteFilter().startsWith(getClass().getName())); assertNull(cq.localTransformedListener()); assertNull(cq.remoteTransformer()); } } }

Target:
public void testContinuousQuery() throws Exception { try(IgniteEx originNode = startGrid(0); IgniteEx remoteNode = startGrid(1)) { IgniteCache<Integer, Integer> cache = originNode.createCache("cache-1"); SystemView<ContinuousQueryView> origQrys = originNode.context().systemView().view(CQ_SYS_VIEW); SystemView<ContinuousQueryView> remoteQrys = remoteNode.context().systemView().view(CQ_SYS_VIEW); assertEquals(0, origQrys.size()); assertEquals(0, remoteQrys.size()); try(QueryCursor qry = cache.query(new ContinuousQuery<>() .setInitialQuery(new ScanQuery<>()) .setPageSize(100) .setTimeInterval(1000) .setLocalListener(evts -> { }) .setRemoteFilterFactory(() -> evt -> true) )) { for (int i=0; i<100; i++) cache.put(i, i); checkContinuousQueryView(originNode, origQrys, true); checkContinuousQueryView(originNode, remoteQrys, false); } assertEquals(0, origQrys.size()); assertEquals(0, remoteQrys.size()); } }
Source:
public SpaceReference getTagSpaceRef() { String centralFileBaseName = getCentralFileBaseFullName() + "."; String spaceName = centralFileBaseName.substring(0, centralFileBaseName.indexOf('.')); return new SpaceReference(spaceName, new WikiReference(getContext().getDatabase())); }

Target:
public SpaceReference getTagSpaceRef() { String centralFileBaseName = getCentralFileBaseFullName() + "."; String spaceName = centralFileBaseName.substring(0, centralFileBaseName.indexOf('.')); if (Strings.isNullOrEmpty(spaceName)) { spaceName = modelConfig.getDefaultReferenceValue(EntityType.SPACE) + "_attachments"; } return new SpaceReference(spaceName, new WikiReference(getContext().getDatabase())); }
Source:
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException { String bundleName = toBundleName(baseName, locale); String resourceName = toResourceName(bundleName, "properties"); ResourceBundle bundle = null; InputStream stream = null; if (reload) { URL url = loader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { connection.setUseCaches(false); stream = connection.getInputStream(); } } } else { stream = loader.getResourceAsStream(resourceName); } if (stream != null) { try { bundle = new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8)); } finally { stream.close(); } } return bundle; }

Target:
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException { String resourceName = toResourceName(toBundleName(baseName, locale), "properties"); ResourceBundle bundle = null; InputStream stream = null; if (reload) { URL url = loader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { connection.setUseCaches(false); stream = connection.getInputStream(); } } } else { stream = loader.getResourceAsStream(resourceName); } if (stream != null) { try { bundle = new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8)); } finally { stream.close(); } } return bundle; }
Source:
public void processBarrier(CheckpointBarrier barrier, InputChannelInfo channelInfo) throws IOException { long barrierId = barrier.getId(); if (currentCheckpointId > barrierId || (currentCheckpointId == barrierId && !isCheckpointPending())) { return; } if (currentCheckpointId < barrierId) { if (isCheckpointPending()) { cancelSubsumedCheckpoint(barrierId); } markCheckpointStart(barrier.getTimestamp()); currentCheckpointId = barrierId; numBarriersReceived = 0; allBarriersReceivedFuture = new CompletableFuture<>(); checkpointCoordinator.initCheckpoint(barrierId, barrier.getCheckpointOptions()); for (final CheckpointableInput input : inputs) { input.checkpointStarted(barrier); } notifyCheckpoint(barrier); } if (currentCheckpointId == barrierId) { LOG.debug("{}: Received barrier from channel @ {}.", taskName, channelInfo, barrierId); if (++numBarriersReceived == numOpenChannels) { if (getNumOpenChannels() > 1) { markAlignmentEnd(); } else { markAlignmentEnd(0); } allBarriersReceivedFuture.complete(null); resetPendingCheckpoint(barrierId); } } }

Target:
public void processBarrier(CheckpointBarrier barrier, InputChannelInfo channelInfo) throws IOException { long barrierId = barrier.getId(); if (currentCheckpointId > barrierId || (currentCheckpointId == barrierId && !isCheckpointPending())) { return; } if (currentCheckpointId < barrierId) { if (isCheckpointPending()) { cancelSubsumedCheckpoint(barrierId); } if (getNumOpenChannels() == 1) { markAlignmentStartAndEnd(barrier.getTimestamp()); } else { markAlignmentStart(barrier.getTimestamp()); } currentCheckpointId = barrierId; numBarriersReceived = 0; allBarriersReceivedFuture = new CompletableFuture<>(); checkpointCoordinator.initCheckpoint(barrierId, barrier.getCheckpointOptions()); for (final CheckpointableInput input : inputs) { input.checkpointStarted(barrier); } notifyCheckpoint(barrier); } if (currentCheckpointId == barrierId) { LOG.debug("{}: Received barrier from channel @ {}.", taskName, channelInfo, barrierId); if (++numBarriersReceived == numOpenChannels) { if (getNumOpenChannels() > 1) { markAlignmentEnd(); } allBarriersReceivedFuture.complete(null); resetPendingCheckpoint(barrierId); } } }
Source:
private void setTexts() { mAnchorLikely.setText(mSettings.getAnchorLikely()); mAnchorNotLikely.setText(mSettings.getAnchorNotLikely()); mBtnSubmit.setText(mSettings.getBtnSubmit()); mBtnDismiss.setText(mSettings.getBtnDismiss()); mBtnEditScore.setText("BACK"); mEtFeedback.setHint(mSettings.getFollowupPlaceholder(mRatingBar.getSelectedScore())); }

Target:
private void setTexts() { mAnchorLikely.setText(mSettings.getAnchorLikely()); mAnchorNotLikely.setText(mSettings.getAnchorNotLikely()); mBtnSubmit.setText(mSettings.getBtnSubmit()); mBtnDismiss.setText(mSettings.getBtnDismiss()); mBtnEditScore.setText(mSettings.getBtnEditScore()); mEtFeedback.setHint(mSettings.getFollowupPlaceholder(mRatingBar.getSelectedScore())); }
Source:
protected String visitFunctionCall(FunctionCall node, @Nullable List<Expression> parameters) { StringBuilder builder = new StringBuilder(); String arguments = joinExpressions(node.getArguments()); if (node.getArguments().isEmpty() && "count".equalsIgnoreCase(node.getName().getSuffix())) { arguments = "*"; } if (node.isDistinct()) { arguments = "DISTINCT " + arguments; } builder.append(node.getName()); if (!FUNCTION_CALLS_WITHOUT_PARENTHESIS.contains(node.getName().toString())) { builder.append('(').append(arguments).append(')'); } node.filter() .map(filter -> builder .append(" FILTER (WHERE ") .append(formatExpression(filter)) .append(")")); node.getWindow() .map(window -> builder .append(" OVER ") .append(visitWindow(window, parameters))); return builder.toString(); }

Target:
protected String visitFunctionCall(FunctionCall node, @Nullable List<Expression> parameters) { StringBuilder builder = new StringBuilder(); String arguments = joinExpressions(node.getArguments()); if (node.getArguments().isEmpty() && "count".equalsIgnoreCase(node.getName().getSuffix())) { arguments = "*"; } if (node.isDistinct()) { arguments = "DISTINCT " + arguments; } builder.append(node.getName()); if (!FUNCTION_CALLS_WITHOUT_PARENTHESIS.contains(node.getName().toString())) { builder.append('(').append(arguments).append(')'); } node.filter() .ifPresent(filter -> builder .append(" FILTER (WHERE ") .append(formatExpression(filter)) .append(")")); node.getWindow() .ifPresent(window -> builder .append(" OVER ") .append(visitWindow(window, parameters))); return builder.toString(); }
Source:
private static Properties calcEnvironment(IConfiguration cfg){ Properties envProps = new Properties(); ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg); IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true); for(int i = 0; i < vars.length; i++){ String key = vars[i].getName(); String value = vars[i].getValue(); if (key != null && value != null) envProps.setProperty(key, value); else { if (key != null) envProps.setProperty(key, ""); String varStr = null; try { varStr = " var.toString:" + vars[i].toString(); } catch(NullPointerException e) { } ManagedBuilderCorePlugin.log( new Status( IStatus.INFO, ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.OK, "ScannerConfigBuilder.calcEnvironment(" + String.valueOf(cfg) + ')' + (varStr == null ? "" : varStr) + " class:" + vars[i].getClass().getName() + " name:" + String.valueOf(key) + " value:" + String.valueOf(value), null)); } } return envProps; }

Target:
private static Properties calcEnvironment(IConfiguration cfg){ Properties envProps = new Properties(); ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg); IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true); for(int i = 0; i < vars.length; i++){ String key = vars[i].getName(); String value = vars[i].getValue(); if (key != null) envProps.setProperty(key, value == null ? "" : value); } return envProps; }
Source:
public static String escapeStringLiteral(final String s) { if (s == null) { return DruidExpression.nullLiteral(); } else { boolean isPlainAscii = true; final StringBuilder builder = new StringBuilder("'"); for (int i = 0; i < s.length(); i++) { final char c = s.charAt(i); if (Character.isLetterOrDigit(c) || c == ' ') { builder.append(c); if (c > 127) { isPlainAscii = false; } } else { builder.append("\\").append(BaseEncoding.base16().encode(Chars.toByteArray(c))); isPlainAscii = false; } } builder.append("'"); return isPlainAscii ? builder.toString() : "U&" + builder.toString(); } }

Target:
public static String escapeStringLiteral(final String s) { Preconditions.checkNotNull(s); if (s == null) { return "''"; } else { boolean isPlainAscii = true; final StringBuilder builder = new StringBuilder("'"); for (int i = 0; i < s.length(); i++) { final char c = s.charAt(i); if (Character.isLetterOrDigit(c) || c == ' ') { builder.append(c); if (c > 127) { isPlainAscii = false; } } else { builder.append("\\").append(BaseEncoding.base16().encode(Chars.toByteArray(c))); isPlainAscii = false; } } builder.append("'"); return isPlainAscii ? builder.toString() : "U&" + builder.toString(); } }
Source:
public synchronized void outputNewImage(String filename) { if (imageRenderer == null) { LOGGER.severe("No image renderer has been set. " + "Use setRenderer() method in order to be able to output images."); throw new NoRendererException(); } switch (layoutPolicy) { case COMPUTED_IN_LAYOUT_RUNNER: layoutPipeIn.pump(); break; case COMPUTED_ONCE_AT_NEW_IMAGE: if (layout != null) layout.compute(); break; case COMPUTED_FULLY_AT_NEW_IMAGE: stabilizeLayout(layout.getStabilizationLimit()); break; default: break; } if (clearImageBeforeOutput || gg.getNodeCount() == 0) { imageRenderer.clear(0x00000000); } if (gg.getNodeCount() > 0) { if (autofit) { gg.computeBounds(); Point3 lo = gg.getMinPos(); Point3 hi = gg.getMaxPos(); imageRenderer.getGraphRenderer().getCamera().setBounds(lo.x, lo.y, lo.z, hi.x, hi.y, hi.z); } imageRenderer.render(0, 0, resolution.getWidth(), resolution.getHeight()); } BufferedImage image = imageRenderer.getRenderedImage(); for (Filter action : filters) action.apply(image); image.flush(); try { writeImage(image, filename); printProgress(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to write image", e); } }

Target:
public synchronized void outputNewImage(String filename) { switch (layoutPolicy) { case COMPUTED_IN_LAYOUT_RUNNER: layoutPipeIn.pump(); break; case COMPUTED_ONCE_AT_NEW_IMAGE: if (layout != null) layout.compute(); break; case COMPUTED_FULLY_AT_NEW_IMAGE: stabilizeLayout(layout.getStabilizationLimit()); break; default: break; } if (clearImageBeforeOutput || gg.getNodeCount() == 0) { clearImage(0x00000000); } if (gg.getNodeCount() > 0) { if (autofit) { gg.computeBounds(); Point3 lo = gg.getMinPos(); Point3 hi = gg.getMaxPos(); getCamera().setBounds(lo.x, lo.y, lo.z, hi.x, hi.y, hi.z); } render(); } BufferedImage image = getRenderedImage(); for (Filter action : filters) action.apply(image); image.flush(); try { writeImage(image, filename); printProgress(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to write image", e); } }
Source:
private void updateImageInformation(Tool tool, Tag newTag, Tag oldTag) { if (oldTag.getImages().isEmpty()) { oldTag.getImages().addAll(getImageInformationForTag(tool, newTag).getImages()); } else { Iterator<Image> iterator = oldTag.getImages().iterator(); Iterator<Image> iterator2 = newTag.getImages().iterator(); while (iterator.hasNext()) { Image oldImage = iterator.next(); while (iterator2.hasNext()) { Image newImage = iterator2.next(); if (oldImage.getImageID() != newImage.getImageID()) { oldTag.getImages().remove(oldImage); oldTag.getImages().addAll(getImageInformationForTag(tool, newTag).getImages()); } } } } }

Target:
private void updateImageInformation(Tool tool, Tag newTag, Tag oldTag) { if (oldTag.getImages().isEmpty()) { oldTag.getImages().addAll(getImagesForTag(tool, newTag)); } else { oldTag.getImages().removeAll(oldTag.getImages()); oldTag.getImages().addAll(newTag.getImages()); } }
Source:
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; String name = fFolder.getName(); Label newTaceLabel = new Label(folderGroup, SWT.NONE); newTaceLabel.setFont(font); newTaceLabel.setText(Messages.RenameFolderDialog_FolderNewName); fNewFolderNameText = new Text(folderGroup, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewFolderNameText.setLayoutData(data); fNewFolderNameText.setFont(font); fNewFolderNameText.setFocus(); fNewFolderNameText.setText(name); fNewFolderNameText.setSelection(0, name.length()); fNewFolderNameText.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { validateNewFolderName(); } }); }

Target:
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fFolder.getName(); Label newTaceLabel = new Label(folderGroup, SWT.NONE); newTaceLabel.setFont(font); newTaceLabel.setText(Messages.RenameFolderDialog_FolderNewName); fNewFolderNameText = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewFolderNameText.setLayoutData(data); fNewFolderNameText.setFont(font); fNewFolderNameText.setFocus(); fNewFolderNameText.setText(name); fNewFolderNameText.setSelection(0, name.length()); fNewFolderNameText.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { validateNewFolderName(); } }); }
Source:
public static Object last(Object[] array) { if (array.length == 0) { return null; } return array[array.length - 1]; }

Target:
public static Object last(Object[] array) { if (array.length == 0) { throw new NoSuchElementException("Empty array"); } return array[array.length - 1]; }