auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void configure(HttpSecurity http) throws Exception { super.configure(http); <START> http.addFilterBefore(aadAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); <END> }</code><technical_language>delete AADAuthenticationFilter if want test groupCount</technical_language>

Target:
protected void configure(HttpSecurity http) { http.addFilterBefore(aadAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); }
Source:
<code>private List<String> defaultIncludedModuleNamesForUnnamedModule() { if (fJavaElements != null) { List<IPackageFragmentRoot> roots= new ArrayList<>(); for (IJavaElement <START> fJavaElement : <END> fJavaElements) { if (fJavaElement instanceof IPackageFragmentRoot) { roots.add((IPackageFragmentRoot) fJavaElement); } } return JavaCore.defaultRootModules(roots); } return Collections.emptyList(); }</code><technical_language>rename element</technical_language>

Target:
private List<String> defaultIncludedModuleNamesForUnnamedModule() { if (fJavaElements != null) { List<IPackageFragmentRoot> roots= new ArrayList<>(); for (IJavaElement element : fJavaElements) { if (element instanceof IPackageFragmentRoot) { roots.add((IPackageFragmentRoot) element); } } return JavaCore.defaultRootModules(roots); } return Collections.emptyList(); }
Source:
<code>@Override public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data) { if (data.joiningNodeData() == null) return; ServicesJoinNodeDiscoveryData joinData = (ServicesJoinNodeDiscoveryData)data.joiningNodeData(); for (ServiceInfo desc : joinData.services()) { assert desc.topologySnapshot().isEmpty(); ServiceInfo oldDesc = registeredServices.get(desc.serviceId()); if (oldDesc != null) { U.warn(log, "Failed to register service configuration received from joining node : " + "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "Service with the same service id already exists, cfg=" + oldDesc.configuration()); continue; } oldDesc = lookupInRegisteredServices(desc.name()); if (oldDesc == null) { registeredServices.put(desc.serviceId(), desc); continue; } if (oldDesc.configuration().equalsIgnoreNodeFilter(desc.configuration())) { <START> U.warn(log, "Ignore service configuration received from joining node : " + <END> "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "The same service configuration already registered."); } else { U.warn(log, "Failed to register service configuration received from joining node : " + "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "Service already exists with different configuration, cfg=" + desc.configuration()); } } }</code><technical_language>Log level of this message changed debug. is bad in matching configurations. happen if some nodes services in static configuration. situation cache configurations trigger warnings</technical_language>

Target:
@Override public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data) { if (data.joiningNodeData() == null) return; ServiceProcessorJoinNodeDiscoveryData joinData = (ServiceProcessorJoinNodeDiscoveryData)data.joiningNodeData(); for (ServiceInfo desc : joinData.services()) { assert desc.topologySnapshot().isEmpty(); ServiceInfo oldDesc = registeredServices.get(desc.serviceId()); if (oldDesc != null) { U.warn(log, "Failed to register service configuration received from joining node : " + "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "Service with the same service id already exists, cfg=" + oldDesc.configuration()); continue; } oldDesc = lookupInRegisteredServices(desc.name()); if (oldDesc == null) { registeredServices.put(desc.serviceId(), desc); continue; } if (oldDesc.configuration().equalsIgnoreNodeFilter(desc.configuration())) { if (log.isDebugEnabled()) { log.debug("Ignore service configuration received from joining node : " + "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "The same service configuration already registered."); } } else { U.warn(log, "Failed to register service configuration received from joining node : " + "[nodeId=" + data.joiningNodeId() + ", cfgName=" + desc.name() + "]. " + "Service already exists with different configuration, cfg=" + desc.configuration()); } } }
Source:
<code><START> public Config load(ClassLoader loader, URL url, StrInterpolator strInterpolator, StrInterpolator.Lookup lookup) throws ConfigException { <END> Properties props = new Properties(); URL urlToLoad = url; LinkedList<String> nextUrls = new LinkedList<>(); boolean loaded = false; do { try { Map<String, String> p = new URLConfigReader(urlToLoad).call().getToAdd(); loaded = true; for (Entry<String, String> entry : p.entrySet()) { props.put(entry.getKey(), entry.getValue()); } String next = p.get(includeKey); if (next != null) { nextUrls.addAll(new LinkedList<>(Arrays.asList(next.split(",")))); } } catch (IOException e) { if ( !loaded && nextUrls.isEmpty() ) { throw new ConfigException("Unable to load configuration " + url, e); } } finally { urlToLoad = nextUrls.isEmpty() ? null : getResource(loader, strInterpolator.create(lookup).resolve(nextUrls.remove())); } } while (urlToLoad != null); return new MapConfig(props); }</code><technical_language>is a potential bug files nested @next commands @next in a nested file end of list. recursion here. check for circular @next dependencies well</technical_language>

Target:
public Config load(ClassLoader loader, URL url, StrInterpolator strInterpolator, StrInterpolator.Lookup lookup) throws ConfigException { Properties props = new Properties(); URL urlToLoad = url; LinkedList<String> nextUrls = new LinkedList<>(); Set<String> existingUrls = new HashSet<>(); boolean loaded = false; do { try { Map<String, String> p = new URLConfigReader(urlToLoad).call().getToAdd(); loaded = true; for (Entry<String, String> entry : p.entrySet()) { props.put(entry.getKey(), entry.getValue()); } String next = p.get(includeKey); if (next != null) { String[] listOfAtNext = next.split(","); LinkedList<String> listToAdd = new LinkedList<>(); for (String urlString : listOfAtNext) { String extrapolatedForm = strInterpolator.create(lookup).resolve(urlString); if (!existingUrls.contains(extrapolatedForm)) { existingUrls.add(extrapolatedForm); listToAdd.add(extrapolatedForm); } } listToAdd.addAll(nextUrls); nextUrls = listToAdd; } } catch (IOException e) { if ( !loaded && nextUrls.isEmpty() ) { throw new ConfigException("Unable to load configuration " + url, e); } } finally { urlToLoad = nextUrls.isEmpty() ? null : getResource(loader, nextUrls.remove()); } } while (urlToLoad != null); return new MapConfig(props); }
Source:
<code>public final void setPriority(int newPriority) { ThreadGroup g; checkAccess(); if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) { throw new IllegalArgumentException("Priority out of range: " + newPriority); } if((g = getThreadGroup()) != null) { if (newPriority > g.getMaxPriority()) { newPriority = g.getMaxPriority(); } synchronized(this) { this.priority = newPriority; if (isAlive()) { ThreadPrioritySetter threadPrioritySetter <START> = RuntimeHooks.getThreadPrioritySetter(); <END> if (threadPrioritySetter != null) { threadPrioritySetter.setPriority(newPriority); } else { setPriority0(newPriority); } END Android-added: Customize behavior of Thread.setPriority(). http://b/139521784 } } } }</code><technical_language>style nit: Line is long, please insert a newline "="</technical_language>

Target:
public final void setPriority(int newPriority) { ThreadGroup g; checkAccess(); if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) { throw new IllegalArgumentException("Priority out of range: " + newPriority); } if((g = getThreadGroup()) != null) { if (newPriority > g.getMaxPriority()) { newPriority = g.getMaxPriority(); } synchronized(this) { this.priority = newPriority; if (isAlive()) { ThreadPrioritySetter threadPrioritySetter = RuntimeHooks.getThreadPrioritySetter(); if (threadPrioritySetter != null) { threadPrioritySetter.setPriority(newPriority); } else { setPriority0(newPriority); } END Android-added: Customize behavior of Thread.setPriority(). } } } }
Source:
<code>public static void init(Context context) { <START> if (App.isProFlavor()) { <END> final Crashlytics crashlyticsKit = new Crashlytics.Builder() .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()) .build(); Fabric.with(context, crashlyticsKit); } }</code><technical_language>is this necessary here</technical_language>

Target:
public static void init(Context context) { final Crashlytics crashlyticsKit = new Crashlytics.Builder() .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()) .build(); Fabric.with(context, crashlyticsKit); }
Source:
<code>private static Fragment createFragmentWithResources(String name, String content) { <START> Renderable renderable = (model, l, rl, a) -> content + (model.toMap().isEmpty() ? "" : model.toMap()); <END> return new Fragment(name, renderable, false) { @Override public String render(Model model, Lookup lookup, RequestLookup requestLookup, API api) { requestLookup.addToPlaceholder(Placeholder.css, "CSS Content"); requestLookup.addToPlaceholder(Placeholder.js, "JS Content"); requestLookup.addToPlaceholder(Placeholder.headJs, "Head JS Content"); return content; } }; }</code><technical_language>need create a Renderable override render method of Fragment</technical_language>

Target:
private static Fragment createFragmentWithResources(String name, String content) { return new Fragment(name, null, false) { @Override public String render(Model model, Lookup lookup, RequestLookup requestLookup, API api) { requestLookup.addToPlaceholder(Placeholder.css, "CSS Content"); requestLookup.addToPlaceholder(Placeholder.js, "JS Content"); requestLookup.addToPlaceholder(Placeholder.headJs, "Head JS Content"); return content; } }; }
Source:
<code>private void createControlButtons() { Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); Button okButton = new Button(composite, SWT.PUSH); okButton.setText(resAddressBook.getString("OK")); okButton.addSelectionListener(widgetSelectedAdapter(e -> { <START> shell.close(); <END> })); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText(resAddressBook.getString("Cancel")); cancelButton.addSelectionListener(widgetSelectedAdapter(e -> { values = null; shell.close(); })); shell.setDefaultButton(okButton); }</code><technical_language>Put in line</technical_language>

Target:
private void createControlButtons() { Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); Button okButton = new Button(composite, SWT.PUSH); okButton.setText(resAddressBook.getString("OK")); okButton.addSelectionListener(widgetSelectedAdapter(e -> shell.close())); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText(resAddressBook.getString("Cancel")); cancelButton.addSelectionListener(widgetSelectedAdapter(e -> { values = null; shell.close(); })); shell.setDefaultButton(okButton); }
Source:
<code>public void url() throws Exception { <START> edit(InputType.TEXT, spAddress, URL, new ModelNode("")).andVerifyFailure(); <END> edit(InputType.TEXT, spAddress, URL, new ModelNode(url)).andVerifySuccess(); }</code><technical_language>detect URL empty String, this check undefined value</technical_language>

Target:
public void url() throws Exception { edit(InputType.TEXT, spAddress, URL, "") .verifyFormNotSaved() .verifyAttribute(URL, name.get(Key.URL)); edit(InputType.TEXT, spAddress, URL, url) .verifyFormSaved() .verifyAttribute(URL, url); }
Source:
<code>static public junit.framework.Test suite() { VoltServerConfig config = null; MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestSqlStartsWithRegressionSuite.class); VoltProjectBuilder project = new VoltProjectBuilder(); final String schema = "create table STRINGS (" + "ID int default 0 not null, " + "VAL varchar(32) default null," + "PAT varchar(32) default null," + "PRIMARY KEY(ID));"; try { project.addLiteralSchema(schema); <START> } catch (IOException e) { <END> e.printStackTrace(); } project.addPartitionInfo("STRINGS", "ID"); project.addStmtProcedure("Insert", "insert into strings values (?, ?, ?);"); project.addStmtProcedure("SelectStartsWith", "select * from strings where val starts with ?;"); project.addStmtProcedure("NotStartsWith", "select * from strings where val not starts with ?;"); config = new LocalCluster("sqllike-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI); if (!config.compile(project)) fail(); builder.addServerConfig(config); config = new LocalCluster("sqllike-twosites.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI); if (!config.compile(project)) fail(); builder.addServerConfig(config); config = new LocalCluster("sqllike-twosites.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI); if (!config.compile(project)) fail(); builder.addServerConfig(config); return builder; }</code><technical_language>propagate up</technical_language>

Target:
static public junit.framework.Test suite() throws IOException { VoltServerConfig config = null; MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestSqlStartsWithRegressionSuite.class); VoltProjectBuilder project = new VoltProjectBuilder(); final String schema = "create table STRINGS (" + "ID int default 0 not null, " + "VAL varchar(32) default null," + "PAT varchar(32) default null," + "PRIMARY KEY(ID));"; project.addLiteralSchema(schema); project.addPartitionInfo("STRINGS", "ID"); project.addStmtProcedure("Insert", "insert into strings values (?, ?, ?);"); project.addStmtProcedure("SelectStartsWith", "select * from strings where val starts with ?;"); project.addStmtProcedure("NotStartsWith", "select * from strings where val not starts with ?;"); config = new LocalCluster("sqlstartswith-onesite.jar", 1, 1, 0, BackendTarget.HSQLDB_BACKEND); if (!config.compile(project)) fail(); builder.addServerConfig(config); config = new LocalCluster("sqlstartswith-twosites.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI); if (!config.compile(project)) fail(); builder.addServerConfig(config); config = new LocalCluster("sqlstartswith-twosites.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI); if (!config.compile(project)) fail(); builder.addServerConfig(config); return builder; }
Source:
<code>public void testRemoveSiteWithInvalidOxdId() throws Exception { final DevelopersApi api = Tester.api(); RemoveSiteParams params = new RemoveSiteParams(); final String someRandomId = UUID.randomUUID().toString(); params.setOxdId(someRandomId); ApiResponse<UpdateSiteResponse> removeSiteResponse = api.removeSiteWithHttpInfo(Tester.getAuthorization(), params); <START> assertEquals(removeSiteResponse.getStatusCode(), 200); <END> }</code><technical_language>assert error here? Protocol return error, if case bug here. check legacy test check error code description</technical_language>

Target:
public void testRemoveSiteWithInvalidOxdId() throws Exception { final DevelopersApi api = Tester.api(); RemoveSiteParams params = new RemoveSiteParams(); final String someRandomId = UUID.randomUUID().toString(); params.setOxdId(someRandomId); ApiResponse<RemoveSiteResponse> apiResponse = api.removeSiteWithHttpInfo(Tester.getAuthorization(), params); assertEquals(apiResponse.getStatusCode(), 200); assertTrue("error".equalsIgnoreCase(apiResponse.getData().getStatus())); RemoveSiteResponse removeSiteResponse = apiResponse.getData(); assertNotNull(removeSiteResponse); assertNotNull(removeSiteResponse.getData()); final String error = removeSiteResponse.getData().getError(); assertEquals(error, ErrorResponseCode.INVALID_OXD_ID.getCode()); }
Source:
<code>public void testSwallowedReadComplete() throws Exception { final long delayMillis = 100; final Queue<IdleStateEvent> userEvents = new LinkedBlockingQueue<IdleStateEvent>(); final EmbeddedChannel channel = new EmbeddedChannel(false, false, new FlowControlHandler(), new IdleStateHandler(delayMillis, 0, 0, MILLISECONDS), new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.fireChannelActive(); ctx.read(); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { ctx.fireChannelRead(msg); ctx.read(); } @Override public void channelReadComplete(ChannelHandlerContext ctx) { ctx.fireChannelReadComplete(); ctx.read(); } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { userEvents.add((IdleStateEvent) evt); } ctx.fireUserEventTriggered(evt); } } ); channel.config().setAutoRead(false); assertFalse(channel.config().isAutoRead()); channel.register(); assertTrue(channel.writeInbound(Unpooled.EMPTY_BUFFER)); channel.flushInbound(); assertEquals(Unpooled.EMPTY_BUFFER, channel.readInbound()); channel.flushInbound(); assertNull(channel.readInbound()); Thread.sleep(delayMillis); channel.runPendingTasks(); <START> assertEquals(IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT, userEvents.poll()); <END> }</code><technical_language>nit: call assertFalse(channel.finish());</technical_language>

Target:
public void testSwallowedReadComplete() throws Exception { final long delayMillis = 100; final Queue<IdleStateEvent> userEvents = new LinkedBlockingQueue<IdleStateEvent>(); final EmbeddedChannel channel = new EmbeddedChannel(false, false, new FlowControlHandler(), new IdleStateHandler(delayMillis, 0, 0, MILLISECONDS), new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.fireChannelActive(); ctx.read(); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { ctx.fireChannelRead(msg); ctx.read(); } @Override public void channelReadComplete(ChannelHandlerContext ctx) { ctx.fireChannelReadComplete(); ctx.read(); } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { userEvents.add((IdleStateEvent) evt); } ctx.fireUserEventTriggered(evt); } } ); channel.config().setAutoRead(false); assertFalse(channel.config().isAutoRead()); channel.register(); assertTrue(channel.writeInbound(Unpooled.EMPTY_BUFFER)); channel.flushInbound(); assertEquals(Unpooled.EMPTY_BUFFER, channel.readInbound()); channel.flushInbound(); assertNull(channel.readInbound()); Thread.sleep(delayMillis); channel.runPendingTasks(); assertEquals(IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT, userEvents.poll()); assertFalse(channel.finish()); }
Source:
<code>public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { v = View.inflate(context, R.layout.app_title_view, null); } <START> ApplicationRecord toDisplay = CommCareApplication._().getAppAtIndex(position); <END> TextView appName = (TextView) v.findViewById(R.id.app_name); appName.setText(toDisplay.getDisplayName()); v.setContentDescription(toDisplay.getUniqueId()); return v; }</code><technical_language>tabs misformatted</technical_language>

Target:
public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { v = View.inflate(context, R.layout.app_title_view, null); } ApplicationRecord toDisplay = this.getItem(position); TextView appName = (TextView)v.findViewById(R.id.app_name); appName.setText(toDisplay.getDisplayName()); v.setContentDescription(toDisplay.getUniqueId()); return v; }
Source:
<code>public synchronized CreateIndexResponse createIndex(final String indexName, String settings, int shards) throws ElasticsearchException, IOException { final ReplicasMode replicasMode = clusterAPI.getReplicasMode(); AdminLogger.log(this.getClass(), "createIndex", "Trying to create index: " + indexName + " with shards: " + shards); IndicesAdminClient iac = new ESClient().getClient().admin().indices(); if(shards <1){ try{ shards = Integer.parseInt(System.getProperty("es.index.number_of_shards")); }catch(Exception e){} } if(shards <1){ try{ shards = Config.getIntProperty("es.index.number_of_shards", 2); }catch(Exception e){} } if(shards <0){ shards=1; } if(settings ==null){ settings = getDefaultIndexSettings(shards); } Map map = new ObjectMapper().readValue(settings, LinkedHashMap.class); map.put("number_of_shards", shards); <START> map.put("index.mapping.total_fields.limit", 5000); <END> map.put("number_of_replicas",replicasMode.getNumberOfReplicas()); map.put("auto_expand_replicas",replicasMode.getAutoExpandReplicas()); CreateIndexRequestBuilder cirb = iac.prepareCreate(indexName).setSettings(map); CreateIndexResponse createIndexResponse = cirb.execute().actionGet(); AdminLogger.log(this.getClass(), "createIndex", "Index created: " + indexName + " with shards: " + shards); return createIndexResponse; }</code><technical_language>This read configuration</technical_language>

Target:
public synchronized CreateIndexResponse createIndex(final String indexName, String settings, int shards) throws ElasticsearchException, IOException { final ReplicasMode replicasMode = clusterAPI.getReplicasMode(); AdminLogger.log(this.getClass(), "createIndex", "Trying to create index: " + indexName + " with shards: " + shards); IndicesAdminClient iac = new ESClient().getClient().admin().indices(); if(shards <1){ try{ shards = Integer.parseInt(System.getProperty("es.index.number_of_shards")); }catch(Exception e){} } if(shards <1){ try{ shards = Config.getIntProperty("es.index.number_of_shards", 2); }catch(Exception e){} } if(shards <0){ shards=1; } if(settings ==null){ settings = getDefaultIndexSettings(shards); } Map map = new ObjectMapper().readValue(settings, LinkedHashMap.class); map.put("number_of_shards", shards); map.put("index.mapping.total_fields.limit", Config.getIntProperty("ES_INDEX_MAPPING_TOTAL_FIELD_LIMITS", 5000)); map.put("number_of_replicas",replicasMode.getNumberOfReplicas()); map.put("auto_expand_replicas",replicasMode.getAutoExpandReplicas()); CreateIndexRequestBuilder cirb = iac.prepareCreate(indexName).setSettings(map); CreateIndexResponse createIndexResponse = cirb.execute().actionGet(); AdminLogger.log(this.getClass(), "createIndex", "Index created: " + indexName + " with shards: " + shards); return createIndexResponse; }
Source:
<code>public void testDynamicTaskLoading() throws Exception { String workflowName = TestHelper.getTestMethodName(); TaskDriver driver = new TaskDriver(_manager); JobConfig.Builder job = new JobConfig.Builder(); job.setJobCommandConfigMap(Collections.singletonMap(MockTask.JOB_DELAY, "100")); Workflow.Builder workflow = new Workflow.Builder(workflowName); job.setWorkflow(workflowName); TaskConfig taskConfig = new TaskConfig(MockTask.TASK_COMMAND, new HashMap<String, String>(), null, null); job.addTaskConfigMap(Collections.singletonMap(taskConfig.getId(), taskConfig)); job.setJobId(TaskUtil.getNamespacedJobName(workflowName, "JOB")); workflow.addJob("JOB", job); driver.start(workflow.build()); <START> Thread.sleep(2000); <END> }</code><technical_language>Thanks for PR. Good job ;-) Is functionality of this PR? Do need some sort of assert/statement works</technical_language>

Target:
public void testDynamicTaskLoading() throws Exception { String taskCommand = "Reindex"; String taskJarPath = "src/test/resources/Reindex.jar"; String taskVersion = "1.0.0"; String fullyQualifiedTaskClassName = "com.mycompany.mocktask.MockTask"; String fullyQualifiedTaskFactoryClassName = "com.mycompany.mocktask.MockTaskFactory"; List<String> taskClasses = new ArrayList(); taskClasses.add(fullyQualifiedTaskClassName); DynamicTaskConfig taskConfig = new DynamicTaskConfig(taskCommand, taskJarPath, taskVersion, taskClasses, fullyQualifiedTaskFactoryClassName); String path = TaskConstants.DYNAMICALLY_LOADED_TASK_PATH + "/" + taskCommand; removePathIfExists(path); _manager.getHelixDataAccessor().getBaseDataAccessor() .create(path, taskConfig.getTaskConfigZNRecord(), AccessOption.PERSISTENT); TaskDriver driver = new TaskDriver(_manager); String workflowName = TestHelper.getTestMethodName(); submitWorkflow(workflowName, driver); TaskState finalState = driver.pollForWorkflowState(workflowName, TaskState.COMPLETED, TaskState.FAILED); Assert.assertEquals(finalState, TaskState.COMPLETED); }
Source:
<code>public Enchantment.Builder from(final Enchantment value) { this.enchantmentType = value.getType(); <START> this.level = value.getLevel(); <END> return this; }</code><technical_language>Needs a null check</technical_language>

Target:
public Enchantment.Builder from(final Enchantment value) { checkNotNull(value, "The enchantment to create a builder from cannot be null!"); this.enchantmentType = value.getType(); this.level = value.getLevel(); return this; }
Source:
<code>public BugzillaRestConfiguration getRepositoryConfiguration(TaskRepository repository) throws CoreException { if (clientCache.getIfPresent(new RepositoryKey(repository)) == null) { getClient(repository); } try { return configurationCache.get(new RepositoryKey(repository)); } catch (UncheckedExecutionException e) { if (!e.getMessage().startsWith( <START> "com.google.common.cache.CacheLoader$InvalidCacheLoadException: CacheLoader returned null for key")) { <END> throw new CoreException(new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, e.getMessage(), e)); } else { return null; } } catch (ExecutionException e) { if (!e.getMessage().startsWith("CacheLoader returned null for key")) { throw new CoreException(new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, e.getMessage(), e)); } } return null; }</code><technical_language>need find a do this. suggestion throwing a more specific exception in load. work</technical_language>

Target:
public BugzillaRestConfiguration getRepositoryConfiguration(TaskRepository repository) throws CoreException { if (clientCache.getIfPresent(new RepositoryKey(repository)) == null) { getClient(repository); } try { Optional<BugzillaRestConfiguration> configurationOptional = configurationCache.get(new RepositoryKey( repository)); return configurationOptional.isPresent() ? configurationOptional.get() : null; } catch (UncheckedExecutionException e) { throw new CoreException(new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, e.getMessage(), e)); } catch (ExecutionException e) { throw new CoreException(new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, e.getMessage(), e)); } }
Source:
<code>public Tool getExecutable() { for (Tool t : Tool.EMULATORS) { <START> if (t.getExecutable(true).equals(executable)) { <END> return t; } } return Tool.EMULATOR; }</code><technical_language>I imagine this !Functions.isWindows(), hardcoded true</technical_language>

Target:
public Tool getExecutable() { for (Tool t : Tool.EMULATORS) { if (t.executable.equals(executable)) { return t; } } return Tool.EMULATOR; }
Source:
<code>public Blob convertBlobToPDF(Blob blob) throws IOException { String mimetype = blob.getMimeType(); if (MimetypeRegistry.PDF_MIMETYPE.equals(mimetype)) { return blob; } Blob result; if (MediaType.TEXT_PLAIN.equals(mimetype)) { result = convertBlobToMimeType(blob, MimetypeRegistry.PDF_MIMETYPE); } else { if (!MediaType.TEXT_HTML.equals(mimetype)) { String filename = blob.getFilename(); blob = convertBlobToMimeType(blob, MediaType.TEXT_HTML); blob.setFilename(filename); } Path tempDirectory = Framework.createTempDirectory("blobs"); DownloadService downloadService = Framework.getService(DownloadService.class); blob = replaceURLsByAbsolutePaths(blob, tempDirectory, downloadService::resolveBlobFromDownloadUrl); result = convertBlobToMimeType(blob, MimetypeRegistry.PDF_MIMETYPE); <START> org.apache.commons.io.FileUtils.deleteQuietly(tempDirectory.toFile()); <END> } if (result != null) { adjustPDFBlobName(blob, result); } return result; }</code><technical_language>Put deleteQuietly in a finally block, try creation of temp directory</technical_language>

Target:
public Blob convertBlobToPDF(Blob blob) throws IOException { String mimetype = blob.getMimeType(); String filename = blob.getFilename(); if (MimetypeRegistry.PDF_MIMETYPE.equals(mimetype)) { return blob; } Blob result; if (MediaType.TEXT_PLAIN.equals(mimetype)) { result = convertBlobToMimeType(blob, MimetypeRegistry.PDF_MIMETYPE); } else { if (!MediaType.TEXT_HTML.equals(mimetype)) { blob = convertBlobToMimeType(blob, MediaType.TEXT_HTML); blob.setFilename(filename); } Path tempDirectory = Framework.createTempDirectory("blobs"); try { DownloadService downloadService = Framework.getService(DownloadService.class); blob = replaceURLsByAbsolutePaths(blob, tempDirectory, downloadService::resolveBlobFromDownloadUrl); result = convertBlobToMimeType(blob, MimetypeRegistry.PDF_MIMETYPE); } finally { org.apache.commons.io.FileUtils.deleteQuietly(tempDirectory.toFile()); } } if (result != null) { adjustPDFBlobName(filename, result); } return result; }
Source:
<code>public V put(@NonNull K key, @NonNull V value) { map.put(key, new Entry<>(key, value, ++time)); <START> if (map.size() >= maximumSize) { <END> purge(); } return value; }</code><technical_language>For a small maximuSize, 1, more reasonable check for: map.size() > maximumSize</technical_language>

Target:
public V put(@NonNull K key, @NonNull V value) { map.put(key, new Entry<>(key, value, ++time)); if (map.size() > maximumSize) { purge(); } return value; }
Source:
<code>public static List<Stereotype> findSubstereotypes(Element umlElement, String stereotypeName) { if (umlElement == null || stereotypeName == null) { return null; } Set<Stereotype> stereotypes = new HashSet<>(); org.eclipse.uml2.uml.Package umlPackage = umlElement.getNearestPackage(); if (umlPackage == null) { Stereotype stereotype = umlElement.getApplicableStereotype(stereotypeName); if (stereotype != null) { stereotypes.add(stereotype); } } else { for (Profile profile : umlPackage.getAllAppliedProfiles()) { Set<Stereotype> ownedStereotypes = getAllStereotypes(profile); for (Stereotype ownedStereotype : ownedStereotypes) { for (Stereotype superStereotype : getAllSuperStereotypes(ownedStereotype)) { if (stereotypeName.equals(superStereotype.getQualifiedName())) { stereotypes.add(ownedStereotype); } } } } } return new <START> LinkedList<>(stereotypes); <END> }</code><technical_language>type of list/map, ... removed</technical_language>

Target:
public static List<Stereotype> findSubstereotypes(Element umlElement, String stereotypeName) { if (umlElement == null || stereotypeName == null) { return null; } Set<Stereotype> stereotypes = new HashSet<>(); org.eclipse.uml2.uml.Package umlPackage = umlElement.getNearestPackage(); if (umlPackage == null) { Stereotype stereotype = umlElement.getApplicableStereotype(stereotypeName); if (stereotype != null) { stereotypes.add(stereotype); } } else { for (Profile profile : umlPackage.getAllAppliedProfiles()) { Set<Stereotype> ownedStereotypes = getAllStereotypes(profile); for (Stereotype ownedStereotype : ownedStereotypes) { for (Stereotype superStereotype : getAllSuperStereotypes(ownedStereotype)) { if (stereotypeName.equals(superStereotype.getQualifiedName())) { stereotypes.add(ownedStereotype); } } } } } return new LinkedList<Stereotype>(stereotypes); }
Source:
<code>protected void startGravatarUpload(final String filePath) { if (!TextUtils.isEmpty(filePath)) { final File file = new File(filePath); if (file.exists()) { startProgress(); GravatarApi.uploadGravatar(file, mAccountStore.getAccount().getEmail(), mAccountStore.getAccessToken(), new GravatarApi.GravatarUploadListener() { @Override public void onSuccess() { endProgress(); mPhotoUrl = GravatarUtils.fixGravatarUrl(mAccount.getAccount().getAvatarUrl(), <START> getResources().getDimensionPixelSize(R.dimen.avatar_sz_login_epilogue)); <END> loadAvatar(mPhotoUrl, filePath); mHeaderAvatarAdd.setVisibility(View.GONE); mIsAvatarAdded = true; } @Override public void onError() { endProgress(); showErrorDialogAvatar(); AppLog.e(T.NUX, "Uploading image to Gravatar failed"); } }); } else { ToastUtils.showToast(getActivity(), R.string.error_locating_image, ToastUtils.Duration.SHORT); } } else { ToastUtils.showToast(getActivity(), R.string.error_locating_image, ToastUtils.Duration.SHORT); } }</code><technical_language>Good call incorporating injectCache() track @theck13 , I new image immediately epilogue setting it. a thingie: turns out injected image response is for a URL is slightly URL loaded in MeFragment epilogue is dimissed, annoyance screen load injected avatar. Problem size parameter is screens. do handling this issue in this PR</technical_language>

Target:
protected void startGravatarUpload(final String filePath) { if (!TextUtils.isEmpty(filePath)) { final File file = new File(filePath); if (file.exists()) { startProgress(); GravatarApi.uploadGravatar(file, mAccountStore.getAccount().getEmail(), mAccountStore.getAccessToken(), new GravatarApi.GravatarUploadListener() { @Override public void onSuccess() { endProgress(); mPhotoUrl = GravatarUtils.fixGravatarUrl(mAccount.getAccount().getAvatarUrl(), getResources().getDimensionPixelSize(R.dimen.avatar_sz_large)); loadAvatar(mPhotoUrl, filePath); mHeaderAvatarAdd.setVisibility(View.GONE); mIsAvatarAdded = true; } @Override public void onError() { endProgress(); showErrorDialogAvatar(); AppLog.e(T.NUX, "Uploading image to Gravatar failed"); } }); } else { ToastUtils.showToast(getActivity(), R.string.error_locating_image, ToastUtils.Duration.SHORT); } } else { ToastUtils.showToast(getActivity(), R.string.error_locating_image, ToastUtils.Duration.SHORT); } }
Source:
<code>public void testEvent() { EventGateway gateway = new EventGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); <START> Node<View<BaseGateway>, ?> node = mockNode(UUID, gateway); <END> when(propertyWriterFactory.of(any(org.eclipse.bpmn2.EventBasedGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); }</code><technical_language>need mock</technical_language>

Target:
public void testEvent() { EventGateway gateway = new EventGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.EventBasedGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); }
Source:
<code>protected void executeQueryCommand() { if (!isSystemSuperUser()) { <START> getQueryReturnValue().setReturnValue(getDbFacade().getRoleDao().getAllNonAdmin()); <END> } else { getQueryReturnValue().setReturnValue(getDbFacade().getRoleDao().getAll()); } }</code><technical_language>please 'setReturnValue(..)' instead</technical_language>

Target:
protected void executeQueryCommand() { if (!isAdminUser()) { setReturnValue(getDbFacade().getRoleDao().getAllNonAdmin()); } else { setReturnValue(getDbFacade().getRoleDao().getAll()); } }
Source:
<code>private Collection<IdAttrs> getIdAttrsList( Collection<? extends Entity> other) { Collection<IdAttrs> idAttrsList = Lists.newArrayList(); for (Entity en : other) { if (Strings.isNullOrEmpty(en.getIdentity())) { IdAttrs at = new IdAttrs(); <START> en.populateIdAttrs(at); <END> idAttrsList.add(at); } } return idAttrsList; }</code><technical_language>a static method combine constructor call population a single call</technical_language>

Target:
private Collection<Map<String, String>> getIdAttrsList( Collection<? extends Entity> other) { Collection<Map<String, String>> idAttrsList = Lists.newArrayList(); for (Entity en : other) { if (Strings.isNullOrEmpty(en.getIdentity())) { idAttrsList.add(en.getIdAttrsMap()); } } return idAttrsList; }
Source:
<code>public void afterSuccessObserverIsNotNotifiedAfterTxRollBack() throws SystemException { ActionSequence.reset(); ejbTestBean.initTransaction(); <START> Assert.assertFalse(ActionSequence.getSequenceData().isEmpty()); <END> Assert.assertFalse(ActionSequence.getSequenceData().contains(TransactionPhase.AFTER_SUCCESS.toString())); }</code><technical_language>compare sequence data</technical_language>

Target:
public void afterSuccessObserverIsNotNotifiedAfterTxRollBack() throws SystemException { reset(); ejbTestBean.initTransaction(); assertSequenceDataContainsAll( Arrays.asList(TransactionPhase.IN_PROGRESS.toString(), TransactionPhase.BEFORE_COMPLETION.toString(), TransactionPhase.AFTER_COMPLETION.toString(), TransactionPhase.AFTER_FAILURE.toString())); assertTrue(getSequenceData().indexOf(TransactionPhase.BEFORE_COMPLETION.toString()) < getSequenceData() .indexOf(TransactionPhase.AFTER_COMPLETION.toString())); assertFalse(getSequenceData().contains(TransactionPhase.AFTER_SUCCESS.toString())); }
Source:
<code>public void testAssociationLnListTypeMappingWithEmptyLists() { final List<AssociationLnListElement> associationLnListElement = new ArrayList<>(); final AssociationLnListType associationLnListType = new AssociationLnListTypeBuilder() .withEmptyLists(associationLnListElement).build(); final AssociationLnListTypeDto associationLnListTypeDto = this.mapperFactory.getMapperFacade() .map(associationLnListType, AssociationLnListTypeDto.class); this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement()); <START> assertNotNull(associationLnListTypeDto); <END> }</code><technical_language>If this check for null is needed desirable, previous statement. is now, if associationLnListTypeDto == null this line reached a NullPointerException thrown</technical_language>

Target:
public void testAssociationLnListTypeMappingWithEmptyLists() { final AssociationLnListType associationLnListType = new AssociationLnListTypeBuilder().withEmptyLists().build(); final AssociationLnListTypeDto associationLnListTypeDto = this.configurationMapper.map(associationLnListType, AssociationLnListTypeDto.class); assertNotNull(associationLnListTypeDto); this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement()); }
Source:
<code>private PatchSet getBasePatchSet(Change change, Ref ref) throws IOException, InvalidChangeOperationException { try { int pos = ref.getName().lastIndexOf("/"); String psId = <START> ref.getName().substring(++pos); <END> return db.get().patchSets().get(new PatchSet.Id( change.getId(), Integer.valueOf(psId))); } catch (OrmException e) { throw new IOException(e); } }</code><technical_language>pos + 1, depending side effect</technical_language>

Target:
private PatchSet getBasePatchSet(Change change, Ref ref) throws IOException, InvalidChangeOperationException { try { int pos = ref.getName().lastIndexOf("/"); String psId = ref.getName().substring(pos + 1); return db.get().patchSets().get(new PatchSet.Id( change.getId(), Integer.valueOf(psId))); } catch (OrmException e) { throw new IOException(e); } }
Source:
<code>private static ProviderParameters providerParametersMock(Class<?>... testClasses) { TestsToRun testsToRun = newTestsToRun(testClasses); ScanResult scanResult = mock(ScanResult.class); when(scanResult.applyFilter(any(), any())).thenReturn(testsToRun); RunOrderCalculator runOrderCalculator = mock(RunOrderCalculator.class); when(runOrderCalculator.orderTestClasses(any())).thenReturn(testsToRun); ReporterFactory reporterFactory = mock(ReporterFactory.class); <START> RunListener runListener = mock(ForkingRunListener.class); <END> when(reporterFactory.createReporter()).thenReturn(runListener); ProviderParameters providerParameters = mock(ProviderParameters.class); when(providerParameters.getScanResult()).thenReturn(scanResult); when(providerParameters.getRunOrderCalculator()).thenReturn(runOrderCalculator); when(providerParameters.getReporterFactory()).thenReturn(reporterFactory); return providerParameters; }</code><technical_language>I mock(RunListener.class, withSettings().extraInterfaces(ConsoleOutputReceiver.class)) a lot of RunListener implementations in Surefire</technical_language>

Target:
private static ProviderParameters providerParametersMock(Class<?>... testClasses) { TestsToRun testsToRun = newTestsToRun(testClasses); ScanResult scanResult = mock(ScanResult.class); when(scanResult.applyFilter(any(), any())).thenReturn(testsToRun); RunOrderCalculator runOrderCalculator = mock(RunOrderCalculator.class); when(runOrderCalculator.orderTestClasses(any())).thenReturn(testsToRun); ReporterFactory reporterFactory = mock(ReporterFactory.class); RunListener runListener = mock(ForkingRunListener.class, withSettings().extraInterfaces(ConsoleOutputReceiver.class)); when(reporterFactory.createReporter()).thenReturn(runListener); ProviderParameters providerParameters = mock(ProviderParameters.class); when(providerParameters.getScanResult()).thenReturn(scanResult); when(providerParameters.getRunOrderCalculator()).thenReturn(runOrderCalculator); when(providerParameters.getReporterFactory()).thenReturn(reporterFactory); return providerParameters; }
Source:
<code>private static boolean responseOk(final int status) { switch (status) { <START> case HttpStatus.SC_CREATED: <END> case HttpStatus.SC_OK: return true; default: return false; } }</code><technical_language>Is relevant maybbe rewrite this status / 100 == 2 trick, in <LINK_0></technical_language>

Target:
private static boolean responseOk(final int status) { return status / 100 == 2; }
Source:
<code>private void startClient() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, UnknownHostException { if (client == null) { LOG.info("Connecting to the ElasticSearch cluster: " + configuration.getClusterName()); if (configuration.getHostAddressesList() != null && !configuration.getHostAddressesList().isEmpty()) { client = createClient(); } else { <START> LOG.info("Incorrect ip address and port parameters settings for ElasticSearch cluster"); <END> } } }</code><technical_language>this WARN some exception thrown? Instead of logging ip is incorrect. this validation done in doStart method validated earlier</technical_language>

Target:
private void startClient() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, UnknownHostException { if (client == null) { LOG.info("Connecting to the ElasticSearch cluster: " + configuration.getClusterName()); if (configuration.getHostAddressesList() != null && !configuration.getHostAddressesList().isEmpty()) { client = createClient(); } else { LOG.warn("Incorrect ip address and port parameters settings for ElasticSearch cluster"); } } }
Source:
<code>RevCommit next() throws MissingObjectException, IncorrectObjectTypeException, IOException { for (;;) { <START> final RevCommit <END> c = pending.next(); if (c == null) return null; if (c.inDegree > 0) { continue; } if ((c.flags & TOPO_QUEUED) == 0) { continue; } for (RevCommit p : c.parents) { if (--p.inDegree == 0 && (p.flags & TOPO_QUEUED) != 0) { pending.unpop(p); } if (firstParent) { break; } } c.flags &= ~TOPO_QUEUED; return c; } }</code><technical_language>Optional: update coding style, removing this "final" adding brackets "if" below</technical_language>

Target:
RevCommit next() throws MissingObjectException, IncorrectObjectTypeException, IOException { for (;;) { final RevCommit c = pending.next(); if (c == null) return null; if (c.inDegree > 0) { continue; } if ((c.flags & TOPO_QUEUED) == 0) { continue; } for (RevCommit p : c.parents) { if ((c.flags & UNINTERESTING) == 0) { p.inDegree--; } if (p.inDegree == 0 && (p.flags & TOPO_QUEUED) != 0) { pending.unpop(p); } if (firstParent) { break; } } c.flags &= ~TOPO_QUEUED; return c; } }
Source:
<code>protected List<PacketHandler> getHandlers() { <START> synchronized (this.handlers) { <END> return this.handlers; } }</code><technical_language>need for synchronized</technical_language>

Target:
protected List<PacketHandler> getHandlers() { return this.handlers; }
Source:
<code><START> public long getSendCount() { <END> return sendCount.get(); }</code><technical_language>breaking changes this in a point release (cherry-picks). I choice add methods getSendCountAsLong(). sense retain int versions for users need long precision</technical_language>

Target:
public int getSendCount() { return (int) sendCount.get(); }
Source:
<code>public static void takeScreenshotOfElement(IElement element, File toSaveAs) throws IOException, WidgetException { for(int i = 0; i < 10; i++) { log.info("Taking screen shot of locator " + element.getLocator() + " ... attempt #" + (i+1)); element.scrollTo(); <START> <END> WebDriver wd = SessionManager.getInstance().getCurrentSession().getWrappedDriver(); File screenshot; boolean isRemote = false; if(!(wd instanceof RemoteWebDriver)) { screenshot = ((TakesScreenshot) wd).getScreenshotAs(OutputType.FILE); } else { Augmenter augmenter = new Augmenter(); screenshot = ((TakesScreenshot) augmenter.augment(wd)).getScreenshotAs(OutputType.FILE); isRemote = true; } BufferedImage fullImage = ImageIO.read(screenshot); element.waitForElementPresent(); WebElement ele = element.getWebElement(); Point point = ele.getLocation(); int eleWidth = ele.getSize().getWidth(); int eleHeight = ele.getSize().getHeight(); int x; int y; if(isRemote) { x = ((Locatable)ele).getCoordinates().inViewPort().getX(); y = ((Locatable)ele).getCoordinates().inViewPort().getY(); } else { x = point.getX(); y = point.getY(); } log.debug("Screenshot coordinates x: "+x+", y: "+y); BufferedImage eleScreenshot = fullImage.getSubimage(x, y, eleWidth, eleHeight); ImageIO.write(eleScreenshot, "png", screenshot); if(!isBlack(ImageIO.read(screenshot))) { FileUtils.copyFile(screenshot, toSaveAs); break; } } }</code><technical_language>this affect of conditionals in before? Is reason this statement moved</technical_language>

Target:
public static void takeScreenshotOfElement(IElement element, File toSaveAs) throws IOException, WidgetException { for(int i = 0; i < 10; i++) { log.info("Taking screen shot of locator " + element.getLocator() + " ... attempt #" + (i+1)); element.scrollTo(); WebDriver wd = SessionManager.getInstance().getCurrentSession().getWrappedDriver(); File screenshot; boolean isRemote = false; if(!(wd instanceof RemoteWebDriver)) { screenshot = ((TakesScreenshot) wd).getScreenshotAs(OutputType.FILE); } else { Augmenter augmenter = new Augmenter(); screenshot = ((TakesScreenshot) augmenter.augment(wd)).getScreenshotAs(OutputType.FILE); isRemote = true; } BufferedImage fullImage = ImageIO.read(screenshot); WebElement ele = element.getWebElement(); Point point = ele.getLocation(); int eleWidth = ele.getSize().getWidth(); int eleHeight = ele.getSize().getHeight(); int x; int y; if(isRemote) { x = ((Locatable)ele).getCoordinates().inViewPort().getX(); y = ((Locatable)ele).getCoordinates().inViewPort().getY(); } else { x = point.getX(); y = point.getY(); } log.debug("Screenshot coordinates x: "+x+", y: "+y); BufferedImage eleScreenshot = fullImage.getSubimage(x, y, eleWidth, eleHeight); ImageIO.write(eleScreenshot, "png", screenshot); if(!isBlack(ImageIO.read(screenshot))) { FileUtils.copyFile(screenshot, toSaveAs); break; } } }