auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void executeCommand(ChannelHandlerContext ctx, Command command) throws Exception { RedisResponse response; if (!isAuthenticated()) { response = handleUnAuthenticatedCommand(command); writeToChannel(response); return; } <START> if (command.isOfType(RedisCommandType.SELECT) <END> || command.isOfType(RedisCommandType.CONFIG) || command.isOfType(RedisCommandType.PUBSUB)) { writeToChannel(RedisResponse.ok()); return; } if (command.isUnsupported() && !allowUnsupportedCommands()) { writeToChannel( RedisResponse.error(command.getCommandType() + RedisConstants.ERROR_UNSUPPORTED_COMMAND)); return; } if (command.isUnimplemented()) { logger.info("Failed " + command.getCommandType() + " because it is not implemented."); writeToChannel(RedisResponse.error(command.getCommandType() + " is not implemented.")); return; } response = command.execute(this); logResponse(response); writeToChannel(response); if (command.isOfType(RedisCommandType.QUIT)) { channelInactive(ctx); } }</code><technical_language>I understand this code added. commands unimplemented list. this added this PR accident</technical_language>

Target:
private void executeCommand(ChannelHandlerContext ctx, Command command) throws Exception { RedisResponse response; if (!isAuthenticated()) { response = handleUnAuthenticatedCommand(command); writeToChannel(response); return; } if (command.isUnsupported() && !allowUnsupportedCommands()) { writeToChannel( RedisResponse.error(command.getCommandType() + RedisConstants.ERROR_UNSUPPORTED_COMMAND)); return; } if (command.isUnimplemented()) { logger.info("Failed " + command.getCommandType() + " because it is not implemented."); writeToChannel(RedisResponse.error(command.getCommandType() + " is not implemented.")); return; } response = command.execute(this); logResponse(response); writeToChannel(response); if (command.isOfType(RedisCommandType.QUIT)) { channelInactive(ctx); } }
Source:
<code><START> public List<User> call(ApiCaller ac, Deserializer parms) throws PerunException { <END> ac.stateChangingCheck(); return ac.getSearcher().getFacilities(ac.getSession(), parms.read("attributesWithSearchingValues", LinkedHashMap.class)); }</code><technical_language>List<User> -> List<Facility></technical_language>

Target:
public List<User> call(ApiCaller ac, Deserializer parms) throws PerunException { ac.stateChangingCheck(); return ac.getSearcher().getUsers(ac.getSession(), parms.read("attributesWithSearchingValues", LinkedHashMap.class)); }
Source:
<code>public Query toQuery( final Set<ValueIndexTerm> terms ) { checkNotNullAndNotEmpty(terms); ValuePackageNameIndexTerm packageTerm = null; ValueProjectRootPathIndexTerm projectTerm = null; ValueResourceIndexTerm ruleTerm = null; for( ValueIndexTerm term : terms ) { if( term instanceof ValuePackageNameIndexTerm ) { packageTerm = (ValuePackageNameIndexTerm) term; } else if ( term instanceof ValueProjectRootPathIndexTerm ) { projectTerm = (ValueProjectRootPathIndexTerm) term; } else if ( term instanceof ValueResourceIndexTerm ) { ruleTerm = (ValueResourceIndexTerm) term; } } SearchEmptyQueryBuilder queryBuilder = new SearchEmptyQueryBuilder() .addTerm( packageTerm ) .addTerm( projectTerm ); if( ruleTerm != null ) { queryBuilder.addTerm(ruleTerm); } else { queryBuilder.addRuleNameWildCardTerm(); } Query build = queryBuilder.build(); <START> String s = build.toString(); <END> return build; }</code><technical_language>Debugging!?</technical_language>

Target:
public Query toQuery( final Set<ValueIndexTerm> terms ) { checkNotNullAndNotEmpty(terms); ValuePackageNameIndexTerm packageTerm = null; ValueProjectRootPathIndexTerm projectTerm = null; ValueResourceIndexTerm ruleTerm = null; for( ValueIndexTerm term : terms ) { if( term instanceof ValuePackageNameIndexTerm ) { packageTerm = (ValuePackageNameIndexTerm) term; } else if ( term instanceof ValueProjectRootPathIndexTerm ) { projectTerm = (ValueProjectRootPathIndexTerm) term; } else if ( term instanceof ValueResourceIndexTerm ) { ruleTerm = (ValueResourceIndexTerm) term; } } SearchEmptyQueryBuilder queryBuilder = new SearchEmptyQueryBuilder() .addTerm( packageTerm ) .addTerm( projectTerm ); if( ruleTerm != null ) { queryBuilder.addTerm(ruleTerm); } else { queryBuilder.addRuleNameWildCardTerm(); } return queryBuilder.build(); }
Source:
<code>public void setPorts(List<PortMapping> ports) { <START> this.ports.addAll(ports); <END> }</code><technical_language>this.ports null</technical_language>

Target:
public void setPorts(List<PortMapping> ports) { if (ports != null) { this.ports.addAll(ports); } }
Source:
<code>@Test public void missingConnectionHeader() throws IOException { webServer.enqueue(new MockResponse() .setResponseCode(101) .setHeader("Upgrade", "websocket") .setHeader("Sec-WebSocket-Accept", "ujmZX4KXZqjwy6vi1aQFH5p4Ygk=")); newWebSocket(); clientListener.assertFailure(101, null, ProtocolException.class, "Expected 'Connection' header value 'Upgrade' but was 'null'"); <START> client.connectionPool().evictAll(); <END> assertEquals(0, client.connectionPool().connectionCount()); }</code><technical_language>nit: TestUtil.ensureAllConnectionsReleased()</technical_language>

Target:
@Test public void missingConnectionHeader() throws IOException { webServer.enqueue(new MockResponse() .setResponseCode(101) .setHeader("Upgrade", "websocket") .setHeader("Sec-WebSocket-Accept", "ujmZX4KXZqjwy6vi1aQFH5p4Ygk=")); newWebSocket(); clientListener.assertFailure(101, null, ProtocolException.class, "Expected 'Connection' header value 'Upgrade' but was 'null'"); ensureAllConnectionsReleased(client); }
Source:
<code>public void searchRelatedPersonByIdentifier_shouldReturnResourceIfExists() { List<RelatedPerson> relatedPersonList = getService().searchRelatedPersonByIdentifier(PATIENT_IDENTIFIER); assertEquals(relatedPersonList.size(), 3); <START> assertNotNull(relatedPersonList); <END> assertEquals(relatedPersonList.get(0).getGender().getDisplay(), "Male"); assertEquals(relatedPersonList.get(0).getId(), "b70cb368-cf80-4a22-9d75-5d0d1f9b75dc"); assertEquals(relatedPersonList.get(0).getPatient().getReference(), "person/ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562"); assertEquals(relatedPersonList.get(1).getGender().getDisplay(), "Male"); assertEquals(relatedPersonList.get(1).getId(), "c18717dd-5d78-4a0e-84fc-ee62c5f0676a"); assertEquals(relatedPersonList.get(0).getPatient().getReference(), "person/ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562"); assertEquals(relatedPersonList.get(2).getGender().getDisplay(), "Male"); assertEquals(relatedPersonList.get(2).getId(), "ee232368-cf80-4a22-9d75-5d0d9dce"); }</code><technical_language>Is assertNotNull adding previous assertion</technical_language>

Target:
public void searchRelatedPersonByIdentifier_shouldReturnResourceIfExists() { List<RelatedPerson> relatedPersonList = getService().searchRelatedPersonByIdentifier(PATIENT_IDENTIFIER); assertEquals(relatedPersonList.size(), 3); assertEquals(relatedPersonList.get(0).getGender().getDisplay(), "Male"); assertEquals(relatedPersonList.get(0).getId(), "b70cb368-cf80-4a22-9d75-5d0d1f9b75dc"); assertEquals(relatedPersonList.get(0).getPatient().getReference(), "person/ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562"); }
Source:
<code><START> public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() { <END> when(message.getReplyTo()).thenReturn(replyToAddresses); when(message.getListPost()).thenReturn(listPostAddresses); when(message.getFrom()).thenReturn(fromAddresses); assertSame(replyToAddresses, ReplyToParser.getRecipientsToReplyTo(message)); }</code><technical_language>Again, 'arrange, act, assert' separated empty lines nice</technical_language>

Target:
public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() throws MessagingException { when(message.getReplyTo()).thenReturn(replyToAddresses); when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[]{listPostHeaderValue}); when(message.getFrom()).thenReturn(fromAddresses); assertSame(replyToAddresses, ReplyToParser.getRecipientsToReplyTo(message)); }
Source:
<code>private RestClient getRestClient(String uri, Map<String, String> httpConfig) { uri = RestliUtils.sanitizeUri(uri); RestClient restClient; String key = getKey(uri, httpConfig); <START> restClient = _restClients.getOrDefault(key, null); <END> if (restClient == null) { restClient = new RestClient(new TransportClientAdapter(CLIENT_FACTORY.getClient(httpConfig)), uri); _restClients.put(key, restClient); } return restClient; }</code><technical_language>nit: Map::computeIfAbsent</technical_language>

Target:
private RestClient getRestClient(String uri, Map<String, String> httpConfig) { String canonicalUri = RestliUtils.sanitizeUri(uri); RestClient restClient; String key = getKey(uri, httpConfig); restClient = _restClients.computeIfAbsent(key, (k) -> new RestClient(new TransportClientAdapter(CLIENT_FACTORY.getClient(httpConfig)), canonicalUri)); return restClient; }
Source:
<code>void decorate(JCheckBox pullBeforeField, JLabel pullBeforeOverrideLabel, JComboBox pullBeforeOverrideField, JTextPane textpanel) { <START> pullBeforeField.setText(savePasswordsConsent ? "Pull before export" : "Pull before export (Requires Remember passwords in Settings)"); <END> pullBeforeField.setVisible(!isOverridePanel); pullBeforeField.setEnabled(savePasswordsConsent && hasTransferSettings); pullBeforeOverrideLabel.setVisible(isOverridePanel); pullBeforeOverrideField.setVisible(isOverridePanel); pullBeforeOverrideField.setEnabled(savePasswordsConsent && hasTransferSettings); textpanel.setVisible(isOverridePanel && (!savePasswordsConsent || !hasTransferSettings)); textpanel.setText(!savePasswordsConsent ? "You can't pull before exporting forms until you give your consent to store passwords on the Settings panel" : !hasTransferSettings ? "Please, pull this form once again to be able to check these checkboxes" : ""); }</code><technical_language>I simply praise this bit of dynamic text (praise!, praise!), I a suggestion: pullBeforeField.setText("Pull export" + (savePasswordsConsent ? "" : " (Requires Remember passwords in Settings)"));</technical_language>

Target:
void decorate(JCheckBox pullBeforeField, JLabel pullBeforeOverrideLabel, JComboBox pullBeforeOverrideField, JTextPane textpanel) { pullBeforeField.setVisible(!isOverridePanel); pullBeforeField.setEnabled(savePasswordsConsent && (!isOverridePanel || hasTransferSettings)); pullBeforeOverrideLabel.setVisible(isOverridePanel); pullBeforeOverrideField.setVisible(isOverridePanel); pullBeforeOverrideField.setEnabled(savePasswordsConsent && hasTransferSettings); textpanel.setVisible(!savePasswordsConsent || !hasTransferSettings || !isOverridePanel); textpanel.setText(savePasswordsConsent ? hasTransferSettings && isOverridePanel ? "" : REQUIRE_PULL_TEXT : REQUIRE_SAVE_PASSWORDS ); }
Source:
<code>public void testFilterVariableToSelectModelElementVariableMigration() { copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, REPRESENTATIONS_FILE_PATH, MODELER_FILE_NAME); ResourceSet set = new ResourceSetImpl(); Group group = null; try { group = (Group) ModelUtils.load(URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + "/" + MODELER_FILE_NAME, true), set); } catch (IOException e) { e.printStackTrace(); } assertNotNull("Group is not retrieved.", group); String version = group.getVersion(); assertTrue("Before save, the migration framework will return true even if the migration has been done during load.", VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version))); try { group.eResource().save(Collections.emptyMap()); } catch (IOException e) { <START> e.printStackTrace(); <END> } version = group.getVersion(); assertFalse("The version tag should now be set telling that the migration was done.", VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version))); checkVSMMigrationEffect(group); }</code><technical_language>Bad, printStackTrace in test</technical_language>

Target:
public void testFilterVariableToSelectModelElementVariableMigration() { copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, REPRESENTATIONS_FILE_PATH, MODELER_FILE_NAME); ResourceSet set = new ResourceSetImpl(); Group group = null; try { group = (Group) ModelUtils.load(URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + "/" + MODELER_FILE_NAME, true), set); } catch (IOException e) { fail("Pb when loading the resource : " + e.getMessage()); } assertNotNull("Group is not retrieved.", group); String version = group.getVersion(); assertTrue("Before save, the migration framework will return true even if the migration has been done during load.", VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version))); try { group.eResource().save(Collections.emptyMap()); } catch (IOException e) { fail("Pb when saving the resource : " + e.getMessage()); } version = group.getVersion(); assertFalse("The version tag should now be set telling that the migration was done.", VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version))); checkVSMMigrationEffect(group); }
Source:
<code>public static void treeNode(PrintStream out, Description description) { String location = description.getClassName() + "." + description.getMethodName(); out.println(create("suiteTreeNode", <START> new Pair("name", escape(description.getMethodName())), <END> new Pair("location", "java:test://" + escape(location)))); }</code><technical_language>some constant for "name", "location" etc</technical_language>

Target:
public static void treeNode(PrintStream out, Description description) { String location = description.getClassName() + "." + description.getMethodName(); out.println(create(SUITE_TREE_NODE, new Pair(NAME, escape(description.getMethodName())), new Pair(LOCATION, "java:test://" + escape(location)))); }
Source:
<code>public void onPauseGame() { Toast.makeText(this, "Game Paused", Toast.LENGTH_SHORT).show(); <START> game.onPauseGame(); <END> }</code><technical_language>I this game.pause() want pause, inform game paused? (which makees sense right?)</technical_language>

Target:
public void onPauseGame() { Toast.makeText(this, "Game Paused", Toast.LENGTH_SHORT).show(); game.pause(); }
Source:
<code>private void loadPayload() { VmDeviceDAO dao = getDbFacade().getVmDeviceDao(); List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getParameters().getVmId(), VmDeviceGeneralType.DISK); for (VmDevice disk : disks) { if (VmPayload.isPayload(disk.getSpecParams())) { VmPayload payload = new VmPayload(disk); <START> payload.setDeviceType(VmDeviceType.valueOf(disk.getDevice().toUpperCase())); <END> getVm().setVmPayload(payload); break; } } }</code><technical_language>this is needed</technical_language>

Target:
private void loadPayload() { VmDeviceDAO dao = getDbFacade().getVmDeviceDao(); List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getParameters().getVmId(), VmDeviceGeneralType.DISK); for (VmDevice disk : disks) { if (VmPayload.isPayload(disk.getSpecParams())) { VmPayload payload = new VmPayload(disk); getVm().setVmPayload(payload); break; } } }
Source:
<code>public static void putLabels(ObjectMeta metadata, Map<String, String> labels) { if (labels == null || labels.isEmpty()) { return; } <START> labels.forEach((k, v) -> putLabel(metadata, k, v)); <END> }</code><technical_language>Map.putAll instead of call putLabel in loop</technical_language>

Target:
public static void putLabels(ObjectMeta metadata, Map<String, String> labels) { if (labels == null || labels.isEmpty()) { return; } Map<String, String> metaLabels = metadata.getLabels(); if (metaLabels == null) { metadata.setLabels(new HashMap<>(labels)); } else { metaLabels.putAll(labels); } }
Source:
<code>protected SWTBotEditor openRepresentation(Session session, String representationDescriptionName, final String representationName, Class<? extends DRepresentation> expectedRepresentationClass, boolean disableSnapToGridOnThisEditor, boolean disableSnapToShapeOnThisEditor) { DRepresentation representation = getRepresentationWithName(session, representationDescriptionName, representationName); TestCase.assertTrue("This representation should be a " + expectedRepresentationClass.getSimpleName(), expectedRepresentationClass.isInstance(representation)); DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor()); SWTBotUtils.waitAllUiEvents(); SWTBotEditor swtBotEditor = null; <START> String expectedTitle = representationName; <END> if (TestsUtil.isLunaPlatform()) { expectedTitle = Objects.firstNonNull(representationName, "").trim(); } if (DDiagram.class.isAssignableFrom(expectedRepresentationClass)) { swtBotEditor = SWTBotSiriusHelper.getSiriusDiagramEditor(expectedTitle); if (disableSnapToGridOnThisEditor) { ((SWTBotSiriusDiagramEditor) swtBotEditor).setSnapToGrid(false); } if (disableSnapToShapeOnThisEditor) { ((SWTBotSiriusDiagramEditor) swtBotEditor).setSnapToShape(false); } } else { swtBotEditor = SWTBotSiriusHelper.getSiriusEditor(expectedTitle); } return swtBotEditor; }</code><technical_language>"editorPart.getTitle()" instead of representationName (this is done change)</technical_language>

Target:
protected SWTBotEditor openRepresentation(Session session, String representationDescriptionName, final String representationName, Class<? extends DRepresentation> expectedRepresentationClass, boolean disableSnapToGridOnThisEditor, boolean disableSnapToShapeOnThisEditor) { DRepresentation representation = getRepresentationWithName(session, representationDescriptionName, representationName); TestCase.assertTrue("This representation should be a " + expectedRepresentationClass.getSimpleName(), expectedRepresentationClass.isInstance(representation)); IEditorPart editorPart = DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor()); SWTBotUtils.waitAllUiEvents(); SWTBotEditor swtBotEditor = null; String expectedTitle = editorPart.getTitle(); if (TestsUtil.isLunaPlatform()) { expectedTitle = Objects.firstNonNull(representationName, "").trim(); } if (DDiagram.class.isAssignableFrom(expectedRepresentationClass)) { swtBotEditor = SWTBotSiriusHelper.getSiriusDiagramEditor(expectedTitle); if (disableSnapToGridOnThisEditor) { ((SWTBotSiriusDiagramEditor) swtBotEditor).setSnapToGrid(false); } if (disableSnapToShapeOnThisEditor) { ((SWTBotSiriusDiagramEditor) swtBotEditor).setSnapToShape(false); } } else { swtBotEditor = SWTBotSiriusHelper.getSiriusEditor(expectedTitle); } return swtBotEditor; }
Source:
<code>protected String getDocumentSkinExtensionURL(DocumentReference documentReference, String documentName, String pluginName, XWikiContext context) { String queryString = String.format("%s&amp;%s&amp;%s%s", getLanguageQueryString(context), getDocumentVersionQueryString(documentReference, context), <START> getWikiVersionQueryString(context), <END> parametersAsQueryString(documentName, context)); return context.getWiki().getURL(documentReference, pluginName, queryString, "", context); }</code><technical_language>I point for a wiki page, if wiki page changed need invalidate cache</technical_language>

Target:
protected String getDocumentSkinExtensionURL(DocumentReference documentReference, String documentName, String pluginName, XWikiContext context) { String queryString = String.format("%s&amp;%s%s", getLanguageQueryString(context), getDocumentVersionQueryString(documentReference, context), parametersAsQueryString(documentName, context)); return context.getWiki().getURL(documentReference, pluginName, queryString, "", context); }
Source:
<code><START> public void setCustomHeader(String field, String value) { <END> String lowerCaseField = field.toLowerCase(); if (lowerCaseField.equals("content-type") || lowerCaseField.equals("authorization")) { return; } customHeaders.put(field, value); }</code><technical_language>a custom header set previously removed</technical_language>

Target:
public void setCustomHeader(String field, String value) { HttpCustomHeader header; int index = findCustomHeader(field.toLowerCase()); if (index >= 0) { header = customHeaders.get(index); header.setValue(value); } else { header = new HttpCustomHeader(field, value); customHeaders.add(header); } }
Source:
<code>public void releaseStore(Store<?, ?> resource) throws CacheAccessException { Map.Entry<CachingTier.Provider, AuthoritativeTier.Provider> entry = providersMap.get(resource); if (entry == null) { throw new IllegalArgumentException("Given store is not managed by this provider : " + resource); } CacheStore cacheStore = (CacheStore) resource; <START> cacheStore.flushAll((Store)cacheStore.realCachingTier); <END> entry.getKey().releaseCachingTier(cacheStore.realCachingTier); entry.getValue().releaseAuthoritativeTier(cacheStore.authoritativeTier); }</code><technical_language>#487 this assumption true anymore</technical_language>

Target:
public void releaseStore(Store<?, ?> resource) { Map.Entry<CachingTier.Provider, AuthoritativeTier.Provider> entry = providersMap.get(resource); if (entry == null) { throw new IllegalArgumentException("Given store is not managed by this provider : " + resource); } CacheStore cacheStore = (CacheStore) resource; entry.getKey().releaseCachingTier(cacheStore.realCachingTier); entry.getValue().releaseAuthoritativeTier(cacheStore.authoritativeTier); }
Source:
<code>protected void handleDispose(DisposeEvent event) { editingDomainChange(getCompareConfiguration().getEditingDomain(), null); <START> getCompareConfiguration().getEventBus().unregister(this); <END> differenceGroupProvider.dispose(); super.handleDispose(event); }</code><technical_language>differenceGroupProvider is null this place ? If not, please add guard</technical_language>

Target:
protected void handleDispose(DisposeEvent event) { editingDomainChange(getCompareConfiguration().getEditingDomain(), null); getCompareConfiguration().getEventBus().unregister(this); if (differenceGroupProvider != null) { differenceGroupProvider.dispose(); } super.handleDispose(event); }
Source:
<code>public void close() <START> throws StoreException, InterruptedException { <END> persistor.write(); try { hardDeleter.persistCleanupToken(); } catch (IOException e) { logger.error("Index : " + dataDir + " error while persisting cleanup token ", e); } File cleanShutdownFile = new File(dataDir, Clean_Shutdown_Filename); try { cleanShutdownFile.createNewFile(); } catch (IOException e) { logger.error("Index : " + dataDir + " error while creating clean shutdown file ", e); } }</code><technical_language>reason throw InterruptedException</technical_language>

Target:
public void close() throws StoreException { persistor.write(); try { hardDeleter.shutDown(); } catch (Exception e) { logger.error("Index : " + dataDir + " error while persisting cleanup token ", e); } File cleanShutdownFile = new File(dataDir, Clean_Shutdown_Filename); try { cleanShutdownFile.createNewFile(); } catch (IOException e) { logger.error("Index : " + dataDir + " error while creating clean shutdown file ", e); } }
Source:
<code>protected static File searchPath(String path, String... lookFor) { if (path == null) return null; for (String p : path.split(File.pathSeparator)) { for (String command : lookFor) { try { final File e = new File(p, command); if (e.isFile()) { return e.getAbsoluteFile(); } } catch (SecurityException e) { <START> LOG.warn("The path '{}' isn't accessible. Skip it", command); <END> } } } return null; }</code><technical_language>Suppress non-localised string warning here. //$NON-NLS-1$</technical_language>

Target:
protected static File searchPath(String path, String... lookFor) { if (path == null) return null; for (String p : path.split(File.pathSeparator)) { for (String command : lookFor) { final File file = new File(p, command); try { if (file.isFile()) { return file.getAbsoluteFile(); } } catch (SecurityException e) { LOG.warn("The path '{}' isn't accessible. Skip it", file.getPath()); } } } return null; }
Source:
<code>public void init(ServletConfig config) throws ServletException { super.init(config); url = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL).replaceAll("%\\{", "\\${")); <START> url404 = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL404).replaceAll("%\\{", "\\${")); <END> }</code><technical_language>add a fallback in case web.xml a url404 in configuration. prevent similar issue proxy interface reports installed. I simply point real 404.html, some generic installed message</technical_language>

Target:
public void init(ServletConfig config) throws ServletException { super.init(config); url = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL).replaceAll("%\\{", "\\${")); url404 = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL404).replaceAll("%\\{", "\\${")); if (StringUtils.isEmpty(url404)) { url404 = url404Default; } }
Source:
<code>protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) { <START> final HashMap<String, Boolean> variableToEncoded = new HashMap<String, Boolean>(); <END> for (Entry<Integer, Boolean> entry : metadata.indexToEncoded().entrySet()) { final Collection<String> names = metadata.indexToName().get(entry.getKey()); for (String name : names) { variableToEncoded.put(name, entry.getValue()); } } return mutable.resolve(variables, variableToEncoded); }</code><technical_language>LinkedHashMap pls</technical_language>

Target:
protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) { Map<String, Boolean> variableToEncoded = new LinkedHashMap<String, Boolean>(); for (Entry<Integer, Boolean> entry : metadata.indexToEncoded().entrySet()) { Collection<String> names = metadata.indexToName().get(entry.getKey()); for (String name : names) { variableToEncoded.put(name, entry.getValue()); } } return mutable.resolve(variables, variableToEncoded); }
Source:
<code>private String getEntityRouting(Object entity) { ElasticsearchPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass()); Iterable<ElasticsearchPersistentProperty> routingProperties = persistentEntity.getPersistentProperties(JoinTypeRelations.class); Iterator<ElasticsearchPersistentProperty> routingPropertyIterator = routingProperties.iterator(); String routingProp = null; if (routingPropertyIterator.hasNext()) { ElasticsearchPersistentProperty routingProperty = routingPropertyIterator.next(); if (routingProperty != null) { Object joinRouting = persistentEntity.getPropertyAccessor(entity) .getProperty(routingProperty); if (joinRouting instanceof JoinField) { <START> JoinField<?> joinField = (JoinField<?>) joinRouting; <END> routingProp = stringIdRepresentation(joinField.getParent()); } } } if (routingPropertyIterator.hasNext()) { throw new RuntimeException("No more than one routing field"); } return routingProp; }</code><technical_language>logic ElasticsearchPersistentEntity. add a method boolean hasJoinFieldProperty() ElasticsearchPersistenProperty getJoinFieldProperty(). This initialized in org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity#addPersistentProperty. check if a property matches check type JoinField, annotations. in getEntityRouting get property (like done in getEntityVersion(), retrieve parentvalue Object entityConverter.convertId() get String for routing value</technical_language>

Target:
private String getEntityRouting(Object entity) { ElasticsearchPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass()); ElasticsearchPersistentProperty joinProperty = persistentEntity.getJoinFieldProperty(); if (joinProperty != null) { Object joinField = persistentEntity.getPropertyAccessor(entity).getProperty(joinProperty); if (joinField != null && JoinField.class.isAssignableFrom(joinField.getClass()) && ((JoinField<?>) joinField).getParent() != null) { return elasticsearchConverter.convertId(((JoinField<?>) joinField).getParent()); } } return null; }
Source:
<code>private void tryEnqueueSubscriptionShutdownEvent(SubscriptionShutdownEvent subscriptionShutdownEvent) { try { parent.recordsDeliveryQueue .add(new RecordsRetrievedContext(Either.right(subscriptionShutdownEvent), this, Instant.now())); } catch (Exception e) { log.warn( "{}: Unable to enqueue the shutdown event due to capacity restrictions in delivery queue with remaining capacity {}. Ignoring. Last successful response: RequestId - {}, Timestamp - {}", parent.shardId, subscriptionShutdownEvent.getEventIdentifier(), parent.recordsDeliveryQueue.remainingCapacity(), <START> subscriptionShutdownEvent.getShutdownEventThrowableOptional(), parent.getLastSuccessfulResponseRequestId(), parent.getLastSuccessfulResponseTimestamp()); <END> } }</code><technical_language>expected actual arguments doesnt match. check</technical_language>

Target:
private void tryEnqueueSubscriptionShutdownEvent(SubscriptionShutdownEvent subscriptionShutdownEvent) { try { parent.recordsDeliveryQueue .add(new RecordsRetrievedContext(Either.right(subscriptionShutdownEvent), this, Instant.now())); } catch (Exception e) { log.warn( "{}: Unable to enqueue the shutdown event due to capacity restrictions in delivery queue with remaining capacity {}. Ignoring. Last successful request details -- {}", parent.shardId, subscriptionShutdownEvent.getEventIdentifier(), parent.recordsDeliveryQueue.remainingCapacity(), parent.lastSuccessfulRequestDetails, subscriptionShutdownEvent.getShutdownEventThrowableOptional()); } }
Source:
<code>public String toString() { <START> return "SpongeRegistryType{" + <END> "root=" + root + ", location=" + location + '}'; }</code><technical_language>Please StringJoiner toString()s elsewhere</technical_language>

Target:
public String toString() { return new StringJoiner(", ", SpongeRegistryType.class.getSimpleName() + "[", "]") .add("root=" + this.root) .add("location='" + this.location + "'") .toString(); }
Source:
<code>public boolean hasDocString() { <START> return doc_string!=null; <END> }</code><technical_language>ArrayUtils.isNotEmpty(doc_string) empty string is treated doc_string</technical_language>

Target:
public boolean hasDocString() { return doc_string != null && StringUtils.isNotEmpty(doc_string.getValue()); }
Source:
<code>public void addTasksOnWakeup(Runnable task) { <START> if (!lockAddNewTasks) { <END> tasksOnWakeup.add(task); wakeUp(); } }</code><technical_language>QQ: tasks added other thread? If can, a racing condition. existing tasks cleared, a new package is received some tasks added. A lock flag is enough sync thread</technical_language>

Target:
public void addTasksOnWakeup(Runnable task) { tasksOnWakeup.add(task); wakeUp(); }
Source:
<code>public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity runtimeID) throws InfrastructureException { if (!trustedStoreInitialized) { return; } ConfigMap allCaCertsConfigMap = cheServerClientFactory .create() .configMaps() .inNamespace(installationLocationNamespace) .withName(caBundleConfigMap) .get(); if (allCaCertsConfigMap == null) { return; } KubernetesNamespace namespace = namespaceFactory.getOrCreate(runtimeID); k8sEnv .getConfigMaps() .put( configMapName, new ConfigMapBuilder() .withMetadata( new ObjectMetaBuilder() <START> .withName(configMapName) <END> .withAnnotations(allCaCertsConfigMap.getMetadata().getAnnotations()) .withLabels(configMapLabelKeyValue) .build()) .withApiVersion(allCaCertsConfigMap.getApiVersion()) .withData(allCaCertsConfigMap.getData()) .build()); for (PodData pod : k8sEnv.getPodsData().values()) { if (pod.getRole() == PodRole.DEPLOYMENT) { if (pod.getSpec() .getVolumes() .stream() .noneMatch(v -> v.getName().equals(CHE_TRUST_STORE_VOLUME))) { pod.getSpec() .getVolumes() .add( new VolumeBuilder() .withName(CHE_TRUST_STORE_VOLUME) .withConfigMap( new ConfigMapVolumeSourceBuilder().withName(configMapName).build()) .build()); } } for (Container container : pod.getSpec().getInitContainers()) { provisionTrustStoreVolumeMountIfNeeded(container); } for (Container container : pod.getSpec().getContainers()) { provisionTrustStoreVolumeMountIfNeeded(container); } } }</code><technical_language>I description of che.infra.kubernetes.trusted_ca.dest_configmap property updated</technical_language>

Target:
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity runtimeID) throws InfrastructureException { if (!trustedStoreInitialized) { return; } ConfigMap allCaCertsConfigMap = cheServerClientFactory .create() .configMaps() .inNamespace(installationLocationNamespace) .withName(caBundleConfigMap) .get(); if (allCaCertsConfigMap == null) { return; } k8sEnv .getConfigMaps() .put( configMapName, new ConfigMapBuilder() .withMetadata( new ObjectMetaBuilder() .withName(configMapName) .withAnnotations(allCaCertsConfigMap.getMetadata().getAnnotations()) .withLabels(configMapLabelKeyValue) .build()) .withApiVersion(allCaCertsConfigMap.getApiVersion()) .withData(allCaCertsConfigMap.getData()) .build()); for (PodData pod : k8sEnv.getPodsData().values()) { if (pod.getRole() == PodRole.DEPLOYMENT) { if (pod.getSpec() .getVolumes() .stream() .noneMatch(v -> v.getName().equals(CHE_TRUST_STORE_VOLUME))) { pod.getSpec() .getVolumes() .add( new VolumeBuilder() .withName(CHE_TRUST_STORE_VOLUME) .withConfigMap( new ConfigMapVolumeSourceBuilder().withName(configMapName).build()) .build()); } } for (Container container : pod.getSpec().getInitContainers()) { provisionTrustStoreVolumeMountIfNeeded(container); } for (Container container : pod.getSpec().getContainers()) { provisionTrustStoreVolumeMountIfNeeded(container); } } }
Source:
<code>public static Map<String, String> toQueryParameters(String coverageId) { return Maps.of( "service", "WCS", "version", "2.0.1", <START> "request", "DescribeCoverage", <END> "coverageId", coverageId); }</code><technical_language>DescribeCoverage, GetCapabilities declared enum (and other similar places)</technical_language>

Target:
public static Map<String, String> toQueryParameters(String coverageId) { return Maps.of( "service", "WCS", "version", WCS.VERSION_201, "request", "DescribeCoverage", "coverageId", coverageId); }
Source:
<code>JarFileUtils(IPostProcessor processor, String xmlPathInJar, List<String> testNames) { <START> this(processor, xmlPathInJar, testNames, null); <END> }</code><technical_language>ParallelMode.NONE instead of null default</technical_language>

Target:
JarFileUtils(IPostProcessor processor, String xmlPathInJar, List<String> testNames) { this(processor, xmlPathInJar, testNames, XmlSuite.ParallelMode.NONE); }
Source:
<code>public boolean handleUri(String uriScheme, String uri) throws CoreException { IUriSchemeHandler handler = null; <START> if (createdHandlers.containsKey(uriScheme)) { <END> handler = createdHandlers.get(uriScheme); } else { handler = reader.getHandlerFromExtensionPoint(uriScheme); createdHandlers.put(uriScheme, handler); } if (handler != null) { handler.handle(uri); } return handler != null; }</code><technical_language>Please consider map.computeIfAbsent</technical_language>

Target:
public void handleUri(String uriScheme, String uri) throws CoreException { IUriSchemeHandler handler = null; handler = getHandler(uriScheme); if (handler != null) { handler.handle(uri); } }
Source:
<code>public void channelInactiveTest() { HttpRequest request = createRequestWithHeaders(HttpMethod.GET, TestingUri.Close.toString()); ChunkedWriteHandler chunkedWriteHandler = new ChunkedWriteHandler(); EmbeddedChannel channel = new EmbeddedChannel(chunkedWriteHandler); NettyResponseChannel nettyResponseChannel = new NettyResponseChannel(new MockChannelHandlerContext(channel), new NettyMetrics(new MetricRegistry()), new PerformanceConfig(new VerifiableProperties(new Properties()))); channel.disconnect().awaitUninterruptibly(); assertFalse("Channel should be closed", channel.isOpen()); Future<Long> future = nettyResponseChannel.write(Unpooled.buffer(1), null); try { <START> future.get(); <END> } catch (InterruptedException | ExecutionException e) { assertTrue("Should be ClosedChannelException", e.getCause() instanceof ClosedChannelException); } }</code><technical_language>please add a fail("") future.get();</technical_language>

Target:
public void channelInactiveTest() { HttpRequest request = createRequestWithHeaders(HttpMethod.GET, TestingUri.Close.toString()); ChunkedWriteHandler chunkedWriteHandler = new ChunkedWriteHandler(); EmbeddedChannel channel = new EmbeddedChannel(chunkedWriteHandler); NettyResponseChannel nettyResponseChannel = new NettyResponseChannel(new MockChannelHandlerContext(channel), new NettyMetrics(new MetricRegistry()), new PerformanceConfig(new VerifiableProperties(new Properties()))); channel.disconnect().awaitUninterruptibly(); assertFalse("Channel should be closed", channel.isOpen()); Future<Long> future = nettyResponseChannel.write(Unpooled.buffer(1), null); try { future.get(); fail("Future.get() should throw exception."); } catch (InterruptedException | ExecutionException e) { assertTrue("Should be ClosedChannelException", e.getCause() instanceof ClosedChannelException); } }
Source:
<code>private void handleNavIntent() { Log.d(TAG, "handleNavIntent()"); Intent intent = getIntent(); if (intent.hasExtra(EXTRA_FEED_ID) || intent.hasExtra(EXTRA_REFRESH_ON_START) || (intent.hasExtra(EXTRA_NAV_TYPE) && (intent.hasExtra(EXTRA_NAV_INDEX) || intent.hasExtra(EXTRA_FRAGMENT_TAG)))) { int index = intent.getIntExtra(EXTRA_NAV_INDEX, -1); String tag = intent.getStringExtra(EXTRA_FRAGMENT_TAG); Bundle args = intent.getBundleExtra(EXTRA_FRAGMENT_ARGS); boolean refreshOnStart = intent.getBooleanExtra(EXTRA_REFRESH_ON_START, false); if (refreshOnStart) { tag = QueueFragment.TAG; args = new Bundle(); <START> args.putBoolean(QueueFragment.ARG_REFRESH_ON_START, true); <END> } long feedId = intent.getLongExtra(EXTRA_FEED_ID, 0); if (index >= 0) { loadFragment(index, args); } else if (tag != null) { loadFragment(tag, args); } else if(feedId > 0) { loadFeedFragmentById(feedId, args); } } setIntent(new Intent(MainActivity.this, MainActivity.class)); }</code><technical_language>call AutoUpdateManager.runImmediate(requireContext()); instead of passing queue</technical_language>

Target:
private void handleNavIntent() { Intent intent = getIntent(); if (intent.hasExtra(EXTRA_FEED_ID) || intent.hasExtra(EXTRA_FRAGMENT_TAG) || intent.hasExtra(EXTRA_REFRESH_ON_START)) { Log.d(TAG, "handleNavIntent()"); String tag = intent.getStringExtra(EXTRA_FRAGMENT_TAG); Bundle args = intent.getBundleExtra(EXTRA_FRAGMENT_ARGS); boolean refreshOnStart = intent.getBooleanExtra(EXTRA_REFRESH_ON_START, false); if (refreshOnStart) { AutoUpdateManager.runImmediate(this); } long feedId = intent.getLongExtra(EXTRA_FEED_ID, 0); if (tag != null) { loadFragment(tag, args); } else if (feedId > 0) { loadFeedFragmentById(feedId, args); } } else if (intent.getBooleanExtra(EXTRA_OPEN_PLAYER, false)) { sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); bottomSheetCallback.onSlide(null, 1.0f); } setIntent(new Intent(MainActivity.this, MainActivity.class)); }
Source:
<code>public void testBuilderWithUnsanitisedFieldValues() { AccountAttributes observedAccountAttributes = AccountAttributes.builder() .withGoogleId("googleId@gmail.com") .withName(" random name with extra spaces ") <START> .withEmail(" email ") <END> .withInstitute(" random institute name with extra spaces ") .withStudentProfileAttributes(StudentProfileAttributes.builder("googleId@gmail.com") .build()) .build(); assertEquals("googleId", observedAccountAttributes.getGoogleId()); assertEquals("random name with extra spaces", observedAccountAttributes.getName()); assertEquals("email", observedAccountAttributes.getEmail()); assertEquals("random institute name with extra spaces", observedAccountAttributes.getInstitute()); assertEquals("googleId", observedAccountAttributes.studentProfile.googleId); }</code><technical_language>"&<email>&" spaces for types of sanitization</technical_language>

Target:
public void testBuilderWithUnsanitisedFieldValues() { AccountAttributes observedAccountAttributes = AccountAttributes.builder() .withGoogleId("googleId@gmail.com") .withName(" random name with extra spaces ") .withEmail(" email@example.com ") .withInstitute(" random institute name with extra spaces ") .withStudentProfileAttributes(StudentProfileAttributes.builder("googleId@gmail.com") .build()) .build(); assertEquals("googleId", observedAccountAttributes.getGoogleId()); assertEquals("random name with extra spaces", observedAccountAttributes.getName()); assertEquals("email@example.com", observedAccountAttributes.getEmail()); assertEquals("random institute name with extra spaces", observedAccountAttributes.getInstitute()); assertEquals("googleId", observedAccountAttributes.studentProfile.googleId); }
Source:
<code>public synchronized List<String> getGroups(String user) throws IOException { Set<String> groupSet = new TreeSet<String>(); List<String> groups = Collections.emptyList(); for (GroupMappingServiceProvider provider : providersList) { try { groups = provider.getGroups(user); } catch (Exception e) { LOG.warn("Unable to get groups for user via because: {}", user, provider.getClass().getSimpleName(), e.toString()); LOG.debug("Stacktrace: ", e); } if (!groups.isEmpty()) { groupSet.addAll(groups); if (!combined) break; } } <START> return Collections.unmodifiableList(new ArrayList<>(groupSet)); <END> }</code><technical_language>Now, calling getGroups() start failing if adding new list while case before. inmodifiable is kind of dangerous</technical_language>

Target:
public synchronized List<String> getGroups(String user) throws IOException { Set<String> groupSet = new TreeSet<String>(); for (GroupMappingServiceProvider provider : providersList) { List<String> groups = Collections.emptyList(); try { groups = provider.getGroups(user); } catch (Exception e) { LOG.warn("Unable to get groups for user via because: {}", user, provider.getClass().getSimpleName(), e.toString()); LOG.debug("Stacktrace: ", e); } if (!groups.isEmpty()) { groupSet.addAll(groups); if (!combined) break; } } return new ArrayList<>(groupSet); }
Source:
<code>public void testAllMethods() throws Exception { accountService = new InMemoryUnknownAccountServiceFactory(null, null, null).getAccountService(); <START> Account refAccount = new AccountBuilder((short) 1, "a", Account.AccountStatus.INACTIVE, null).build(); <END> assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountById(Utils.getRandomShort(random))); assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountById((short) -1)); assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountByName(UtilsTest.getRandomString(10))); assertEquals("Wrong size of account collection", 1, accountService.getAllAccounts().size()); assertFalse("Wrong return value from an unsuccessful update operation", accountService.updateAccounts(Collections.singletonList(refAccount))); assertEquals("Wrong size of account collection", 1, accountService.getAllAccounts().size()); accountService.close(); }</code><technical_language>this is a "refAccount" (i.e. a reference) - name appropriately declare is required (not this early)</technical_language>

Target:
public void testAllMethods() throws Exception { accountService = new InMemoryUnknownAccountServiceFactory(null, null, null).getAccountService(); assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountById(Utils.getRandomShort(random))); assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountById((short) -1)); assertEquals("Wrong account", Account.UNKNOWN_ACCOUNT, accountService.getAccountByName(UtilsTest.getRandomString(10))); assertEquals("Wrong size of account collection", 1, accountService.getAllAccounts().size()); Account account = new AccountBuilder((short) 1, "a", Account.AccountStatus.INACTIVE, null).build(); assertFalse("Wrong return value from an unsuccessful update operation", accountService.updateAccounts(Collections.singletonList(account))); assertEquals("Wrong size of account collection", 1, accountService.getAllAccounts().size()); try { accountService.getAllAccounts().add(account); fail("Should have thrown."); } catch (UnsupportedOperationException e) { } accountService.close(); }
Source:
<code>public void writeIdsToCqlStore( HttpServletRequest request, HttpServletResponse response ) { messageConsumerFactory.createConsumer( new CqlWritingConsumer(), JacksonMessageSerializer.forType(ResourceUpdatedMessage.class), KAFKA_TOPIC_NAME, KAFKA_CONSUMER_GROUP <START> ).withFailedMessagePersistence(mongo); <END> response.setStatus(200); try { response.getWriter().write("Started Mongo to CQL consumer"); } catch (IOException e) { throw Throwables.propagate(e); } }</code><technical_language>consumer is a Guava service. needs started</technical_language>

Target:
public void writeIdsToCqlStore( HttpServletRequest request, HttpServletResponse response ) { if (this.cqlConsumer == null) { this.cqlConsumer = messageConsumerFactory.createConsumer( new CqlWritingConsumer(), JacksonMessageSerializer.forType(ResourceUpdatedMessage.class), KAFKA_TOPIC_NAME, KAFKA_CONSUMER_GROUP ).withFailedMessagePersistence(mongo) .build(); } cqlConsumer.startAsync().awaitRunning(); response.setStatus(200); try { response.getWriter().write("Started Mongo to CQL consumer"); } catch (IOException e) { throw Throwables.propagate(e); } }
Source:
<code>public void testAddPatientCorrelationPLQ() throws Exception { PatientCorrelationProxyWebServiceUnsecuredImpl impl = getPatientCorrelationProxyWebServiceUnsecuredImpl(); impl.addPatientCorrelationPLQ(mockPLQrec, mockAssertion); <START> when(mockWebProxy.getUrlLocalHomeCommunity(NhincConstants.PATIENT_CORRELATION_SERVICE_NAME)).thenReturn(""); <END> verify(mockClient).invokePort(any(Class.class), any(String.class), any(Object.class)); verify(mockCONNECTClientFactory).getCONNECTClientUnsecured(any(ServicePortDescriptor.class), any(String.class), any(AssertionType.class)); }</code><technical_language>need "When"s invoke service in order for mocks work, begs question this is should, if is needed</technical_language>

Target:
public void testAddPatientCorrelationPLQ() throws Exception { PatientCorrelationProxyWebServiceUnsecuredImpl impl = getPatientCorrelationProxyWebServiceUnsecuredImpl(); impl.addPatientCorrelationPLQ(mockPLQrec, mockAssertion); verify(mockClient).invokePort(any(Class.class), any(String.class), any(AddPatientCorrelationPLQRequestType.class)); verify(mockCONNECTClientFactory).getCONNECTClientUnsecured(any(ServicePortDescriptor.class), any(String.class), any(AssertionType.class)); }
Source:
<code>public void onBrowserEvent(final Event event) { switch (DOM.eventGetType(event)) { case Event.ONCLICK: { final Element td = getEventTargetCell(event); if (td == null) { break; } final int row = rowOf(td); if (getRowItem(row) != null) { onCellSingleClick(rowOf(td), columnOf(td)); return; } break; } case Event.ONDBLCLICK: { Element td = getEventTargetCell(event); if (td == null) { return; } onCellDoubleClick(rowOf(td), columnOf(td)); return; } <START> } <END> }</code><technical_language>Is 'super.onBrowserEvent(event);' needed anymore</technical_language>

Target:
public void onBrowserEvent(final Event event) { switch (DOM.eventGetType(event)) { case Event.ONCLICK: { final Element td = getEventTargetCell(event); if (td == null) { break; } final int row = rowOf(td); if (getRowItem(row) != null) { onCellSingleClick(rowOf(td), columnOf(td)); return; } break; } case Event.ONDBLCLICK: { Element td = getEventTargetCell(event); if (td == null) { return; } onCellDoubleClick(rowOf(td), columnOf(td)); return; } } super.onBrowserEvent(event); }