auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private List<KfsToPMWSupplierDiversityDTO> buildPmwToKfsSupplierDiversityList(String sqlToRun) { List<KfsToPMWSupplierDiversityDTO> supplierList = new ArrayList<KfsToPMWSupplierDiversityDTO>(); List<PaymentWorksSupplierDiversityMapDatabaseRow> pmwToKfsDiversityDatabaseRows = findActiveSupplierDiversitiesForMap(sqlToRun); if (ObjectUtils.isNotNull(pmwToKfsDiversityDatabaseRows) && !pmwToKfsDiversityDatabaseRows.isEmpty()) { for (PaymentWorksSupplierDiversityMapDatabaseRow row : pmwToKfsDiversityDatabaseRows) { supplierList.add(new KfsToPMWSupplierDiversityDTO(row.getKfsSupplierDiversityCode(), row.getKfsSupplierDiversityDescription(), row.getPmwSupplierDiversityDescription())); } for (KfsToPMWSupplierDiversityDTO dto : supplierList) { <START> LOG.info("buildPmwToKfsSupplierDiversityList, KfsToPMWSupplierDiversityDTO: " + dto.toString()); <END> } } return supplierList; }</code><technical_language>do want log supplier diversity list this debug only</technical_language>

Target:
private List<KfsToPMWSupplierDiversityDTO> buildPmwToKfsSupplierDiversityList(String sqlToRun) { List<KfsToPMWSupplierDiversityDTO> supplierList = new ArrayList<KfsToPMWSupplierDiversityDTO>(); List<PaymentWorksSupplierDiversityMapDatabaseRow> pmwToKfsDiversityDatabaseRows = findActiveSupplierDiversitiesList(sqlToRun); if (ObjectUtils.isNotNull(pmwToKfsDiversityDatabaseRows) && !pmwToKfsDiversityDatabaseRows.isEmpty()) { for (PaymentWorksSupplierDiversityMapDatabaseRow row : pmwToKfsDiversityDatabaseRows) { supplierList.add(new KfsToPMWSupplierDiversityDTO(row.getKfsSupplierDiversityCode(), row.getKfsSupplierDiversityDescription(), row.getPmwSupplierDiversityDescription())); } if (LOG.isDebugEnabled()) { for (KfsToPMWSupplierDiversityDTO dto : supplierList) { LOG.debug("buildPmwToKfsSupplierDiversityList, KfsToPMWSupplierDiversityDTO: " + dto.toString()); } } } return supplierList; }
Source:
<code>public Response updateAsset(@PathParam(CuCamsConstants.CapAssetApi.CAPITAL_ASSET_NUMBER) String capitalAssetNumber, @Context HttpHeaders headers) { try { if (!validateUpdateAssetQueryParameters()) { <START> LOG.warn("Bad Request for Asset Inventory #" + capitalAssetNumber + " " + servletRequest.getQueryString()); <END> return respondBadRequest(); } LOG.info("Requesting Capital Asset Inventory #" + capitalAssetNumber + " " + servletRequest.getQueryString()); String conditionCode = servletRequest.getParameter(CuCamsConstants.CapAssetApi.CONDITION_CODE); String buildingCode = servletRequest.getParameter(CuCamsConstants.CapAssetApi.BUILDING_CODE); String roomNumber = servletRequest.getParameter(CuCamsConstants.CapAssetApi.ROOM_NUMBER); Asset asset = getCuAssetService().updateAssetInventory(capitalAssetNumber, conditionCode, buildingCode, roomNumber); LOG.info("Updated Capital Asset Inventory #" + capitalAssetNumber + " " + asset.getLastInventoryDate().toString()); Properties properties = getAssetProperties(asset); return Response.ok(gson.toJson(properties)).build(); } catch (Exception ex) { LOG.error("updateAsset", ex); return ex instanceof BadRequestException ? respondBadRequest() : respondInternalServerError(ex); } }</code><technical_language>Method name is missing log message. Also, this specific message warning level error level</technical_language>

Target:
public Response updateAsset(@PathParam(CuCamsConstants.CapAssetApi.CAPITAL_ASSET_NUMBER) String capitalAssetNumber, @Context HttpHeaders headers) { try { if (!validateUpdateAssetQueryParameters()) { LOG.error("updateAsset: Bad Request for Asset Inventory #" + capitalAssetNumber + " " + servletRequest.getQueryString()); return respondBadRequest(); } LOG.info("updateAsset: Requesting Capital Asset Inventory #" + capitalAssetNumber + " " + servletRequest.getQueryString()); String conditionCode = servletRequest.getParameter(CuCamsConstants.CapAssetApi.CONDITION_CODE); String buildingCode = servletRequest.getParameter(CuCamsConstants.CapAssetApi.BUILDING_CODE); String roomNumber = servletRequest.getParameter(CuCamsConstants.CapAssetApi.ROOM_NUMBER); Asset asset = getCuAssetService().updateAssetInventory(capitalAssetNumber, conditionCode, buildingCode, roomNumber); if (ObjectUtils.isNull(asset)) { LOG.error("updateAsset: Asset Inventory #" + capitalAssetNumber + " Not Found"); return respondNotFound(); } LOG.info("updateAsset: Updated Capital Asset Inventory #" + capitalAssetNumber + " " + asset.getLastInventoryDate().toString()); Properties properties = getAssetProperties(asset); return Response.ok(gson.toJson(properties)).build(); } catch (Exception ex) { LOG.error("updateAsset", ex); return ex instanceof BadRequestException ? respondBadRequest() : respondInternalServerError(ex); } }
Source:
<code>private String resolveStackPointerName() throws Throwable { <START> get_X86_REGS(); <END> String sp_name = "rsp"; if (fRegisterNames.contains(sp_name)) { return sp_name; } sp_name = "esp"; if (fRegisterNames.contains(sp_name)) { return sp_name; } sp_name = "sp"; if (fRegisterNames.contains(sp_name)) { return sp_name; } return null; }</code><technical_language>Store this result in a local global fRegisterNames. is pattern meant get_X86_REGS()</technical_language>

Target:
private String resolveStackPointerName() throws Throwable { List<String> regNames = get_X86_REGS(); String sp_name = "rsp"; if (regNames.contains(sp_name)) { return sp_name; } sp_name = "esp"; if (regNames.contains(sp_name)) { return sp_name; } sp_name = "sp"; if (regNames.contains(sp_name)) { return sp_name; } return null; }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { List<RepositoryTreeNode<?>> nodes = getSelectedNodes(); Set<WorkingDirNode> nodesToCollapse = nodes.stream() <START> .map(n -> getWorkingDirParent(n)).filter(n -> n != null) <END> .collect(Collectors.toSet()); if (!nodesToCollapse.isEmpty()) { CommonViewer viewer = getView(event).getCommonViewer(); for (WorkingDirNode node : nodesToCollapse) { viewer.collapseToLevel(node, AbstractTreeViewer.ALL_LEVELS); } } return null; }</code><technical_language>try lambdas method references in new code. .map(this::getWorkingDirParent).filter(Objects::nonNull)</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { List<RepositoryTreeNode<?>> nodes = getSelectedNodes(); Set<WorkingDirNode> nodesToCollapse = nodes.stream() .map(this::getWorkingDirParent).filter(Objects::nonNull) .collect(Collectors.toSet()); if (!nodesToCollapse.isEmpty()) { CommonViewer viewer = getView(event).getCommonViewer(); for (WorkingDirNode node : nodesToCollapse) { viewer.collapseToLevel(node, AbstractTreeViewer.ALL_LEVELS); } } return null; }
Source:
<code>Main(Logger console) { this.console = console; this.jc = new JCommander(this); this.help = new Help(jc, console); jc.setProgramName(PROGRAM_NAME); jc.addCommand("help", help, "-h", "-help", "--help"); jc.addCommand("create", new CreateDatasetCommand(console)); jc.addCommand("copy", new CopyCommand(console)); jc.addCommand("transform", new TransformCommand(console)); jc.addCommand("update", new UpdateDatasetCommand(console)); jc.addCommand("delete", new DeleteDatasetCommand(console)); jc.addCommand("schema", new SchemaCommand(console)); jc.addCommand("info", new InfoCommand(console)); jc.addCommand("show", new ShowRecordsCommand(console)); jc.addCommand("csv-schema", new CSVSchemaCommand(console)); jc.addCommand("csv-import", new CSVImportCommand(console)); jc.addCommand("obj-schema", new ObjectSchemaCommand(console)); jc.addCommand("partition-config", new CreatePartitionStrategyCommand(console)); jc.addCommand("mapping-config", new CreateColumnMappingCommand(console)); <START> jc.addCommand("logging-config", new LoggingConfigCommand(console)); <END> jc.addCommand("flume-config", new FlumeConfigCommand(console)); }</code><technical_language>naming, "logging-config" is general. "log4j-config" is more indicative of does. support other logging configuration formats in future adding a switch, OK</technical_language>

Target:
Main(Logger console) { this.console = console; this.jc = new JCommander(this); this.help = new Help(jc, console); jc.setProgramName(DEFAULT_PROGRAM_NAME); jc.addCommand("help", help, "-h", "-help", "--help"); jc.addCommand("create", new CreateDatasetCommand(console)); jc.addCommand("copy", new CopyCommand(console)); jc.addCommand("transform", new TransformCommand(console)); jc.addCommand("update", new UpdateDatasetCommand(console)); jc.addCommand("delete", new DeleteDatasetCommand(console)); jc.addCommand("schema", new SchemaCommand(console)); jc.addCommand("info", new InfoCommand(console)); jc.addCommand("show", new ShowRecordsCommand(console)); jc.addCommand("csv-schema", new CSVSchemaCommand(console)); jc.addCommand("csv-import", new CSVImportCommand(console)); jc.addCommand("obj-schema", new ObjectSchemaCommand(console)); jc.addCommand("partition-config", new CreatePartitionStrategyCommand(console)); jc.addCommand("mapping-config", new CreateColumnMappingCommand(console)); jc.addCommand("log4j-config", new Log4jConfigCommand(console)); jc.addCommand("flume-config", new FlumeConfigCommand(console)); }
Source:
<code>protected void deserializeBody(InputStream inputStream) throws IOException, MessageFormatException { <START> getBlobOperation.setBlobOutput(MessageFormatRecord.deserializeBlob(inputStream).getBlobOutput()); <END> }</code><technical_language>is true storing blobOutput right? do getBlobOutput() call</technical_language>

Target:
protected void deserializeBody(InputStream inputStream) throws IOException, MessageFormatException { BlobData blobData = MessageFormatRecord.deserializeBlob(inputStream); getBlobOperation.setBlobOutput(new BlobOutput(blobData.getSize(), blobData.getStream())); }
Source:
<code>public ListenableFuture<SubmissionResult> submit(Path path, ProgressObserver observer) throws TmcCoreException { UrlCommunicator communicator = new UrlCommunicator(settings); TmcApi tmcApi = new TmcApi(communicator, settings); ExerciseSubmitter exerciseSubmitter = new ExerciseSubmitter( new ProjectRootFinder(tmcApi), <START> new StudentFileAwareZipper(new EverythingIsStudentFileStudentFilePolicy()), <END> communicator, tmcApi, settings); Submit submit = new Submit( settings, exerciseSubmitter, new SubmissionPoller(tmcApi), path.toString(), observer); return threadPool.submit(submit); }</code><technical_language>this PR, want submit everything..</technical_language>

Target:
public ListenableFuture<SubmissionResult> submit(Path path, ProgressObserver observer) throws TmcCoreException { UrlCommunicator communicator = new UrlCommunicator(settings); TmcApi tmcApi = new TmcApi(communicator, settings); ExerciseSubmitter exerciseSubmitter = new ExerciseSubmitter( new ProjectRootFinder(tmcApi), new TaskExecutorImpl(), communicator, tmcApi, settings); Submit submit = new Submit( settings, exerciseSubmitter, new SubmissionPoller(tmcApi), path.toString(), observer); return threadPool.submit(submit); }
Source:
<code>@Override public void updateCounter(long val) { try { pCntr.update(val); } catch (IgniteCheckedException e) { <START> U.error(log, "Partition counter inconsistency is detected and new counter value will be ignored. " + <END> "Most probably a node with most actual data is out of topology or data streamer is used in isolated " + "mode (allowOverride=true) concurrently with normal cache operations [rebCntr=" + val + ", locCntr=" + pCntr + ']'); if (failNodeOnPartitionInconsistency) ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } }</code><technical_language>rebCntr name means? please provide original exception U.error a full stacktrace in case failNodeOnPartitionInconsistency is false</technical_language>

Target:
@Override public void updateCounter(long val) { try { pCntr.update(val); } catch (IgniteCheckedException e) { U.error(log, "Failed to update partition counter. " + "Most probably a node with most actual data is out of topology or data streamer is used " + "in preload mode (allowOverride=false) concurrently with cache transactions [grpName=" + grp.name() + ", partId=" + partId + ']', e); if (failNodeOnPartitionInconsistency) ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } }
Source:
<code>protected void refreshViewer(final Object object) { asyncViewerRefresh(new Runnable() { public void run() { synchronized (viewer) { final TreePath[] treePaths = viewer.getExpandedTreePaths(); if (object != null) { viewer.refresh(object); } else { viewer.refresh(); } <START> viewer.setExpandedTreePaths(treePaths); <END> } } }); }</code><technical_language>This line endless load linux a node zero children</technical_language>

Target:
protected void refreshViewer(final Object object) { asyncViewerRefresh(new Runnable() { public void run() { synchronized (viewer) { if (object != null) { viewer.refresh(object); } else { viewer.refresh(); } } } }); }
Source:
<code>protected void processViewUpdate(Grid grid2) { logger.debug("Player: " + playerNumber + " - UPDATE VIEW EVENT"); if(grid != null){ <START> Point p1 = new Point(0,0); <END> Point p2 = new Point(0,0); Point p1New = new Point(0,0); Point p2New = new Point(0,0); for(int j = 0; j != grid.getSize().height;j++){ for(int i = 0; i != grid.getSize().width; i++){ Point p = new Point(i,j); ArrayList<Entity> old = (ArrayList<Entity>) grid.get(p); ArrayList<Entity> newSquare = (ArrayList<Entity>) grid2.get(p); for(Entity e: old){ if(e.toString().equals("0")){ p1 = new Point(p); } else if(e.toString().equals("1")){ p2 = new Point(p); } } for(Entity e: newSquare){ if(e.toString().equals("0")){ p1New = new Point(p); } else if(e.toString().equals("1")){ p2New = new Point(p); } } } } if(p1 != null && p1New != null && (p1.x != p1New.x || p1.y != p1New.y)){ logger.info("Player 1 has moved from " +p1.x + "," + p1.y + " to " + p1New.x + "," + p1New.y); } if(p2 != null && p2New != null && (p2.x != p2New.x || p2.y != p2New.y)){ logger.info("Player 2 has moved from " +p2.x + "," + p2.y + " to " + p2New.x + "," + p2New.y); } } else{ logger.info("Player " + playerNumber + " first view of the grid"); } this.grid = grid2; }</code><technical_language>do: Point p1 = new Point(0, 0), p2 = new Point(p1), p1New = new Point(p1), p2New = new Point(p1);</technical_language>

Target:
protected void processViewUpdate(Grid grid2) { logger.debug("Player: " + playerNumber + " - UPDATE VIEW EVENT"); if(grid != null){ Point p1 = null, p2 = null, p1New = null, p2New = null; for (Point p : grid.keySet()) { ArrayList<Entity> old = (ArrayList<Entity>) grid.get(p); ArrayList<Entity> newSquare = (ArrayList<Entity>) grid2.get(p); for (Entity e : old) { if (e.toString().equals("0")) { p1 = new Point(p); } else if (e.toString().equals("1")) { p2 = new Point(p); } } for (Entity e : newSquare) { if (e.toString().equals("0")) { p1New = new Point(p); } else if (e.toString().equals("1")) { p2New = new Point(p); } } } if(p1 != null && p1New != null && (p1.x != p1New.x || p1.y != p1New.y)){ logger.info("Player 1 has moved from " +p1.x + "," + p1.y + " to " + p1New.x + "," + p1New.y); } if(p2 != null && p2New != null && (p2.x != p2New.x || p2.y != p2New.y)){ logger.info("Player 2 has moved from " +p2.x + "," + p2.y + " to " + p2New.x + "," + p2New.y); } } else{ logger.info("Player " + playerNumber + " first view of the grid"); } this.grid = grid2; }
Source:
<code>protected <X> X verifyEndpointReturningObject(final Function<T, X> methodRunner) { final X result = methodRunner.apply(clientBuilder.apply(localhost)); <START> assertThat(methodRunner.apply(clientBuilder.apply(localhost)), notNullValue()); <END> return result; }</code><technical_language>suggestion assertThat(result, notNullValue()); space difference beginning of diff a visual bug, space is added</technical_language>

Target:
protected <X> X verifyEndpointReturningObject(final Function<T, X> methodRunner) { final X result = methodRunner.apply(clientBuilder.apply(localhost)); assertThat(result, notNullValue()); return result; }
Source:
<code>private static void fillResponses(Operation swaggerOperation, org.restlet.ext.apispark.internal.model.Operation operation, Contract contract, Map<String, Object> parameters) { if (swaggerOperation == null) { return; } if (swaggerOperation.getResponses() != null) { for (Entry<String, Response> responseEntry : swaggerOperation .getResponses().entrySet()) { String key = responseEntry.getKey(); Response swaggerResponse = responseEntry.getValue(); int statusCode; try { statusCode = Integer.parseInt(key); } catch (NumberFormatException e) { <START> if (!key.equals("default")) { <END> LOGGER.warning(String.format( "Response '%s' for operation '%s' " + "could not be retrieved because its " + "key is not a valid status code.", key, swaggerOperation.getOperationId())); } continue; } fillResponse(statusCode, responseEntry.getValue(), swaggerOperation, operation, contract, parameters); } Response defaultSwaggerResponse = swaggerOperation.getResponses().get( "default"); if (defaultSwaggerResponse != null && operation.getResponse(200) == null) { fillResponse(200, defaultSwaggerResponse, swaggerOperation, operation, contract, parameters); } else if (defaultSwaggerResponse != null) { LOGGER.warning(String.format( "The 'default' response for the operation '%s' was " + "ignored because there is already a response for 200 " + "OK and the Restlet Framework does not support " + "'default' responses for other status codes.", swaggerOperation.getOperationId())); } } }</code><technical_language>do mind write instead? java if (!"default".equals(key)) {</technical_language>

Target:
private static void fillResponses(Operation swaggerOperation, org.restlet.ext.apispark.internal.model.Operation operation, Contract contract, Map<String, Object> parameters) { if (swaggerOperation == null) { return; } boolean operationHasSpecificSuccessResponse = false; if (swaggerOperation.getResponses() != null) { for (Entry<String, Response> responseEntry : swaggerOperation .getResponses().entrySet()) { String key = responseEntry.getKey(); Response swaggerResponse = responseEntry.getValue(); if ("default".equals(key)) { continue; } int statusCode; try { statusCode = Integer.parseInt(key); } catch (NumberFormatException e) { LOGGER.warning(String.format( "Response '%s' for operation '%s' " + "could not be retrieved because its " + "key is not a valid status code.", key, swaggerOperation.getOperationId())); continue; } if (Status.isSuccess(statusCode)) { operationHasSpecificSuccessResponse = true; } fillResponse(statusCode, swaggerResponse, swaggerOperation, operation, contract, parameters); } Response defaultSwaggerResponse = swaggerOperation.getResponses() .get("default"); if (defaultSwaggerResponse != null && !operationHasSpecificSuccessResponse) { fillResponse(200, defaultSwaggerResponse, swaggerOperation, operation, contract, parameters); } else if (defaultSwaggerResponse != null) { LOGGER.warning(String.format( "The 'default' response for the operation '%s' was " + "ignored because there is already a success response " + "and the Restlet Framework does not support " + "'default' responses for other status codes.", swaggerOperation.getOperationId())); } } }
Source:
<code>public void rightClickAir(GlowPlayer player, ItemStack holding) { if (fastEquip) { <START> equipStack(player, holding); <END> } }</code><technical_language>This dupe usage, client sends a right click packet. This is meant check if usage is allowed</technical_language>

Target:
public void rightClickAir(GlowPlayer player, ItemStack holding) { }
Source:
<code>public List<Pool> listBySourceEntitlements(List<Entitlement> ents) { if (ents.size() == 0) { return new ArrayList<Pool>(); } <START> Iterable<List<Entitlement>> blocks = Iterables.partition(ents, IN_OPERATOR_BLOCK_SIZE); <END> List<Pool> results = new LinkedList<Pool>(); for (List<Entitlement> block : blocks) { results.addAll( createSecureCriteria() .add(CPRestrictions.in("sourceEntitlement", block)) .setFetchMode("entitlements", FetchMode.JOIN) .list()); } if (results.size() > 0) { List<Pool> pools = listBySourceEntitlements(convertPoolsToEntitlements(results)); results.addAll(pools); } return results; }</code><technical_language>partition QUERY_PARAMETER_LIMIT (may exist in 0.9.x, set 32k default) IN_OPERATOR_BLOCK_SIZE. If opt this as-is, drop of CPRestrictions, add of value</technical_language>

Target:
public List<Pool> listBySourceEntitlements(List<Entitlement> ents) { if (ents.size() == 0) { return new ArrayList<Pool>(); } Iterable<List<Entitlement>> blocks = Iterables.partition(ents, QUERY_PARAMETER_LIMIT); List<Pool> results = new LinkedList<Pool>(); for (List<Entitlement> block : blocks) { results.addAll( createSecureCriteria() .add(CPRestrictions.in("sourceEntitlement", block)) .setFetchMode("entitlements", FetchMode.JOIN) .list()); } if (results.size() > 0) { List<Pool> pools = listBySourceEntitlements(convertPoolsToEntitlements(results)); results.addAll(pools); } return results; }
Source:
<code>public void addContents(@NonNull Container container) { File[] agentDirs = new File(Helper.getActiveInstance().getRootDir(), "nodes").listFiles(); if (agentDirs == null) { return; } for(File agentDir : agentDirs) { File config = new File(agentDir, "config.xml"); try { File patchedConfig = SecretHandler.findSecrets(config); container.add(new TemporalFileContent("nodes/slave/" + agentDir.getName() + "/config.xml", patchedConfig)); } catch (IOException | ParserConfigurationException | XMLStreamException | SAXException | TransformerException e) { <START> LOGGER.log(Level.WARNING, "could not add the {0} configuration file to the support bundle because of: {1}", new Object[]{ config.getAbsolutePath(), e }); <END> } } }</code><technical_language>if passing exception in string is gonna beautiful. Maybe: java LogRecord record = new LogRecord(Level.WARNING, "Could add {0} configuration file support bundle of: {1}"); record.setParameters(new Object[]{config.getAbsolutePath(), e}); record.setThrown(e); LOGGER.log(record);</technical_language>

Target:
public void addContents(@NonNull Container container) { File[] agentDirs = new File(Helper.getActiveInstance().getRootDir(), "nodes").listFiles(); if (agentDirs == null) { return; } for(File agentDir : agentDirs) { File config = new File(agentDir, "config.xml"); try { File patchedConfig = SecretHandler.findSecrets(config); container.add(new TemporaryFileContent("nodes/slave/" + agentDir.getName() + "/config.xml", patchedConfig)); } catch (IOException | SAXException | TransformerException e) { LogRecord record = new LogRecord(Level.WARNING, "Could not add the {0} configuration file to the support bundle because of: {1}"); record.setParameters(new Object[]{ config.getAbsolutePath(), e }); record.setThrown(e); LOGGER.log(record); } } }
Source:
<code>public void start(BundleContext context) throws Exception { super.start(context); new WorkspaceArchivesCore(); ResourcesPlugin.getWorkspace().addResourceChangeListener(new WorkspaceChangeListener()); <START> KeyManager.getInstance(); <END> }</code><technical_language>try toxic TCCL, KeyManager : java ClassLoader originalTCCL = Thread.currentThread().getContextClassLoader(); ClassLoader cl = originalTCCL; while (cl != null && cl.getClass().getName().contains("org.codehaus.plexus.classworlds")) { cl = cl.getParent(); } try { Thread.currentThread().setContextClassLoader(cl); KeyManager.getInstance(); } finally { Thread.currentThread().setContextClassLoader(originalTCCL); } ugly sh*t</technical_language>

Target:
public void start(BundleContext context) throws Exception { super.start(context); new WorkspaceArchivesCore(); ResourcesPlugin.getWorkspace().addResourceChangeListener(new WorkspaceChangeListener()); Bundle bundle = context.getBundle(); BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); ClassLoader bundleLoader = bundleWiring.getClassLoader(); ClassLoader originalTCCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(bundleLoader); KeyManager.getInstance(); } finally { Thread.currentThread().setContextClassLoader(originalTCCL); } }
Source:
<code>public Dialog onCreateDialog(Bundle savedInstance) { <START> <END> if (savedInstance != null) { preSelectedTags = new HashSet<Keyword>(Arrays.asList( (Keyword[]) savedInstance.getParcelableArray("preSelectedTags"))); selectedTags = new HashSet<Keyword>(Arrays.asList( (Keyword[]) savedInstance.getParcelableArray("selectedTags"))); } LayoutInflater inflater = getActivity().getLayoutInflater(); View tagChoiceListView = inflater.inflate(R.layout.tag_choice_list, null); ImageButton buttonTagEditor = (ImageButton) tagChoiceListView.findViewById(R.id.button_keyword_editor); buttonTagEditor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listener.onStartKeywordEditor(); dismiss(); } }); tags = Keyword.getVisibleKeywords(); TagListAdapter adapter = new TagListAdapter(getActivity(), tags); ListView listView = (ListView) tagChoiceListView.findViewById( R.id.tag_choice_list_view); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick( AdapterView parent, View view, int position, long id) { ListView lv = (ListView) parent; Keyword clickedTag = tags.get(position); if (lv.isItemChecked(position)) { selectedTags.add(clickedTag); } else { selectedTags.remove(clickedTag); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.tag_choice_dialog_title) .setView(tagChoiceListView) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Set<Keyword> addedTags = new HashSet<Keyword>(selectedTags); addedTags.removeAll(preSelectedTags); Set<Keyword> deletedTags = new HashSet<Keyword>(preSelectedTags); deletedTags.removeAll(selectedTags); listener.onStoreTags(addedTags, deletedTags); } }) .setNegativeButton(android.R.string.cancel, null); return builder.create(); }</code><technical_language>long</technical_language>

Target:
public Dialog onCreateDialog(Bundle savedInstance) { if (savedInstance != null) { preSelectedTags = new HashSet<Keyword>(Arrays.asList( (Keyword[]) savedInstance.getParcelableArray("preSelectedTags"))); selectedTags = new HashSet<Keyword>(Arrays.asList( (Keyword[]) savedInstance.getParcelableArray("selectedTags"))); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.tag_choice_dialog_title) .setView(getTagChoiceView()) .setPositiveButton(android.R.string.ok, new OkListener()) .setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Source:
<code>private void setTimeZone(final String zoneId) { if (StringUtils.isBlank(zoneId)) { timeZone = TimeZone.getDefault().toZoneId(); <START> logger.warn("No time zone set, fallback to the system time zone '{}'.", timeZone.toString()); <END> } else { try { timeZone = ZoneId.of(zoneId); } catch (DateTimeException e) { timeZone = TimeZone.getDefault().toZoneId(); logger.warn("Error setting time zone '{}', fallback to the system time zone '{}': {}", zoneId, timeZone.toString(), e.getMessage()); } } }</code><technical_language>normal situation (as default set a timezone)? If is, I expect logging (as is fine), want set debug instead</technical_language>

Target:
private void setTimeZone(final String zoneId) { if (StringUtils.isBlank(zoneId)) { timeZone = TimeZone.getDefault().toZoneId(); logger.debug("No time zone set, falling back to the default time zone '{}'.", timeZone.toString()); } else { try { timeZone = ZoneId.of(zoneId); } catch (DateTimeException e) { timeZone = TimeZone.getDefault().toZoneId(); logger.warn("Error setting time zone '{}', falling back to the default time zone '{}': {}", zoneId, timeZone.toString(), e.getMessage()); } } }
Source:
<code>private void getMessageBodyBytes(MessageBodyBytesProcessor processor) throws IOException, XMLStreamException { int currentEventType; StringBuilder cdata = new StringBuilder(); while (reader.hasNext()) { currentEventType = reader.getEventType(); if (currentEventType == XMLStreamConstants.END_ELEMENT) { break; } <START> else if (currentEventType == XMLStreamConstants.CHARACTERS && cdata.length() > 0) { <END> processor.processBodyBytes(decode(cdata.toString())); cdata.setLength(0); } else { cdata.append(new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()).trim()); } reader.next(); } }</code><technical_language>JDK's STAX implementation reports CDATA sections XMLStreamConstants.CHARACTERS (instead of XMLStreamConstants.CDATA Woodstox does) default. this condition needs additionally check text contains white spaces only. reader.isWhiteSpace() do</technical_language>

Target:
private void getMessageBodyBytes(MessageBodyBytesProcessor processor) throws IOException, XMLStreamException { int currentEventType; StringBuilder cdata = new StringBuilder(); while (reader.hasNext()) { currentEventType = reader.getEventType(); if (currentEventType == XMLStreamConstants.END_ELEMENT) { break; } else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) { processor.processBodyBytes(decode(cdata.toString())); cdata.setLength(0); } else { cdata.append(new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()).trim()); } reader.next(); } }
Source:
<code>private void tryToUpdateParseForAppUpgrade(Context context){ PrefManager.AppInfoPrefManager pmanager = new PrefManager.AppInfoPrefManager(context); Long previousVersion = pmanager.getAppVersionCode(); boolean hadNotification = pmanager.isNotificationEnabled(); int curVersion = PropertyUtil.getManifestVersionCode(context); if ( previousVersion < curVersion ){ ParseInstallation installation = ParseInstallation.getCurrentInstallation(); Locale locale = Locale.getDefault(); installation.put("preferredLanguage",locale.getLanguage()); <START> installation.put("preferredCountry",locale.getCountry()); <END> if ( hadNotification ) { pmanager.setAppUpgradeNeedSyncWithParse(true); } installation.saveEventually(); } pmanager.setAppVersionCode(curVersion); pmanager.setNotificationEnabled(true); }</code><technical_language>if a user changes language version</technical_language>

Target:
private void tryToUpdateParseForAppUpgrade(Context context){ PrefManager.AppInfoPrefManager pmanager = new PrefManager.AppInfoPrefManager(context); Long previousVersion = pmanager.getAppVersionCode(); boolean hadNotification = pmanager.isNotificationEnabled(); int curVersion = PropertyUtil.getManifestVersionCode(context); if ( previousVersion < curVersion ){ if ( hadNotification ) { pmanager.setAppUpgradeNeedSyncWithParse(true); } } ParseInstallation installation = ParseInstallation.getCurrentInstallation(); final String languageKey = "preferredLanguage"; final String countryKey = "preferredLanguage"; String savedPreferredLanguage = installation.getString(languageKey); String savedPreferredCountry = installation.getString(countryKey); Locale locale = Locale.getDefault(); String currentPreferredLanguage = locale.getLanguage(); String currentPreferredCountry = locale.getCountry(); boolean dirty = false; if (!currentPreferredLanguage.equals(savedPreferredLanguage) ) { installation.put(languageKey, currentPreferredLanguage); dirty = true; } if (!currentPreferredCountry.equals(savedPreferredCountry) ) { installation.put(countryKey, currentPreferredCountry); dirty = true; } if ( dirty ) { try { installation.saveInBackground(); }catch (Exception ex){ logger.error(ex); } } pmanager.setAppVersionCode(curVersion); pmanager.setNotificationEnabled(true); }
Source:
<code>private void safelyAddProperty(Properties properties, String key, Integer value) { <START> properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value.intValue()); <END> }</code><technical_language>Do need call intValue() here? This line of code is implicitly convert primitive int Integer</technical_language>

Target:
private void safelyAddProperty(Properties properties, String key, Integer value) { properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value); }
Source:
<code>protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException { if (level + 1 > indexSequence.size()) { indexSequence.add(0); returnSequence.add(0); } SequencePointable seqItem = pp.takeOne(SequencePointable.class); try { getSequence(tvpInput, seqItem); int seqLength = seqItem.getEntryCount(); while (indexSequence.get(level) < seqLength) { seqItem.getEntry(indexSequence.get(level), tvpItem); if (indexSequence.get(level) == returnSequence.get(level)) { returnSequence.set(level, returnSequence.get(level) + 1); <START> if (isfilter) { <END> if (filter.accept(ntp, tvpItem)) { try { setNodeToResult(tvpItem, result); return true; } catch (IOException e) { String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription(); throw new AlgebricksException(description); } } else { setNodeToResult(tvpItem, result); continue; } } else { setNodeToResult(tvpItem, result); return true; } } if (level + 1 <= indexSequence.size()) { if (stepNodeTree(tvpItem, level + 1, result)) { return true; } } indexSequence.set(level, indexSequence.get(level) + 1); } if (level == 0) { indexSequence.set(level, 0); returnSequence.set(level, 0); } else { indexSequence.remove(level); returnSequence.remove(level); } return false; } catch (IOException e) { String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription(); throw new AlgebricksException(description); } finally { pp.giveBack(seqItem); } }</code><technical_language>logic is correct. process adds nodes result do match filter</technical_language>

Target:
protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException { if (level + 1 > indexSequence.size()) { indexSequence.add(0); returnSequence.add(0); } SequencePointable seqItem = pp.takeOne(SequencePointable.class); try { getSequence(tvpInput, seqItem); int seqLength = seqItem.getEntryCount(); while (indexSequence.get(level) < seqLength) { seqItem.getEntry(indexSequence.get(level), tvpItem); if (indexSequence.get(level) == returnSequence.get(level)) { returnSequence.set(level, returnSequence.get(level) + 1); if (!isfilter || (isfilter && filter.accept(ntp, tvpItem))) { setNodeToResult(tvpItem, result); return true; } } if (level + 1 <= indexSequence.size()) { if (stepNodeTree(tvpItem, level + 1, result)) { return true; } } indexSequence.set(level, indexSequence.get(level) + 1); } if (level == 0) { indexSequence.set(level, 0); returnSequence.set(level, 0); } else { indexSequence.remove(level); returnSequence.remove(level); } return false; } catch (IOException e) { String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription(); throw new AlgebricksException(description); } finally { pp.giveBack(seqItem); } }
Source:
<code>protected List<SPMAsyncTaskHandler> initTaskHandlers() { List<SPMAsyncTaskHandler> taskHandlers = new ArrayList<>(); if (!getParameters().isImageIdsSorted()) { List<DiskImage> images = getAllImagesForDisk(); ImagesHandler.sortImageList(images); List<DiskImage> sortedImages = images.stream() .filter(image -> getImages().contains(image)) <START> .filter(image -> image.getDiskStorageType() == DiskStorageType.IMAGE) <END> .collect(Collectors.toList()); getParameters().setImageIds(new ArrayList<>(ImagesHandler.getDiskImageIds(sortedImages))); getParameters().setImageIdsSorted(true); } for (Guid imageId : getParameters().getImageIds()) { taskHandlers.add(new RemoveDiskSnapshotTaskHandler(this, imageId, getImageGroupId(), getVmId())); } return !taskHandlers.isEmpty() ? taskHandlers : null; }</code><technical_language>do this filtering previous - cheaper</technical_language>

Target:
protected List<SPMAsyncTaskHandler> initTaskHandlers() { List<SPMAsyncTaskHandler> taskHandlers = new ArrayList<>(); if (!getParameters().isImageIdsSorted()) { List<DiskImage> images = getAllImagesForDisk(); ImagesHandler.sortImageList(images); List<DiskImage> sortedImages = images.stream() .filter(image -> image.getDiskStorageType() == DiskStorageType.IMAGE) .filter(image -> getImages().contains(image)) .collect(Collectors.toList()); getParameters().setImageIds(new ArrayList<>(ImagesHandler.getDiskImageIds(sortedImages))); getParameters().setImageIdsSorted(true); } for (Guid imageId : getParameters().getImageIds()) { taskHandlers.add(new RemoveDiskSnapshotTaskHandler(this, imageId, getImageGroupId(), getVmId())); } return !taskHandlers.isEmpty() ? taskHandlers : null; }
Source:
<code>void add(ChannelOutboundBuffer buffer, boolean connected) throws Exception { processor.connected = connected; try { buffer.forEachFlushedMessage(processor); } finally { processor.connected = false; <START> } <END> }</code><technical_language>resetting this is needed set use</technical_language>

Target:
void add(ChannelOutboundBuffer buffer, boolean connected) throws Exception { processor.connected = connected; buffer.forEachFlushedMessage(processor); }
Source:
<code>public UrlContent getResourceContent(String sessionId, String url, boolean insecure) throws IOException { <START> CommonHttpClientBuilder builder = new CommonHttpClientBuilder().maxConnections(CONNECTION_POOL_SIZE) <END> .useSystemProperties() .insecure(insecure); try (CloseableHttpClient client = builder.build()) { HttpGet request = new HttpGet(url); if (sessionId != null) { request.setHeader("sessionid", sessionId); } CloseableHttpResponse response = client.execute(request); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != HttpStatus.SC_OK) { throw new IOException(String.format("Cannot access resource %s: code %d", url, status.getStatusCode())); } Header contentDispositionHeader = response.getFirstHeader("Content-Disposition"); String filename; if (contentDispositionHeader != null && contentDispositionHeader.getValue().matches(CONTENT_DISPOSITIOB_REGEXP)) { filename = contentDispositionHeader.getValue().replaceFirst(CONTENT_DISPOSITIOB_REGEXP, "$1"); } else { filename = FileUtils.getFileNameWithExtension(new URL(url)); } return new UrlContent(readContent(response.getEntity().getContent()), filename); } }</code><technical_language>this part is other method getResource(.... extracted in a private method</technical_language>

Target:
public UrlContent getResourceContent(String sessionId, String url, boolean insecure) throws IOException { CommonHttpClientBuilder builder = new CommonHttpClientBuilder().maxConnections(CONNECTION_POOL_SIZE) .useSystemProperties() .insecure(insecure); try (CloseableHttpClient client = builder.build()) { CloseableHttpResponse response = createAndExecuteRequest(sessionId, url, client); Header contentDispositionHeader = response.getFirstHeader("Content-Disposition"); String filename; if (contentDispositionHeader != null && contentDispositionHeader.getValue().matches(CONTENT_DISPOSITIOB_REGEXP)) { filename = contentDispositionHeader.getValue().replaceFirst(CONTENT_DISPOSITIOB_REGEXP, "$1"); } else { filename = FileUtils.getFileNameWithExtension(new URL(url)); } return new UrlContent(readContent(response.getEntity().getContent()), filename); } }
Source:
<code>public int getEncodeSize() { <START> return 0; <END> }</code><technical_language>given/calculated</technical_language>

Target:
public int getEncodeSize() { return getBuffer() == null ? -1 : getBuffer().writerIndex(); }
Source:
<code>public StandardSlackService(StandardSlackServiceBuilder standardSlackServiceBuilder) { this.baseUrl = standardSlackServiceBuilder.baseUrl; if (this.baseUrl != null && !this.baseUrl.isEmpty() && !this.baseUrl.endsWith("/")) { this.baseUrl += "/"; } this.teamDomain = standardSlackServiceBuilder.teamDomain; this.botUser = standardSlackServiceBuilder.botUser; if (standardSlackServiceBuilder.roomId == null) { throw new IllegalArgumentException("Project Channel or Slack User ID must be specified."); } this.roomIds = standardSlackServiceBuilder.roomId.split("[,; ]+"); this.replyBroadcast = standardSlackServiceBuilder.replyBroadcast; <START> this.sendAsText = standardSlackServiceBuilder.sendAsText; <END> this.iconEmoji = correctEmojiFormat(standardSlackServiceBuilder.iconEmoji); this.username = standardSlackServiceBuilder.username; this.populatedToken = standardSlackServiceBuilder.populatedToken; }</code><technical_language>unused here? missing if statement unfurl_links/unfurl_media</technical_language>

Target:
public StandardSlackService(StandardSlackServiceBuilder standardSlackServiceBuilder) { this.baseUrl = standardSlackServiceBuilder.baseUrl; if (this.baseUrl != null && !this.baseUrl.isEmpty() && !this.baseUrl.endsWith("/")) { this.baseUrl += "/"; } this.teamDomain = standardSlackServiceBuilder.teamDomain; this.botUser = standardSlackServiceBuilder.botUser; if (standardSlackServiceBuilder.roomId == null) { throw new IllegalArgumentException("Project Channel or Slack User ID must be specified."); } this.roomIds = standardSlackServiceBuilder.roomId.split("[,; ]+"); this.replyBroadcast = standardSlackServiceBuilder.replyBroadcast; this.iconEmoji = correctEmojiFormat(standardSlackServiceBuilder.iconEmoji); this.username = standardSlackServiceBuilder.username; this.populatedToken = standardSlackServiceBuilder.populatedToken; }
Source:
<code>public void process(AuthToken m, AuthCallbacks.GenericCallback<AuthToken> cb) { try { byte[] clientSideToken = m.getData(); byte[] response = server.response(clientSideToken); if (response != null) { cb.operationComplete(BKException.Code.OK, AuthToken.wrap(response)); } if (server.isComplete()) { completeCb.operationComplete(BKException.Code.OK, null); } } catch (SaslException err) { LOG.error("SASL error", err); <START> completeCb.operationComplete(BKException.Code.UnauthorizedAccessException, null); <END> } }</code><technical_language>want log entire stack trace time. I cases automated script log in filled logs quickly making difficult debug else</technical_language>

Target:
public void process(AuthToken m, AuthCallbacks.GenericCallback<AuthToken> cb) { try { byte[] clientSideToken = m.getData(); byte[] response = server.response(clientSideToken); if (response != null) { cb.operationComplete(BKException.Code.OK, AuthToken.wrap(response)); } if (server.isComplete()) { completeCb.operationComplete(BKException.Code.OK, null); } } catch (SaslException err) { LOG.debug("SASL error", err); completeCb.operationComplete(BKException.Code.UnauthorizedAccessException, null); } }
Source:
<code>public CompletionStage<Result> status() { return ask( "/user/status", <START> new StatusActor.StatusRequest(), <END> new StatusResponse.Builder() .setLocalAddress(_actorSystem.provider().getDefaultAddress()) .build()) .thenApply(status -> ok(OBJECT_MAPPER.<JsonNode>valueToTree(status))); }</code><technical_language>skip this fun inject actorref directly</technical_language>

Target:
public CompletionStage<Result> status() { return PatternsCS.ask( _statusActor, new StatusActor.StatusRequest(), Duration.ofSeconds(1)) .exceptionally(t -> new StatusResponse.Builder() .setLocalAddress(_actorSystem.provider().getDefaultAddress()) .build()) .thenApply(status -> ok(OBJECT_MAPPER.<JsonNode>valueToTree(status))); }
Source:
<code>protected String findOriginalName(String fullpath, String changeset) throws IOException { if (fullpath == null || fullpath.isEmpty() || fullpath.length() < directoryName.length()) { LOGGER.log(Level.SEVERE, "Invalid file path string: {0}", fullpath); return null; } if (changeset == null || changeset.isEmpty()) { LOGGER.log(Level.SEVERE, "Invalid changeset string: {0}", changeset); return null; } String file = fullpath.replace(directoryName + File.separator, ""); String[] argv = { ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK), "log", "--follow", "--summary", ABBREV_LOG, "--abbrev-commit", fullpath }; ProcessBuilder pb = new ProcessBuilder(argv); Process process = Runtime.getRuntime().exec(argv, null, new File(directoryName)); try { try (BufferedReader in = new BufferedReader( new InputStreamReader(process.getInputStream()))) { String line; String rev = null; while ((line = in.readLine()) != null) { if (line.startsWith("commit ")) { rev = line.replace("commit ", ""); continue; } if (rev.equals(changeset)) { break; } if (line.startsWith(" rename ")) { line = line.replace(" rename ", ""); line = expandGitRenamedOutput(line); String[] split = line.split(" => "); if (split.length < 2) { throw new IOException( String.format( "Invalid format of the git output. Expected " + "\"file => otherfile\" but got \"{}\"", line)); } file = split[0]; } <START> if (rev.equals(changeset)) { <END> break; } } } } finally { if (process != null) { try { process.exitValue(); } catch (IllegalThreadStateException e) { process.destroy(); } } } return (fullpath.substring(0, directoryName.length() + 1) + file); }</code><technical_language>this is supposed work piece of code lines 360-362</technical_language>

Target:
protected String findOriginalName(String fullpath, String changeset) throws IOException { if (fullpath == null || fullpath.isEmpty() || fullpath.length() < directoryName.length()) { throw new IOException(String.format("Invalid file path string: %s", fullpath)); } if (changeset == null || changeset.isEmpty()) { throw new IOException(String.format("Invalid changeset string for path %s: %s", fullpath, changeset)); } String file = fullpath.replace(directoryName + File.separator, ""); String[] argv = { ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK), "log", "--follow", "--summary", ABBREV_LOG, "--abbrev-commit", "--name-status", "--pretty=format:commit %h%b", "--", fullpath }; ProcessBuilder pb = new ProcessBuilder(argv); Process process = Runtime.getRuntime().exec(argv, null, new File(directoryName)); try { try (BufferedReader in = new BufferedReader( new InputStreamReader(process.getInputStream()))) { String line; String rev = null; Matcher m; Pattern pattern = Pattern.compile("^R\\d+\\s(.*)\\s(.*)"); while ((line = in.readLine()) != null) { if (line.startsWith("commit ")) { rev = line.substring(7); continue; } if (changeset.equals(rev)) { break; } if ((m = pattern.matcher(line)).find()) { file = m.group(1); } } } } finally { if (process != null) { try { process.exitValue(); } catch (IllegalThreadStateException e) { process.destroy(); } } } return (fullpath.substring(0, directoryName.length() + 1) + file); }