auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public void testPojoToJsonPrettyPrint() { <END> String json = "{\n \"foo\" : \"bar\"\n}"; CompositeMessageConverter converter = converterFactory.newInstance(MimeTypeUtils.APPLICATION_JSON); for (MessageConverter messageConverter : converter.getConverters()) { if (messageConverter instanceof PojoToJsonMessageConverter) { ((PojoToJsonMessageConverter) messageConverter).setPrettyPrint(true); } else if (messageConverter instanceof TupleToJsonMessageConverter) { ((TupleToJsonMessageConverter) messageConverter).setPrettyPrint(true); } } Message<?> msg = (Message<?>) converter.fromMessage(new GenericMessage<Foo>(new Foo()), String.class); assertEquals(json, msg.getPayload()); assertEquals(MimeTypeUtils.APPLICATION_JSON, msg.getHeaders().get(MessageHeaders.CONTENT_TYPE)); }</code><technical_language>do a true unit test for specific converters in a dedicated class, spending 50% of lines of code finding converter list</technical_language>

Target:
public void testPojoToJsonPrettyPrint() { String json = "{\n \"foo\" : \"bar\"\n}"; PojoToJsonMessageConverter messageConverter = new PojoToJsonMessageConverter(); messageConverter.setPrettyPrint(true); Message<?> msg = (Message<?>) messageConverter.fromMessage(new GenericMessage<Foo>(new Foo()), String.class); assertEquals(json, msg.getPayload()); assertEquals(MimeTypeUtils.APPLICATION_JSON, msg.getHeaders().get(MessageHeaders.CONTENT_TYPE)); }
Source:
<code>private void loadPaletteGroups() { paletteGroupMap = new HashMap<String,IPaletteGroup>(); paletteGroups = new ArrayList<IPaletteGroup>(); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(POINT_ID); if(point != null){ HashMap<String, String> positions = new HashMap<String, String>(); <START> for (IConfigurationElement element : point.getConfigurationElements()) { <END> IPaletteGroup paletteGroup = createPaletteGroupInstance(element); if(paletteGroup != null){ paletteGroup.setPaletteModel(this); String version = getSelectedVersion(paletteGroup); paletteGroup.setSelectedVersion(version); paletteGroupMap.put(paletteGroup.getName(), paletteGroup); paletteGroups.add(paletteGroup); String position = element.getAttribute("position"); if(position != null){ positions.put(paletteGroup.getName(), position); } } } for(String groupName : positions.keySet()){ String position = positions.get(groupName); IPaletteGroup group = paletteGroupMap.get(groupName); if(POSITION_TOP.equals(position)){ paletteGroups.remove(group); paletteGroups.add(0, group); }else if(POSITION_BOTTOM.equals(position)){ paletteGroups.remove(group); paletteGroups.add(group); } } } }</code><technical_language>Is enough able order groups positions "top" "bottom"? implement order number of groups</technical_language>

Target:
private ArrayList<IPaletteGroup> loadPaletteGroups() { TreeMap<String,IPaletteGroup> groupsByOrderId = new TreeMap<String,IPaletteGroup>(); paletteGroupMap = new HashMap<String, IPaletteGroup>(); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(POINT_ID); for (IConfigurationElement element : point.getConfigurationElements()) { IPaletteGroup paletteGroup = createPaletteGroupInstance(element); if(paletteGroup != null){ paletteGroup.setPaletteModel(this); IHTMLLibraryVersion version = getSelectedVersion(paletteGroup); paletteGroup.setSelectedVersion(version); paletteGroupMap.put(paletteGroup.getName(), paletteGroup); String orderId = element.getAttribute("orderId"); if(orderId == null){ orderId = paletteGroup.getName(); } groupsByOrderId.put(orderId, paletteGroup); } } return new ArrayList<IPaletteGroup>(groupsByOrderId.values()); }
Source:
<code>public static Collection[] findAll(Context context) throws SQLException { TableRowIterator tri = null; try { String query = "SELECT c.* FROM collection c " + "LEFT JOIN metadatavalue m on (m.resource_id = c.collection_id and m.resource_type_id = ? and m.metadata_field_id = ?) "; <START> if("oracle".equals(ConfigurationManager.getProperty("db.name"))){ <END> query += " ORDER BY cast(m.text_value as varchar2(128))"; }else{ query += " ORDER BY m.text_value"; } tri = DatabaseManager.query(context, query, Constants.COLLECTION, MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID() ); } catch (SQLException e) { log.error("Find all Collections - ",e); throw e; } List<Collection> collections = new ArrayList<Collection>(); try { while (tri.hasNext()) { TableRow row = tri.next(); Collection fromCache = (Collection) context.fromCache( Collection.class, row.getIntColumn("collection_id")); if (fromCache != null) { collections.add(fromCache); } else { collections.add(new Collection(context, row)); } } } finally { if (tri != null) { tri.close(); } } Collection[] collectionArray = new Collection[collections.size()]; collectionArray = (Collection[]) collections.toArray(collectionArray); return collectionArray; }</code><technical_language>DatabaseManager.isOracle()</technical_language>

Target:
public static Collection[] findAll(Context context) throws SQLException { TableRowIterator tri = null; try { String query = "SELECT c.* FROM collection c " + "LEFT JOIN metadatavalue m on (m.resource_id = c.collection_id and m.resource_type_id = ? and m.metadata_field_id = ?) "; if(DatabaseManager.isOracle()){ query += " ORDER BY cast(m.text_value as varchar2(128))"; }else{ query += " ORDER BY m.text_value"; } tri = DatabaseManager.query(context, query, Constants.COLLECTION, MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID() ); } catch (SQLException e) { log.error("Find all Collections - ",e); throw e; } List<Collection> collections = new ArrayList<Collection>(); try { while (tri.hasNext()) { TableRow row = tri.next(); Collection fromCache = (Collection) context.fromCache( Collection.class, row.getIntColumn("collection_id")); if (fromCache != null) { collections.add(fromCache); } else { collections.add(new Collection(context, row)); } } } finally { if (tri != null) { tri.close(); } } Collection[] collectionArray = new Collection[collections.size()]; collectionArray = (Collection[]) collections.toArray(collectionArray); return collectionArray; }
Source:
<code>public void testSimpleAnnounce() throws IOException { <START> IndexerSQLMetadataStorageCoordinator coordinator = new IndexerSQLMetadataStorageCoordinator( <END> mapper, tablesConfig, derbyConnector ); coordinator.announceHistoricalSegments(segments); Assert.assertArrayEquals( mapper.writeValueAsString(defaultSegment).getBytes("UTF-8"), derbyConnector.lookup( tablesConfig.getSegmentsTable(), "id", "payload", defaultSegment.getIdentifier() ) ); }</code><technical_language>coordinator instance variable, is in tests</technical_language>

Target:
public void testSimpleAnnounce() throws IOException { coordinator.announceHistoricalSegments(segments); Assert.assertArrayEquals( mapper.writeValueAsString(defaultSegment).getBytes("UTF-8"), derbyConnector.lookup( tablesConfig.getSegmentsTable(), "id", "payload", defaultSegment.getIdentifier() ) ); }
Source:
<code>public void actionPerformed(ActionEvent e) { DbxState dbxState = etc.getDbxState(); if(Cloud.getInstance().getStatus() != Cloud.Status.DBX_CONNECTED || dbxState == null) { JOptionPane.showMessageDialog(null, "No Dropbox file has been loaded.\n" + "You must open Dropbox file, before you save it.", "Cannot save progress", JOptionPane.WARNING_MESSAGE); return; } String[] periodOptions = {"Disable", "1", "3", "5", "10"}; syncPeriod = (String) JOptionPane.showInputDialog( null, "Select the auto sync period (in min)", "Period of Dropbox Remote Sync", JOptionPane.QUESTION_MESSAGE, null, periodOptions, periodOptions[0] ); <START> LOGGER.log("You set your interval of Dropbox auto sync as: " + syncPeriod); <END> if(syncPeriod == null) { return; } if(!syncPeriod.startsWith("Disable")) { if(autoSyncThread == null) { autoSyncThread = new DbxAutoSync(Integer.valueOf(syncPeriod)); autoSyncThread.start(); } else { autoSyncThread.setInterval(Integer.valueOf(syncPeriod)); } } else { if(autoSyncThread != null){ autoSyncThread.setInterval(0); autoSyncThread.interrupt(); autoSyncThread = null; } } }</code><technical_language>good include "minutes" number displays "5 minutes", 5</technical_language>

Target:
public void actionPerformed(ActionEvent e) { DbxState dbxState = etc.getEditorState().getDbxState(); if(Cloud.getInstance().getStatus() != Cloud.Status.DBX_CONNECTED || dbxState == null) { JOptionPane.showMessageDialog(null, "No Dropbox file has been loaded.\n" + "You must open Dropbox file, before you save it.", "Cannot save progress", JOptionPane.WARNING_MESSAGE); return; } String[] periodOptions = {"Disable", "1 minute", "3 minutes", "5 minutes", "10 minutes"}; syncPeriod = (String) JOptionPane.showInputDialog( null, "Select the auto sync period (in min)", "Period of Dropbox Remote Sync", JOptionPane.QUESTION_MESSAGE, null, periodOptions, periodOptions[0] ); LOGGER.log("You set your interval of Dropbox auto sync as: " + syncPeriod); if(syncPeriod == null) { return; } if(!syncPeriod.startsWith("Disable")) { syncPeriod = syncPeriod.substring(0, syncPeriod.indexOf(" ")); if(autoSyncThread == null) { dbxAutoSyncObj = new DbxAutoSync(Integer.valueOf(syncPeriod)); autoSyncThread = new Thread(dbxAutoSyncObj); autoSyncThread.start(); } else { dbxAutoSyncObj.setInterval(Integer.valueOf(syncPeriod)); } } else { if(autoSyncThread != null){ dbxAutoSyncObj.setInterval(0); autoSyncThread.interrupt(); autoSyncThread = null; } } }
Source:
<code>public CurveParameterMetadata metadata(LocalDate valuationDate) { Tenor startTenor = Tenor.of(template.getPeriodToStart()); <START> return TenorCurveNodeMetadata.of(valuationDate.plus(startTenor), startTenor); <END> }</code><technical_language>tenor of FRA start end. So, is metadata based Period, Tenor</technical_language>

Target:
public CurveParameterMetadata metadata(LocalDate valuationDate) { Tenor endTenor = Tenor.of(template.getPeriodToEnd()); return TenorCurveNodeMetadata.of(valuationDate.plus(endTenor), endTenor); }
Source:
<code>public String displayString(final IdentifierPolicy policy) { <START> return StringUtils.join(names, ".", new Function<Identifier, String>() { <END> @Override public String apply(@Nullable Identifier identifier) { return identifier.displayString(policy); } }); }</code><technical_language>IdentifierPolicy.getIdentifierSeperator() instead of "."</technical_language>

Target:
public String displayString(final IdentifierPolicy policy) { return StringUtils.join(names, policy.getIdentifierSeperator(), new Function<Identifier, String>() { @Override public String apply(@Nullable Identifier identifier) { return identifier.displayString(policy); } }); }
Source:
<code>protected void executeCommand() { final T bckndCmdParams = getParameters(); final SetupNetworksVdsCommandParameters vdsCmdParams = new SetupNetworksVdsCommandParameters( getVdsId(), bckndCmdParams.getNetworks(), bckndCmdParams.getRemovedNetworks(), bckndCmdParams.getBonds(), bckndCmdParams.getRemovedBonds(), bckndCmdParams.getInterfaces()); vdsCmdParams.setForce(bckndCmdParams.isForce()); vdsCmdParams.setCheckConnectivity(bckndCmdParams.isCheckConnectivity()); vdsCmdParams.setConectivityTimeout(bckndCmdParams.getConectivityTimeout()); FutureVDSCall<VDSReturnValue> setupNetworksTask = createFutureTask(vdsCmdParams); if (bckndCmdParams.isCheckConnectivity()) { pollInterruptively(setupNetworksTask); } long timeout = bckndCmdParams.getConectivityTimeout() > 0 ? bckndCmdParams.getConectivityTimeout() <START> : Config.<Integer> GetValue(ConfigValues.vdsTimeout); <END> try { VDSReturnValue retVal = setupNetworksTask.get(timeout, TimeUnit.SECONDS); if (retVal != null && retVal.getSucceeded()) { setSucceeded(TransactionSupport.executeInNewTransaction(updateVdsNetworksInTx(bckndCmdParams))); } } catch (TimeoutException e) { log.debug("Setup networks command timed out for " + timeout + " seconds"); } }</code><technical_language>is difference this timeout new configurable timeout added in this patchset</technical_language>

Target:
protected void executeCommand() { final T bckndCmdParams = getParameters(); final SetupNetworksVdsCommandParameters vdsCmdParams = new SetupNetworksVdsCommandParameters( getVdsId(), bckndCmdParams.getNetworks(), bckndCmdParams.getRemovedNetworks(), bckndCmdParams.getBonds(), bckndCmdParams.getRemovedBonds(), bckndCmdParams.getInterfaces()); vdsCmdParams.setForce(bckndCmdParams.isForce()); vdsCmdParams.setCheckConnectivity(bckndCmdParams.isCheckConnectivity()); vdsCmdParams.setConectivityTimeout(bckndCmdParams.getConectivityTimeout()); FutureVDSCall<VDSReturnValue> setupNetworksTask = createFutureTask(vdsCmdParams); if (bckndCmdParams.isCheckConnectivity()) { pollInterruptively(setupNetworksTask); } long timeout = bckndCmdParams.getConectivityTimeout() > 0 ? bckndCmdParams.getConectivityTimeout() : Config.<Integer> GetValue(ConfigValues.vdsTimeout); try { VDSReturnValue retVal = setupNetworksTask.get(timeout, TimeUnit.SECONDS); if (retVal != null && retVal.getSucceeded()) { setSucceeded(TransactionSupport.executeInNewTransaction(updateVdsNetworksInTx(bckndCmdParams))); } } catch (TimeoutException e) { log.debugFormat("Setup networks command timed out for {0} seconds", timeout); } }
Source:
<code>public Object getPropertyValue(Object id) { if (PROPERTY_NAME_ID.equals(id)) { if (tag != null) { return tag.getTagName(); } return ref.getName().substring(Constants.R_TAGS.length()); } if (PROPERTY_MESSAGE_ID.equals(id)) { if (tag != null) { <START> return tag.getShortMessage(); <END> } return UIText.TagPropertySource_TagPropertyNoMessage; } return null; }</code><technical_language>Strange indent. Moreover, shows (e.g. EGit 0.7.1 tag) message "EGit 0.7.1 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin)". I if JGit a problem here, if tag's message that. repositories view commit message of commit pointed to, signature line</technical_language>

Target:
public Object getPropertyValue(Object id) { if (PROPERTY_TAG_NAME_ID.equals(id)) { if (tag != null) { return tag.getTagName(); } return ref.getName().substring(Constants.R_TAGS.length()); } else if (PROPERTY_TAG_MESSAGE_ID.equals(id)) { if (tag != null) { return tag.getShortMessage(); } return UIText.TagPropertySource_TagPropertyNoMessage; } else if (PROPERTY_COMMIT_MESSAGE_ID.equals(id)) { if (commit != null) { return commit.getShortMessage(); } return ""; } else if (PROPERTY_COMMIT_ID_ID.equals(id)) { if (commit != null) { return commit.getId().name(); } return ""; } return null; }
Source:
<code>public void testThrottleWithRandomDropping() throws InterruptedException { int maxTokens = 10; BlueThrottle throttler = new BlueThrottle(); throttler.setMaxTokens(maxTokens); throttler.setFillCount(maxTokens); throttler.setFillTime(1000); throttler.setFreezeTime(100); throttler.setDropIncrease(0.5); for (int i=0;i<maxTokens;i++) throttler.checkLimit(1); Assert.assertEquals("All tokens should be used up by now", throttler.getMaxTokens(), throttler.getDeficit()); <START> Thread.sleep(110); <END> throttler.checkLimit(1); Assert.assertTrue("Dropping probability should be increased", throttler.getDropChance()>0); LOG.info("Dropping probability is {}", throttler.getDropChance()); Thread.sleep(1500); LOG.info("Bucket is refilled with tokens.", maxTokens); int accepted = 0; for (int i=0;i<maxTokens;i++) { if (throttler.checkLimit(1)) { accepted ++; } } LOG.info("Send requests, are accepted", maxTokens, accepted); Assert.assertTrue("The dropping should be distributed", accepted<maxTokens); accepted = 0; for (int i=0;i<maxTokens;i++) { if (throttler.checkLimit(1)) { accepted ++; } } LOG.info("Send another requests, are accepted", maxTokens, accepted); Assert.assertTrue("Later requests should have a chance", accepted > 0); }</code><technical_language>run this tests multiple times? 100x 1000x ... ? Tests Thread.sleep a smell of flaky tests, especially in Apache infra</technical_language>

Target:
public void testThrottleWithRandomDropping() throws InterruptedException { int maxTokens = 5; BlueThrottle throttler = new BlueThrottleWithMockRandom(new MockRandom()); throttler.setMaxTokens(maxTokens); throttler.setFillCount(maxTokens); throttler.setFillTime(1000); throttler.setFreezeTime(100); throttler.setDropIncrease(0.5); for (int i=0;i<maxTokens;i++) throttler.checkLimit(1); Assert.assertEquals("All tokens should be used up by now", throttler.getMaxTokens(), throttler.getDeficit()); Thread.sleep(120); throttler.checkLimit(1); Assert.assertTrue("Dropping probability should be increased", throttler.getDropChance()>0); LOG.info("Dropping probability is {}", throttler.getDropChance()); Thread.sleep(1100); LOG.info("Bucket is refilled with tokens.", maxTokens); int accepted = 0; for (int i=0;i<maxTokens;i++) { if (throttler.checkLimit(1)) { accepted ++; } } LOG.info("Send requests, are accepted", maxTokens, accepted); Assert.assertTrue("The dropping should be distributed", accepted<maxTokens); accepted = 0; for (int i=0;i<maxTokens;i++) { if (throttler.checkLimit(1)) { accepted ++; } } LOG.info("Send another requests, are accepted", maxTokens, accepted); Assert.assertTrue("Later requests should have a chance", accepted > 0); }
Source:
<code><START> public MecanumChassis(String name, Motor frontLeftWheel, Motor frontRightWheel, Motor backLeftWheel, <END> Motor backRightWheel) { super(frontLeftWheel, frontRightWheel, backLeftWheel, backRightWheel); }</code><technical_language>update pass name through, possibly add another constructor name</technical_language>

Target:
public MecanumChassis(String name, Motor frontLeftWheel, Motor frontRightWheel, Motor backLeftWheel, Motor backRightWheel) { super(name, frontLeftWheel, frontRightWheel, backLeftWheel, backRightWheel); }
Source:
<code>public static void openExtendedNotificationsPanel(UiDevice device) throws UiObjectNotFoundException { new NetworkUtilPopupWatcher(device).checkForCondition(); device.openNotification(); new NetworkUtilPopupWatcher(device).checkForCondition(); UiObject expandIndicator = device.findObject(new UiSelector().resourceId(Res.NOTIFICATION_BAR_EXPAND_RES)); if (expandIndicator.waitForExists(5L)) { expandIndicator.clickAndWaitForNewWindow(); } else { <START> Log.d(TAG, "tray expander icon not found"); <END> } UiObject notificationHeader = device.findObject(new UiSelector().resourceId(Res.NOTIFICATION_BAR_HEADER_RES)); if (notificationHeader.waitForExists(5L)) { notificationHeader.click(); notificationHeader.swipeDown(3); } else { Log.d(TAG, "notification bar header not found"); } openNotificationQuickPanel(device); }</code><technical_language>Is a scenario want proceed ? If not, return here. for "notification bar header found" case</technical_language>

Target:
private static void openExtendedNotificationsPanel(UiDevice device) throws UiObjectNotFoundException { new NetworkUtilPopupWatcher(device).checkForCondition(); device.openNotification(); new NetworkUtilPopupWatcher(device).checkForCondition(); UiObject expandIndicator = device.findObject(new UiSelector().resourceId(Res.NOTIFICATION_BAR_EXPAND_RES)); if (expandIndicator.waitForExists(5L)) { expandIndicator.clickAndWaitForNewWindow(); } else { Log.d(TAG, "tray expander icon not found"); } UiObject notificationHeader = device.findObject(new UiSelector().resourceId(Res.NOTIFICATION_BAR_HEADER_RES)); if (notificationHeader.waitForExists(5L)) { notificationHeader.click(); notificationHeader.swipeDown(3); } else { Log.d(TAG, "notification bar header not found"); } openNotificationQuickPanel(device); }
Source:
<code>protected void initialize() { <START> goalInitial = editedCommand.getGoal(); <END> view.setAvailableGoals(goalRegistry.getAllGoals()); view.setGoal(goalInitial); }</code><technical_language>initialGoal? a bit context, this name odd me</technical_language>

Target:
protected void initialize() { initialGoal = editedCommand.getGoal(); view.setAvailableGoals(goalRegistry.getAllGoals()); view.setGoal(initialGoal); }
Source:
<code>public static boolean validate(String userVarValue) { <START> List<String> validUserVars = new ArrayList<String>(); <END> validUserVars.add(_PREFIX_USER_VAR + UserField.Id.field + _SURFIX_USER_VAR); validUserVars.add(_PREFIX_USER_VAR + UserField.First_Name.field + _SURFIX_USER_VAR); validUserVars.add(_PREFIX_USER_VAR + UserField.Last_Name.field + _SURFIX_USER_VAR); validUserVars.add(_PREFIX_USER_VAR + UserField.User_Name.field + _SURFIX_USER_VAR); validUserVars.add(_PREFIX_USER_VAR + UserField.Language.field + _SURFIX_USER_VAR); boolean result = true; if (userVarValue.startsWith(_PREFIX_USER_VAR) && userVarValue.endsWith(_SURFIX_USER_VAR)) { if (!validUserVars.contains(userVarValue)) { String propertyFieldHead = _PREFIX_USER_VAR + UserField.Properties.field + "[\""; String propertyFieldTail = "\"]" + _SURFIX_USER_VAR; if (!(userVarValue.startsWith(propertyFieldHead) && userVarValue.endsWith(propertyFieldTail))) { result = false; } } } return result; }</code><technical_language>Change List<String> validUserVars = new ArrayList<>();</technical_language>

Target:
public static boolean validate(String userVarValue) { boolean isUserVarPattern = userVarValue.startsWith(_PREFIX_USER_VAR) && userVarValue.endsWith(_SUFFIX_USER_VAR); if (isUserVarPattern) { String propertyFieldHead = _PREFIX_USER_VAR + UserField.Properties.field + "[\""; String propertyFieldTail = "\"]" + _SUFFIX_USER_VAR; boolean propPattern = userVarValue.startsWith(propertyFieldHead) && userVarValue.endsWith(propertyFieldTail) && userVarValue.length() > propertyFieldHead.length() + propertyFieldTail.length(); if (!validUserVars.contains(userVarValue) && !propPattern) { return false; } } return true; }
Source:
<code>public @ResponseBody ResponseEntity<Object> importXML(@RequestParam("file") MultipartFile xmlFile) { String username = GroupsThreadStore.getUsername(); log.info("User has submitted a bulk metadata update package", username); Map<String, Object> result = new HashMap<>(); result.put("action", "import xml"); result.put("username", username); String userEmail = GroupsThreadStore.getEmail(); try (InputStream importStream = xmlFile.getInputStream()) { <START> service.pushJobToQueue(result, importStream, username, userEmail); <END> } catch (IOException e) { log.error("Error creating or writing to import file: {}", e); result.put("error", e.getMessage()); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } catch (IllegalArgumentException e) { log.error("Error queueing the job: {}", e); result.put("error", e.getMessage()); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } result.put("message", "Import of metadata has begun. " + userEmail + " will be emailed when the update completes"); result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }</code><technical_language>noticed now, willing update this pass in AgentPrincipal service pull current thread? is other controllers working, means service opinionated groups submitted. Also, agent principal contains username replace username parameter it</technical_language>

Target:
public @ResponseBody ResponseEntity<Object> importXML(@RequestParam("file") MultipartFile xmlFile) { AgentPrincipals agent = AgentPrincipals.createFromThread(); String userEmail = GroupsThreadStore.getEmail(); log.info("User with email has submitted a bulk metadata update package", userEmail); Map<String, Object> result = new HashMap<>(); result.put("action", "import xml"); result.put("username", agent.getUsername()); result.put("user email", userEmail); try (InputStream importStream = xmlFile.getInputStream()) { service.pushJobToQueue(result, importStream, agent, userEmail); } catch (IOException e) { log.error("Error creating or writing to import file: {}", e); result.put("error", e.getMessage()); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } catch (IllegalArgumentException e) { log.error("Error queueing the job: {}", e); result.put("error", e.getMessage()); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } result.put("message", "Import of metadata has begun. " + userEmail + " will be emailed when the update completes"); result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }
Source:
<code>public String getStudyHost(String studyOid) throws Exception { String pManageUrl = CoreResources.getField("portalURL"); String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid; URL eURL = new URL(pManageUrl + "/app/rest/oc/authorizations" + "?studyoid=" + studyOid + "&instanceurl=" + ocUrl); HttpURLConnection con = null; DataInputStream input = null; String response = null; try { con = (HttpURLConnection)eURL.openConnection(); con.setConnectTimeout(5000); con.setReadTimeout(5000); con.setRequestMethod("GET"); input = new DataInputStream( con.getInputStream()); response = IOUtils.toString(input, "UTF-8"); } catch (Exception e) { logger.error(e.getMessage()); logger.error(ExceptionUtils.getStackTrace(e)); } finally{ } if (response.isEmpty()) return ""; JSONObject json = JSONObject.fromObject(response); if (json.isEmpty()) return ""; JSONObject studyHost = json.getJSONObject("study"); <START> String[] arrayUrl = pManageUrl.split(":"); <END> String tmpProtocol = arrayUrl[0]; String tmpUrl = arrayUrl[1]; String tmpPort = arrayUrl[2]; tmpUrl = tmpUrl.substring(2); String[] tmpArr = tmpUrl.split("\\."); String[] tmpMore = new String[tmpArr.length + 1]; if (tmpArr.length > 2) { tmpArr[0] = studyHost.getString("host"); } else { tmpMore[0] = studyHost.getString("host"); System.arraycopy(tmpArr, 0, tmpMore, 1, tmpArr.length); tmpArr = tmpMore; } StringBuffer urlBuilder = new StringBuffer(); for (int i = 0; i < tmpArr.length; i++) { urlBuilder.append(tmpArr[i]); if (i != tmpArr.length - 1) { urlBuilder.append("."); } else { urlBuilder.append(":" + tmpPort); } } if (!studyHost.isNullObject()) return "http://"+urlBuilder.toString()+ "/#/login"; else return ""; }</code><technical_language>Put this code in method</technical_language>

Target:
public String getStudyHost(String studyOid) throws Exception { String pManageUrl = CoreResources.getField("portalURL"); String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid; URL eURL = new URL(pManageUrl + "/app/rest/oc/authorizations" + "?studyoid=" + studyOid + "&instanceurl=" + ocUrl); HttpURLConnection con = null; DataInputStream input = null; String response = null; try { con = (HttpURLConnection)eURL.openConnection(); con.setConnectTimeout(5000); con.setReadTimeout(5000); con.setRequestMethod("GET"); input = new DataInputStream( con.getInputStream()); response = IOUtils.toString(input, "UTF-8"); } catch (Exception e) { logger.error(e.getMessage()); logger.error(ExceptionUtils.getStackTrace(e)); } finally{ } if (response.isEmpty()) return ""; JSONObject json = JSONObject.fromObject(response); if (json.isEmpty()) return ""; JSONObject studyHost = json.getJSONObject("study"); StringBuffer urlBuilder = buildUrl(pManageUrl, studyHost); if (!studyHost.isNullObject()) return "http://" + urlBuilder.toString() + "/#/login"; else return ""; }
Source:
<code>private void analyzeDescDatabase(ASTNode ast) throws SemanticException { boolean isExtended; String dbName; if (ast.getChildCount() == 1) { dbName = stripQuotes(ast.getChild(0).getText()); isExtended = false; } else if (ast.getChildCount() == 2) { dbName = stripQuotes(ast.getChild(0).getText()); isExtended = true; } else { throw new SemanticException("Unexpected Tokens at DESCRIBE DATABASE"); } DescDatabaseDesc descDbDesc = new DescDatabaseDesc(ctx.getResFile(), dbName, isExtended); inputs.add(new ReadEntity(getDatabase(dbName))); rootTasks.add(TaskFactory.get(new DDLWork2(getInputs(), getOutputs(), descDbDesc))); <START> setFetchTask(createFetchTask(DESC_DATABASE_SCHEMA)); <END> }</code><technical_language>I schema works similarily earlier; asking DDLWork for schema? based desc</technical_language>

Target:
private void analyzeDescDatabase(ASTNode ast) throws SemanticException { boolean isExtended; String dbName; if (ast.getChildCount() == 1) { dbName = stripQuotes(ast.getChild(0).getText()); isExtended = false; } else if (ast.getChildCount() == 2) { dbName = stripQuotes(ast.getChild(0).getText()); isExtended = true; } else { throw new SemanticException("Unexpected Tokens at DESCRIBE DATABASE"); } DescDatabaseDesc descDbDesc = new DescDatabaseDesc(ctx.getResFile(), dbName, isExtended); inputs.add(new ReadEntity(getDatabase(dbName))); rootTasks.add(TaskFactory.get(new DDLWork2(getInputs(), getOutputs(), descDbDesc))); setFetchTask(createFetchTask(DescDatabaseDesc.DESC_DATABASE_SCHEMA)); }
Source:
<code>private boolean isJsonOutputRequired(List <String> installationArgs) { int jsonIndex = installationArgs.indexOf("--json"); if (jsonIndex > -1 ) { return jsonIndex == installationArgs.size() - 1 || !installationArgs.get(jsonIndex).equals("false"); } <START> return installationArgs.contains("--json=true"); <END> }</code><technical_language>If jsonIndex == -1, --json in installationArgs. Conclusion: installationArgs.contains("--json=true") is false</technical_language>

Target:
static boolean isJsonOutputRequired(List <String> installationArgs) { int jsonIndex = installationArgs.indexOf("--json"); if (jsonIndex > -1 ) { return jsonIndex == installationArgs.size() - 1 || !installationArgs.get(jsonIndex + 1).equals("false"); } return installationArgs.contains("--json=true"); }
Source:
<code>public ArrayList<BookieSocketAddress> newEnsemble(int ensembleSize, int writeQuorumSize) throws BKNotEnoughBookiesException { try { <START> return placementPolicy.newEnsemble(ensembleSize, writeQuorumSize, quarantinedBookies.asMap().keySet()); <END> } catch (BKNotEnoughBookiesException e) { if (logger.isDebugEnabled()) { logger.debug("Not enough healthy bookies available, using quarantined bookies"); } return placementPolicy.newEnsemble(ensembleSize, writeQuorumSize, EMPTY_SET); } }</code><technical_language>key set modified in #newEnsembel(). create a new set current quarantinedBookies's key set</technical_language>

Target:
public ArrayList<BookieSocketAddress> newEnsemble(int ensembleSize, int writeQuorumSize) throws BKNotEnoughBookiesException { try { return placementPolicy.newEnsemble(ensembleSize, writeQuorumSize, new HashSet<BookieSocketAddress>( quarantinedBookies.asMap().keySet())); } catch (BKNotEnoughBookiesException e) { if (logger.isDebugEnabled()) { logger.debug("Not enough healthy bookies available, using quarantined bookies"); } return placementPolicy.newEnsemble(ensembleSize, writeQuorumSize, EMPTY_SET); } }
Source:
<code>public void finishedReplication(Replicator replicator) { synchronized (replicator) { remove(replicator); if (replicatorsInProgress.size() == 0 && mReplicationsCompletedListener != null) { mReplicationsCompletedListener.allReplicationsCompleted(); <START> } <END> } }</code><technical_language>I understand this block synchronized a replicator is useful -- explain? get event multiple replicators concurrently, problematic this concurrently</technical_language>

Target:
public void finishedReplication(Replicator replicator) { synchronized (replicatorsInProgress) { remove(replicator); if (replicatorsInProgress.size() == 0 && mReplicationsCompletedListener != null) { mReplicationsCompletedListener.allReplicationsCompleted(); } } }
Source:
<code>public void stop() { try { for (WorkerWrapper workerWrapper : zkWorkers.values()) { <START> workerWrapper.getWatcher().close(); <END> } } catch (Exception e) { throw Throwables.propagate(e); } finally { started = false; } }</code><technical_language>I if Wrapper a close() method if instead of making people stored closed</technical_language>

Target:
public void stop() { try { for (WorkerWrapper workerWrapper : zkWorkers.values()) { workerWrapper.close(); } } catch (Exception e) { throw Throwables.propagate(e); } finally { started = false; } }
Source:
<code><START> public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException <END> { Configuration conf = context.getConfiguration(); final String segmentPaths = conf.get(CONF_INPUT_SEGMENTS); logger.info("Segment Paths = " + segmentPaths); List<InputSplit> splits = Lists.transform( (List<String>)new ObjectMapper().readValue(segmentPaths, new TypeReference<List<String>>() {}), new Function<String, InputSplit>() { @Override public InputSplit apply(String input) { return new DatasourceInputSplit(input); } } ); logger.info("Number of splits = " + splits.size()); return splits; }</code><technical_language>feel a DataSegmentInputSplit <LINK_0> ? Alternatively a "HadoopDataSegment" a hadoopy loadSpec is a URI parsable hadoop (in addition other a DataSegment has. allow peon/overlord setup stuff correctly for hadoop. data get splits done completely, is a matter of ensuring data propagated Hadoop correctly</technical_language>

Target:
public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); String segmentsStr = Preconditions.checkNotNull(conf.get(CONF_INPUT_SEGMENTS), "No segments found to read"); List<DataSegment> segments = HadoopDruidIndexerConfig.jsonMapper.readValue( segmentsStr, new TypeReference<List<DataSegment>>() { } ); if (segments == null || segments.size() == 0) { throw new ISE("No segments found to read"); } logger.info("segments to read [%s]", segmentsStr); long maxSize = conf.getLong(CONF_MAX_SPLIT_SIZE, 0); if (maxSize > 0) { Collections.sort( segments, new Comparator<DataSegment>() { @Override public int compare(DataSegment s1, DataSegment s2) { return Long.compare(s1.getSize(), s2.getSize()); } } ); } List<InputSplit> splits = Lists.newArrayList(); List<DataSegment> list = new ArrayList<>(); long size = 0; for (DataSegment segment : segments) { if (size + segment.getSize() > maxSize && size > 0) { splits.add(new DatasourceInputSplit(list)); list = Lists.newArrayList(); size = 0; } list.add(segment); size += segment.getSize(); } if (list.size() > 0) { splits.add(new DatasourceInputSplit(list)); } logger.info("Number of splits [%d]", splits.size()); return splits; }
Source:
<code>public Connection connect(Shell shell, String connectionString) { disconnect(); connection = ConnectionFactory.getConnection(connectionString, sslContext); try { connection.connect(); } catch (AccessDeniedException accessDenied) { try { <START> connection.close(); <END> String username = null; String password = null; if (shell != null) { username = shell.readLine(Messages.MSG.username()); password = username.isEmpty() ? null : shell.readLine(new Prompt(Messages.MSG.password(), '*')); } else { java.io.Console sysConsole = System.console(); if (sysConsole != null) { username = sysConsole.readLine(Messages.MSG.username()); password = username.isEmpty() ? null : new String(sysConsole.readPassword(Messages.MSG.password())); } else { } } connection.connect(username, password); } catch (Exception e) { disconnect(); showError(shell, e); } } catch (IOException e) { disconnect(); showError(shell, e); } refreshPrompt(); return connection; }</code><technical_language>Util.close(connection) maybe</technical_language>

Target:
public Connection connect(Shell shell, String connectionString) { disconnect(); connection = ConnectionFactory.getConnection(connectionString, sslContext); try { connection.connect(); } catch (AccessDeniedException accessDenied) { try { Util.close(connection); String username = null; String password = null; if (shell != null) { username = shell.readLine(Messages.MSG.username()); password = username.isEmpty() ? null : shell.readLine(new Prompt(Messages.MSG.password(), '*')); } else { java.io.Console sysConsole = System.console(); if (sysConsole != null) { username = sysConsole.readLine(Messages.MSG.username()); password = username.isEmpty() ? null : new String(sysConsole.readPassword(Messages.MSG.password())); } else { } } connection.connect(username, password); } catch (Exception e) { disconnect(); showError(shell, e); } } catch (IOException e) { disconnect(); showError(shell, e); } refreshPrompt(); return connection; }
Source:
<code>public Iterable<Protos.Resource> getScalarResource(Protos.Offer offer, String name, Double value, Double used) { String role = cfg.getFrameworkRole(); ArrayList<Protos.Resource> resources = new ArrayList<>(); double resourceDoubleValue = 0; for (Protos.Resource r : offer.getResourcesList()) { if (r.getName().equals(name) && r.hasRole() && r.getRole().equals(role) && r.hasScalar()) { resourceDoubleValue = r.getScalar().getValue(); if (resourceDoubleValue - used > 0) { resources.add(Protos.Resource.newBuilder().setName(name).setType(Protos.Value.Type.SCALAR) .setScalar(Protos.Value.Scalar.newBuilder().setValue(Math.min(value, resourceDoubleValue - used)).build()) .setRole(role).build()); } break; } else if (r.getName().equals(name) && r.hasRole() && r.getRole().equals(role)) { LOGGER.warn("Resource with name: " + name + "expected type to be SCALAR check configuration on: " + offer.getHostname()); } } if (value - Math.max((resourceDoubleValue - used), 0) > 0) { resources.add(Protos.Resource.newBuilder().setName(name).setType(Protos.Value.Type.SCALAR) <START> .setScalar(Protos.Value.Scalar.newBuilder().setValue(value - Math.max((resourceDoubleValue - used), 0)).build()) <END> .build()); } return resources; }</code><technical_language>Suggest a local variable for of Math.max(resourceDoubleValue - used, 0)</technical_language>

Target:
public Iterable<Protos.Resource> getScalarResource(Protos.Offer offer, String name, Double value, Double used) { String role = cfg.getFrameworkRole(); ArrayList<Protos.Resource> resources = new ArrayList<>(); double resourceDifference = 0; for (Protos.Resource r : offer.getResourcesList()) { if (r.getName().equals(name) && r.hasRole() && r.getRole().equals(role) && r.hasScalar()) { resourceDifference = Math.max(r.getScalar().getValue() - used, 0.0); if (resourceDifference > 0) { resources.add(Protos.Resource.newBuilder().setName(name).setType(Protos.Value.Type.SCALAR) .setScalar(Protos.Value.Scalar.newBuilder().setValue(Math.min(value, resourceDifference)).build()) .setRole(role).build()); } break; } else if (r.getName().equals(name) && r.hasRole() && r.getRole().equals(role)) { LOGGER.warn("Resource with name: " + name + "expected type to be SCALAR check configuration on: " + offer.getHostname()); } } if (value - resourceDifference > 0) { resources.add(Protos.Resource.newBuilder().setName(name).setType(Protos.Value.Type.SCALAR) .setScalar(Protos.Value.Scalar.newBuilder().setValue(value - resourceDifference).build()) .build()); } return resources; }
Source:
<code><START> public void importExportKMeansModelTest(){ <END> Path mdlPath = Paths.get(mdlFilePath); KMeansModel mdl = getClusterModel(); Exporter<KMeansModelFormat, String> exporter = new FileExporter<>(); mdl.saveModel(exporter, mdlFilePath); Assert.assertTrue(String.format("File %s not found", mdlPath.toString()), Files.exists(mdlPath)); KMeansModelFormat load = exporter.load(mdlFilePath); KMeansModel importedMdl = new KMeansModel(load.getCenters(), load.getDistance()); Assert.assertTrue("", mdl.equals(importedMdl)); }</code><technical_language>this changes(and test too) import/export, kmeans model. increase coverage</technical_language>

Target:
public void importExportKMeansModelTest(){ Path mdlPath = Paths.get(mdlFilePath); KMeansModel mdl = getClusterModel(); Exporter<KMeansModelFormat, String> exporter = new FileExporter<>(); mdl.saveModel(exporter, mdlFilePath); Assert.assertTrue(String.format("File %s not found.", mdlPath.toString()), Files.exists(mdlPath)); KMeansModelFormat load = exporter.load(mdlFilePath); KMeansModel importedMdl = new KMeansModel(load.getCenters(), load.getDistance()); Assert.assertTrue("", mdl.equals(importedMdl)); }
Source:
<code>public void testComposedFunctionIsAppliedToExistingMessageSource() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( TestChannelBinderConfiguration.getCompleteConfiguration(FunctionsConfiguration.class)).web( WebApplicationType.NONE) .run("--spring.cloud.stream.function.definition=toUpperCase|concatWithSelf", "--spring.jmx.enabled=false")) { OutputDestination target = context.getBean(OutputDestination.class); assertThat(target.receive(1000).getPayload()).isEqualTo( "HELLO FUNCTION:HELLO FUNCTION".getBytes(StandardCharsets.UTF_8)); <START> context.close(); <END> } }</code><technical_language>need do this try-with-resource: <LINK_0></technical_language>

Target:
public void testComposedFunctionIsAppliedToExistingMessageSource() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( TestChannelBinderConfiguration.getCompleteConfiguration(FunctionsConfiguration.class)).web( WebApplicationType.NONE) .run("--spring.cloud.stream.function.definition=toUpperCase|concatWithSelf", "--spring.jmx.enabled=false")) { OutputDestination target = context.getBean(OutputDestination.class); assertThat(target.receive(1000).getPayload()).isEqualTo( "HELLO FUNCTION:HELLO FUNCTION".getBytes(StandardCharsets.UTF_8)); } }
Source:
<code>protected void buttonPressed(int buttonId) { switch (buttonId) { case DELETE_ID: ILaunchConfiguration c = getLaunchConfiguration(); if (c.isWorkingCopy()) c = ((ILaunchConfigurationWorkingCopy)c).getOriginal(); final ILaunchConfiguration config = c; if (MessageDialog.openConfirm(getShell(), Messages.LaunchConfigurationEditDialog_3, Messages.LaunchConfigurationEditDialog_4 + config.getName())) { new Job(Messages.LaunchConfigurationEditDialog_5) { protected IStatus run(IProgressMonitor monitor) { try { config.delete(); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }; }.schedule(); cancelPressed(); } break; case DUPLICATE_ID: final ILaunchConfiguration original = getLaunchConfiguration(); final String newName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(original.getName()); final Shell shell = getParentShell(); final LaunchGroupExtension group = getLaunchGroup(); <START> new Job(Messages.LaunchConfigurationEditDialog_6) { <END> protected IStatus run(IProgressMonitor monitor) { try { final ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName); final ILaunchConfiguration newConfig = newWorkingCopy.doSave(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { new LaunchConfigurationEditDialog(shell, newConfig, group).open(); } }); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }; }.schedule(); cancelPressed(); break; case LAUNCH_ID: okPressed(); Activator.runCommand(Activator.CMD_LAUNCH); break; default: super.buttonPressed(buttonId); } }</code><technical_language>a UIJob</technical_language>

Target:
protected void buttonPressed(int buttonId) { switch (buttonId) { case DELETE_ID: ILaunchConfiguration c = getLaunchConfiguration(); if (c.isWorkingCopy()) c = ((ILaunchConfigurationWorkingCopy)c).getOriginal(); final ILaunchConfiguration config = c; if (MessageDialog.openConfirm(getShell(), Messages.LaunchConfigurationEditDialog_3, Messages.LaunchConfigurationEditDialog_4 + config.getName())) { new Job(Messages.LaunchConfigurationEditDialog_5) { protected IStatus run(IProgressMonitor monitor) { try { config.delete(); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }; }.schedule(); cancelPressed(); } break; case DUPLICATE_ID: final ILaunchConfiguration original = getLaunchConfiguration(); final String newName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(original.getName()); final Shell shell = getParentShell(); final LaunchGroupExtension group = getLaunchGroup(); new UIJob(Messages.LaunchConfigurationEditDialog_6) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { try { final ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName); final ILaunchConfiguration newConfig = newWorkingCopy.doSave(); new LaunchConfigurationEditDialog(shell, newConfig, group).open(); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }.schedule(); cancelPressed(); break; case LAUNCH_ID: okPressed(); Activator.runCommand(Activator.CMD_LAUNCH); break; default: super.buttonPressed(buttonId); } }
Source:
<code>public Symbol newSymbol(Expression expression, Type type, String suffix) { String nameHint = "expr"; if (expression instanceof Identifier) { nameHint = ((Identifier) expression).getName(); } else if (expression instanceof FunctionCall) { nameHint = ((FunctionCall) expression).getName().getSuffix(); } else if (expression instanceof SymbolReference) { nameHint = ((SymbolReference) expression).getName(); } else if (expression instanceof GroupingOperation) { <START> nameHint = "grouping_operation"; <END> } return newSymbol(nameHint, type, suffix); }</code><technical_language>"grouping"</technical_language>

Target:
public Symbol newSymbol(Expression expression, Type type, String suffix) { String nameHint = "expr"; if (expression instanceof Identifier) { nameHint = ((Identifier) expression).getName(); } else if (expression instanceof FunctionCall) { nameHint = ((FunctionCall) expression).getName().getSuffix(); } else if (expression instanceof SymbolReference) { nameHint = ((SymbolReference) expression).getName(); } else if (expression instanceof GroupingOperation) { nameHint = "grouping"; } return newSymbol(nameHint, type, suffix); }
Source:
<code>public Object sampleVal() { checkHasParams(); <START> double x = lower + Math.floor(Util.random() * (upper - lower + 1)); <END> return new Integer((int) x); }</code><technical_language>Util.randInt()</technical_language>

Target:
public Object sampleVal() { return sample_value(); }
Source:
<code>private String createConsumerClientId(Properties props) { String prefix = props.getProperty(KafkaSourceOptions.CLIENT_ID_PREFIX.key()); <START> return prefix + "-" + new Random().nextLong(); <END> }</code><technical_language>pass in subtaskId append subtaskId suffix</technical_language>

Target:
private String createConsumerClientId(Properties props) { String prefix = props.getProperty(KafkaSourceOptions.CLIENT_ID_PREFIX.key()); return prefix + "-" + subtaskId; }
Source:
<code>static Spannable getSpannableContentForRanges(FormattableContent formattableContent, TextView textView, final NoteBlock.OnNoteBlockTextClickListener onNoteBlockTextClickListener, boolean isFooter) { return getSpannableContentForRanges(formattableContent, textView, isFooter, <START> new Function1<NoteBlockClickableSpan, Unit>() { <END> @Override public Unit invoke(NoteBlockClickableSpan noteBlockClickableSpan) { onNoteBlockTextClickListener.onNoteBlockTextClicked(noteBlockClickableSpan); return null; } }); }</code><technical_language>Creates function listener is null</technical_language>

Target:
static Spannable getSpannableContentForRanges(FormattableContent formattableContent, TextView textView, final NoteBlock.OnNoteBlockTextClickListener onNoteBlockTextClickListener, boolean isFooter) { Function1<NoteBlockClickableSpan, Unit> clickListener = onNoteBlockTextClickListener != null ? new Function1<NoteBlockClickableSpan, Unit>() { @Override public Unit invoke(NoteBlockClickableSpan noteBlockClickableSpan) { onNoteBlockTextClickListener.onNoteBlockTextClicked(noteBlockClickableSpan); return null; } } : null; return getSpannableContentForRanges(formattableContent, textView, isFooter, clickListener); }