auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void startElement(TagNode node) { if (isTable(node) && isLayout(node)) { findAttribute(node, "SUMMARY").ifPresent(a -> createViolation(a.getLine(), format("Remove this \"%s\" attribute", a.getName()))); isWithinLayoutTable = true; } if (isWithinLayoutTable) { if (isCaption(node) || isTableHeader(node)) { createViolation(node.getStartLinePosition(), format("Remove this \"%s\" element", node.getNodeName())); } if (isTableColumn(node)) { findAttribute(node, "HEADERS").ifPresent(a -> createViolation(a.getLine(), format("Remove this \"%s\" attribute", a.getName()))); <START> findAttribute(node, "SCOPE").ifPresent(a -> createViolation(a.getLine(), format("Remove this \"%s\" attribute", a.getName()))); <END> } } }</code><technical_language>Minor: this is more a matter of personal preference, IMO lambdas slighly longer meaningful parameter names, attribute instead of a. this is a matter of preference, leave is if prefer</technical_language>

Target:
public void startElement(TagNode node) { if (isTable(node)) { isWithinLayoutTable.addFirst(isLayout(node)); if (Boolean.TRUE.equals(isWithinLayoutTable.peekFirst())) { raiseViolationOnAttribute(node, "SUMMARY"); } } if (Boolean.TRUE.equals(isWithinLayoutTable.peekFirst())) { if (isCaption(node) || isTableHeader(node)) { createViolation(node.getStartLinePosition(), format("Remove this \"%s\" element", node.getNodeName())); } else if (isTableColumn(node)) { raiseViolationOnAttribute(node, "HEADERS"); raiseViolationOnAttribute(node, "SCOPE"); } } }
Source:
<code>protected Boolean doInBackground(Void... arg0) { boolean result = true; Context context = getActivity(); String additivesFile; switch (LocaleHelper.getLanguage(context)) { <START> case "fr": <END> additivesFile = "additives_fr.json"; break; case "ru": additivesFile = "additives_ru.json"; break; case "en": default: additivesFile = "additives_en.json"; break; } String language = LocaleHelper.getLanguage(context); additivesFile = additivesFile.replace("en", language); InputStream is = null; try { is = getActivity().getAssets().open(additivesFile); List<Additive> frenchAdditives = JsonUtils.readFor(new TypeReference<List<Additive>>() { }) .readValue(is); mAdditiveDao.insertOrReplaceInTx(frenchAdditives); } catch (IOException e) { result = false; Log.e(ADDITIVE_IMPORT, "Unable to import additives from " + additivesFile); } finally { if (is != null) { try { is.close(); } catch (IOException e1) { Log.e(ADDITIVE_IMPORT, "Unable to close the inputstream of " + additivesFile); } } } return result; }</code><technical_language>a long case system cases, concatenate languages, handling languages standard codes</technical_language>

Target:
protected Boolean doInBackground(Void... arg0) { boolean result = true; String additivesFile = "additives_" + LocaleHelper.getLanguage(getActivity()) + ".json"; InputStream is = null; try { is = getActivity().getAssets().open(additivesFile); List<Additive> frenchAdditives = JsonUtils.readFor(new TypeReference<List<Additive>>() { }) .readValue(is); mAdditiveDao.insertOrReplaceInTx(frenchAdditives); } catch (IOException e) { result = false; Log.e(ADDITIVE_IMPORT, "Unable to import additives from " + additivesFile); } finally { if (is != null) { try { is.close(); } catch (IOException e1) { Log.e(ADDITIVE_IMPORT, "Unable to close the inputstream of " + additivesFile); } } } return result; }
Source:
<code><START> public GatewayProxyFactoryBean itemWriteEventsListener() { <END> GatewayProxyFactoryBean factoryBean = new GatewayProxyFactoryBean(ItemWriteListener.class); factoryBean.setDefaultRequestChannel(listenerChannels.itemWriteEvents()); return factoryBean; }</code><technical_language>I thought GatewayProxy approach for ItemWrite do match XD here..</technical_language>

Target:
public ItemWriteListener itemWriteEventsListener() { return new EventEmittingItemWriteEventsListener(listenerChannels.itemWriteEvents()); }
Source:
<code><START> private StudyType(String symbol) { <END> this.symbol = symbol; }</code><technical_language>"Modifier 'private' is redundant for enum constructors"</technical_language>

Target:
StudyType(String symbol) { this.symbol = symbol; }
Source:
<code>public void onMediaUploadProgress(final String localMediaId, final float progress) { if(!mCancelledMediaIds.contains(localMediaId)) { mUploadingMediaProgressMax.put(localMediaId, progress); getGutenbergContainerFragment().mediaFileUploadProgress(Integer.valueOf(localMediaId), progress); } else { <START> mCancelledMediaIds.remove(localMediaId); <END> } }</code><technical_language>yeah I get mean. I thinking if event rapidly cancellation, disregard it. if say, 2+ seconds assume some level of confidence this treated a "new attempt". record time user cancelled id, instead of a HashSet a HashMap links time of cancellation localMediaid key, onMediaUploadProgress is called check if this is contained in mCancelledMediaIds.keys, if check time elapsed deciding remove not. A proper signal check user inserted image in place, a signal for this bridge. add a bridge method, overkill for a corner case bug anyway. I adding time check adds extra security is code add, for full blown solution, wdyt</technical_language>

Target:
public void onMediaUploadProgress(final String localMediaId, final float progress) { if (!mCancelledMediaIds.containsKey(localMediaId)) { mUploadingMediaProgressMax.put(localMediaId, progress); getGutenbergContainerFragment().mediaFileUploadProgress(Integer.valueOf(localMediaId), progress); } else { Date startTime = mCancelledMediaIds.get(localMediaId); if (DateTimeUtils.secondsBetween(startTime, new Date()) > 2) { mCancelledMediaIds.remove(localMediaId); } } }
Source:
<code>private InputStream executeToInputStream(HttpConnection connection) throws CouchException { connection.requestProperties.put("Accept", "application/json"); InputStream is = null; String response = null; int code = -1; try { is = connection.executeToInputStream(); } catch (IOException ioe) { System.out.println("original exception "+ioe); try { response = connection.getConnection().getResponseMessage(); } catch (IOException ioe2) { } } try { code = connection.getConnection().getResponseCode(); if (code == 200 || code == 201 || code == 202) { } else if (code == 404) { throw new NoResourceException("todo"); } else { is = connection.getConnection().getErrorStream(); CouchException ex = this.jsonHelper.fromJson(new InputStreamReader(is), CouchException.class); ex.setStatusCode(code); <START> throw ex; <END> } } catch (IOException ioe) { throw new CouchException(response, code); } return is; }</code><technical_language>Close error stream</technical_language>

Target:
private InputStream executeToInputStream(HttpConnection connection) throws CouchException { connection.requestProperties.put("Accept", "application/json"); InputStream is = null; InputStream es = null; String response = null; int code = -1; Throwable cause = null; try { is = connection.execute().responseAsInputStream(); } catch (IOException ioe) { cause = ioe; } try { code = connection.getConnection().getResponseCode(); response = connection.getConnection().getResponseMessage(); if (code / 100 == 2) { return is; } else if (code == 404) { throw new NoResourceException(response, cause); } else { es = connection.getConnection().getErrorStream(); CouchException ex = this.jsonHelper.fromJson(new InputStreamReader(es), CouchException.class); ex.setStatusCode(code); throw ex; } } catch (IOException ioe) { throw new CouchException("Error retrieving server response", ioe, code); } finally { if (es != null) { try { es.close(); } catch (IOException ioe) { ; } } } }
Source:
<code>public void setModifierGroups(String modifierGroupRegex) { <START> final String safeModifierGroup = Objects.toString(modifierGroupRegex, ""); <END> Arrays.stream(safeModifierGroup.split(",")).forEach(modifierGroup -> { final String trimmed = modifierGroup.trim(); if (CommonUtils.isBlank(trimmed) || DEFAULT_OVERLOAD_GROUP_PATTERN.equals(trimmed)) { overloadGroups.add(DEFAULT_OVERLOAD_GROUP); } else { overloadGroups.add(new RegexOverloadGroup(trimmed)); } }); }</code><technical_language>do need Objects? modifierGroupRegex.toString? is same, more for me</technical_language>

Target:
public void setModifierGroups(String modifierGroupRegex) { Arrays.stream(modifierGroupRegex.split(",")).forEach(modifierGroup -> { final String trimmed = modifierGroup.trim(); if (CommonUtils.isBlank(trimmed) || DEFAULT_OVERLOAD_GROUP_PATTERN.equals(trimmed)) { overloadGroups.add(DEFAULT_OVERLOAD_GROUP); } else { overloadGroups.add(new RegexOverloadGroup(trimmed)); } }); }
Source:
<code>public static Pair<SizeUnit, Double> autoConvert(long size, SizeUnit inUnit) { for (Pair<Long, SizeUnit> currentUnitPair : SizeUnit.weightToUnit) { if (size / Math.pow(CONVERT_FACTOR, currentUnitPair.getFirst() - inUnit.getUnitWeight()) >= 1) { return new Pair<SizeConverter.SizeUnit, Double>(currentUnitPair.getSecond(), Double.valueOf(SizeConverter.convert(size, inUnit, currentUnitPair.getSecond()).doubleValue())); } } <START> return new Pair<SizeConverter.SizeUnit, Double>(SizeUnit.BYTES, new Double(Long.valueOf(size))); <END> }</code><technical_language>easier "Double.valueOf(size)"</technical_language>

Target:
public static Pair<SizeUnit, Double> autoConvert(long size, SizeUnit inUnit) { for (Pair<Long, SizeUnit> currentUnitPair : SizeUnit.weightToUnit) { if (size / Math.pow(CONVERT_FACTOR, currentUnitPair.getFirst() - inUnit.getUnitWeight()) >= 1) { return new Pair<SizeConverter.SizeUnit, Double>(currentUnitPair.getSecond(), Double.valueOf(SizeConverter.convert(size, inUnit, currentUnitPair.getSecond()).doubleValue())); } } return new Pair<SizeConverter.SizeUnit, Double>(SizeUnit.BYTES, Double.valueOf(size)); }
Source:
<code>private DependencyInfo getDockerfileDeps() throws IOException { <START> HashSet<String> emtpySet = new HashSet<>(); <END> return new DependencyInfo(emtpySet, emtpySet); }</code><technical_language>Set<String> = Collections.emptySet()</technical_language>

Target:
private DependencyInfo getDockerfileDeps() throws IOException { Set<String> emtpySet = Collections.emptySet(); return new DependencyInfo(emtpySet, emtpySet); }
Source:
<code>public void setUp() throws Exception { <START> objectMap.put("config.db.read-preference", "primary"); <END> }</code><technical_language>Please rebase develop argument constants class JobParametersNames</technical_language>

Target:
public void setUp() throws Exception { objectMap.put(JobParametersNames.CONFIG_DB_READPREFERENCE, "primary"); }
Source:
<code>private CompletionStage<Boolean> attemptTouchAndReturnIfExpired(InternalCacheEntry ice, int segment) { LocalizedCacheTopology lct = distributionManager.getCacheTopology(); TouchCommand touchCommand = cf.running().buildTouchCommand(ice.getKey(), segment); touchCommand.setTopologyId(lct.getTopologyId()); CompletionStage<Boolean> remoteStage = invokeTouchCommandRemotely(touchCommand, lct, segment); touchCommand.init(componentRegistry, false); long accessTime = timeService.wallClockTime(); touchCommand.setAccessTime(accessTime); CompletableFuture<Object> localStage = touchCommand.invokeAsync(); return remoteStage.thenCombine(localStage, (remoteTouch, localTouch) -> { <START> if (remoteTouch == Boolean.TRUE && localTouch == Boolean.TRUE) { <END> ice.touch(accessTime); return Boolean.FALSE; } return Boolean.TRUE; }); }</code><technical_language>I bad copy ICE a MvccEntry time. synchronized (cacheEntry) stuff, JMC complains JVM biased locking work out</technical_language>

Target:
private CompletionStage<Boolean> attemptTouchAndReturnIfExpired(InternalCacheEntry ice, int segment) { LocalizedCacheTopology lct = distributionManager.getCacheTopology(); TouchCommand touchCommand = cf.running().buildTouchCommand(ice.getKey(), segment); touchCommand.setTopologyId(lct.getTopologyId()); CompletionStage<Boolean> remoteStage = invokeTouchCommandRemotely(touchCommand, lct, segment); touchCommand.init(componentRegistry, false); long accessTime = timeService.wallClockTime(); CompletableFuture<Object> localStage = touchCommand.invokeAsync(accessTime); return remoteStage.thenCombine(localStage, (remoteTouch, localTouch) -> { if (remoteTouch == Boolean.TRUE && localTouch == Boolean.TRUE) { ice.touch(accessTime); return Boolean.FALSE; } return Boolean.TRUE; }); }
Source:
<code>public Response getEventsForCertificate(@PathParam("certificateId") String certificateId) { List<CertificateEvent> eventList = certificateEventService.getCertificateEvents(certificateId); <START> if (eventList.isEmpty()) { <END> LOG.error("No events for certificate with id {}", certificateId); return Response.status(Status.BAD_REQUEST).build(); } LOG.debug("Got events", eventList.size()); return Response.ok(eventList).build(); }</code><technical_language>a thought... this returned a "error" in fact return empty list. If events for a Certificate user of this endpoint's fault..</technical_language>

Target:
public Response getEventsForCertificate(@PathParam("certificateId") String certificateId) { List<CertificateEvent> eventList = certificateEventService.getCertificateEvents(certificateId); if (eventList == null) { LOG.error("Could not complete the request for certificate with id {}", certificateId); return Response.status(Status.BAD_REQUEST).build(); } if (eventList.size() > 0) { LOG.debug("Got events for certificate with id {}", eventList.size(), certificateId); } else if (eventList.isEmpty()) { LOG.debug("No events for certificate with id {}", certificateId); } return Response.ok(eventList).build(); }
Source:
<code>private boolean boardSave(boolean saveAs) { correctExits(); validateBoard(false); if (curBoardFile == null || saveAs) { if (!chooseSaveBoardFile()) { return false; } } butSourceFile.setEnabled(true); try { <START> OutputStream os = new FileOutputStream(curBoardFile); <END> board.save(os); os.close(); savedUndoStackSize = undoStack.size(); hasChanges = false; setFrameTitle(); return true; } catch (IOException ex) { MegaMek.getLogger().error(this, ex); return false; } }</code><technical_language>This moved try statement (try (...)) if board.save throws, os cleaned up</technical_language>

Target:
private boolean boardSave(boolean saveAs) { correctExits(); validateBoard(false); if (curBoardFile == null || saveAs) { if (!chooseSaveBoardFile()) { return false; } } try (OutputStream os = new FileOutputStream(curBoardFile)) { board.save(os); butSourceFile.setEnabled(true); savedUndoStackSize = undoStack.size(); hasChanges = false; setFrameTitle(); return true; } catch (IOException ex) { MegaMek.getLogger().error(this, ex); return false; } }
Source:
<code>public void setReferenceAndUpdateTransactionStatus(String refundExternalId, String refundReference, RefundStatus newRefundStatus) { Optional<RefundTransactionEntity> refundTransactionOptional = refundTransactionDao.findByExternalId(refundExternalId); refundTransactionOptional.ifPresent(refundTransaction -> refundTransaction.setRefundReference(refundReference)); updateRefundTransactionStatus( refundTransactionOptional, newRefundStatus, <START> format("Not updating refund transaction status for externalId [%s] to [%s] charge transaction not found", <END> refundExternalId, newRefundStatus.getValue() ) ); }</code><technical_language>refund transaction found, charge transaction</technical_language>

Target:
public void setReferenceAndUpdateTransactionStatus(String refundExternalId, String refundReference, RefundStatus newRefundStatus) { Optional<RefundTransactionEntity> refundTransactionOptional = refundTransactionDao.findByExternalId(refundExternalId); if (refundTransactionOptional.isPresent()) { RefundTransactionEntity refundTransaction = refundTransactionOptional.get(); refundTransaction.setRefundReference(refundReference); updateRefundTransactionStatus(newRefundStatus, refundTransaction); } else { logger.warn(format("Not updating refund transaction status for externalId [%s] to [%s] refund transaction not found", refundExternalId, newRefundStatus.getValue() )); } }
Source:
<code>public void saveSettings() { super.saveSettings(); if (mSite.isJetpackConnected()) { <START> saveJetpackSettings(); <END> } final Map<String, String> params = serializeDotComParams(); if (params == null || params.isEmpty()) return; WordPress.getRestClientUtils().setGeneralSiteSettings( mSite.getSiteId(), new RestRequest.Listener() { @Override public void onResponse(JSONObject response) { AppLog.d(AppLog.T.API, "Site Settings saved remotely"); notifySavedOnUiThread(null); mRemoteSettings.copyFrom(mSettings); if (response != null) { JSONObject updated = response.optJSONObject(UPDATED_KEY); if (updated == null) return; HashMap<String, Object> properties = new HashMap<>(); Iterator<String> keys = updated.keys(); while (keys.hasNext()) { String currentKey = keys.next(); Object currentValue = updated.opt(currentKey); if (currentValue != null) { properties.put(SAVED_ITEM_PREFIX + currentKey, currentValue); } } AnalyticsUtils.trackWithSiteDetails( AnalyticsTracker.Stat.SITE_SETTINGS_SAVED_REMOTELY, mSite, properties); } } }, new RestRequest.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { AppLog.w(AppLog.T.API, "Error POSTing site settings changes: " + error); notifySavedOnUiThread(error); } }, params); }</code><technical_language>I this result in similar issues mentioned for fetching jetpack settings due mRemoteSettings.copyFrom(mSettings); call. I saving/fetching to/from multiple endpoints changing model for it. Is a handle this</technical_language>

Target:
public void saveSettings() { super.saveSettings(); final Map<String, String> params = serializeDotComParams(); if (params == null || params.isEmpty()) return; WordPress.getRestClientUtils().setGeneralSiteSettings( mSite.getSiteId(), new RestRequest.Listener() { @Override public void onResponse(JSONObject response) { AppLog.d(AppLog.T.API, "Site Settings saved remotely"); notifySavedOnUiThread(null); mRemoteSettings.copyFrom(mSettings); if (response != null) { JSONObject updated = response.optJSONObject("updated"); if (updated == null) return; HashMap<String, Object> properties = new HashMap<>(); Iterator<String> keys = updated.keys(); while (keys.hasNext()) { String currentKey = keys.next(); Object currentValue = updated.opt(currentKey); if (currentValue != null) { properties.put(SAVED_ITEM_PREFIX + currentKey, currentValue); } } AnalyticsUtils.trackWithSiteDetails( AnalyticsTracker.Stat.SITE_SETTINGS_SAVED_REMOTELY, mSite, properties); } if (mSite.isJetpackConnected()) { saveJetpackSettings(); } } }, new RestRequest.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { AppLog.w(AppLog.T.API, "Error POSTing site settings changes: " + error); notifySavedOnUiThread(error); } }, params); }
Source:
<code>public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) { <START> if (consider == Consider.FALSE) { <END> return new CollectionResult<IInstallableUnit>(Collections.<IInstallableUnit> emptyList()); } else { return super.query(query, monitor); } }</code><technical_language>I wondering if this check caller side of this method</technical_language>

Target:
public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) { if (consider == Boolean.FALSE) { return new CollectionResult<IInstallableUnit>(Collections.<IInstallableUnit> emptyList()); } else { return super.query(query, monitor); } }
Source:
<code>public void testDeleteVaultIfEmptyOrNotFound() throws Exception { <START> assertTrue(getGlacierClient().deleteVaultIfEmpty("testDeleteVault")); <END> }</code><technical_language>if a vault exists? do deleteVaultIfEmpty(UUID.randomUUID().toString()) a vault exist</technical_language>

Target:
public void testDeleteVaultIfEmptyOrNotFound() throws Exception { assertTrue(api.deleteVaultIfEmpty(UUID.randomUUID().toString())); }
Source:
<code>public void preprocess(DataSetLookup lookup) { if (identityProvider == null || userGroupCallback == null) { return; } ColumnFilter columnFilter; List<Comparable> orgEntities = new ArrayList<>(); boolean potOwnerFilter = false; if (lookup.getFirstFilterOp() != null) { List<String> potOwners = new ArrayList<String>(); <START> List<ColumnFilter> columFilters = lookup.getFirstFilterOp().getColumnFilterList(); <END> Iterator<ColumnFilter> it= columFilters.iterator(); while ((potOwners.size() <= 0) && it.hasNext()) { CoreFunctionFilter column = (CoreFunctionFilter)it.next(); if (column.getColumnId().toUpperCase().equals(columnId)) { potOwners.addAll(column.getParameters()); for (String potOwner : potOwners) { orgEntities.addAll(Optional.ofNullable(userGroupCallback.getGroupsForUser(potOwner)).orElse(new ArrayList<>())); orgEntities.add(potOwner); } potOwnerFilter = true; int index = lookup.getFirstFilterOp().getColumnFilterIdx(column).intValue(); lookup.getFirstFilterOp().getColumnFilterList().remove(index); } } if (!potOwnerFilter) { orgEntities.addAll(Optional.ofNullable(userGroupCallback.getGroupsForUser(identityProvider.getName())).orElse(new ArrayList<>())); orgEntities.add(identityProvider.getName()); } columnFilter = AND(in(COLUMN_POTOWNER, orgEntities)); lookup.getFirstFilterOp().addFilterColumn(columnFilter); } else { DataSetFilter filter = new DataSetFilter(); orgEntities.addAll(Optional.ofNullable(userGroupCallback.getGroupsForUser(identityProvider.getName())).orElse(new ArrayList<>())); orgEntities.add(identityProvider.getName()); columnFilter = AND(in(COLUMN_POTOWNER, orgEntities)); filter.addFilterColumn(columnFilter); lookup.addOperation(filter); } LOGGER.debug("Adding column filter: {}", columnFilter); super.preprocess(lookup); }</code><technical_language>typo -> columnFilters</technical_language>

Target:
public void preprocess(DataSetLookup lookup) { if (identityProvider == null || userGroupCallback == null) { return; } ColumnFilter columnFilter; List<Comparable> orgEntities = new ArrayList<>(); if (lookup.getFirstFilterOp() != null) { List<String> potOwners = new ArrayList<String>(); List<ColumnFilter> columnFilters = lookup.getFirstFilterOp().getColumnFilterList(); Iterator<ColumnFilter> it= columnFilters.iterator(); while (orgEntities.isEmpty() && it.hasNext()) { CoreFunctionFilter column = (CoreFunctionFilter)it.next(); if (column.getColumnId().toUpperCase().equals(columnId)) { potOwners.addAll(column.getParameters()); for (String potOwner : potOwners) { addUserAndGroupsFromIdentityProvider(orgEntities, potOwner); } it.remove(); } } if (orgEntities.isEmpty()) { addUserAndGroupsFromIdentityProvider(orgEntities, identityProvider.getName()); } columnFilter = AND(in(COLUMN_POTOWNER, orgEntities)); lookup.getFirstFilterOp().addFilterColumn(columnFilter); } else { DataSetFilter filter = new DataSetFilter(); addUserAndGroupsFromIdentityProvider(orgEntities, identityProvider.getName()); columnFilter = AND(in(COLUMN_POTOWNER, orgEntities)); filter.addFilterColumn(columnFilter); lookup.addOperation(filter); } LOGGER.debug("Adding column filter: {}", columnFilter); super.preprocess(lookup); }
Source:
<code>public void setDisplayImage(BufferedImage image, Collection<ImageDetection> detections, Boolean pano) { if (image != null) { if (pano) { <START> if (imageViewer == mapillaryViewer) { <END> panel.remove(imageViewer); imageViewer = panoramicViewer; panel.add(imageViewer); } imageViewer.setImage(image, detections); } else { if (imageViewer == panoramicViewer) { panel.remove(imageViewer); imageViewer = mapillaryViewer; panel.add(imageViewer); } imageViewer.setImage(image, detections); } } else { imageViewer.setImage(null, null); } repaint(); }</code><technical_language>if (imageViewer instanceof MapillaryImageViewer)</technical_language>

Target:
public void setDisplayImage(BufferedImage image, Collection<ImageDetection> detections, Boolean pano) { if (image != null) { if (pano) { if (imageViewer instanceof MapillaryImageViewer) { panel.remove(imageViewer); imageViewer = panoramicViewer; panel.add(imageViewer); repaint(); } } else { if (imageViewer instanceof PanoramicImageViewer) { panel.remove(imageViewer); imageViewer = mapillaryViewer; panel.add(imageViewer); repaint(); } } imageViewer.setImage(image, detections); } else { imageViewer.setImage(null, null); } }
Source:
<code>public StringBuilder getResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { log.info("Add wild tasks in AddExistedTaskAction"); IProject project = (IProject) SessionManager.getProject(request); IUserSession session = (IUserSession) request.getSession().getAttribute("UserSession"); String[] selectedTaskIds = request.getParameterValues("selected"); String sprintId = request.getParameter("sprintID"); <START> Long storyId = Long.parseLong(request.getParameter("issueID")); <END> SprintBacklogHelper sprintBacklogHelper = new SprintBacklogHelper(project, session, sprintId); sprintBacklogHelper.addExistingTasksToStory(selectedTaskIds, storyId); return new StringBuilder(""); }</code><technical_language>Long -> long</technical_language>

Target:
public StringBuilder getResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { log.info("Add wild tasks in AddExistedTaskAction"); IProject project = (IProject) SessionManager.getProject(request); IUserSession session = (IUserSession) request.getSession().getAttribute("UserSession"); String[] selectedTaskIds = request.getParameterValues("selected"); String sprintId = request.getParameter("sprintID"); long storyId = Long.parseLong(request.getParameter("issueID")); SprintBacklogHelper sprintBacklogHelper = new SprintBacklogHelper(project, session, sprintId); sprintBacklogHelper.addExistingTasksToStory(selectedTaskIds, storyId); return new StringBuilder(""); }
Source:
<code>public void notifyHasMessage(Mailbox mailbox, MessageKind kind) { final Receiver receiver = mailbox.getReceiver(); final CommunicationGroup group = demandCreateGroup(receiver); <START> if (mailbox instanceof DefaultMailbox) { <END> group.defaultMailboxes.add(mailbox); } else if (kind == MessageKind.MONOTONE) { group.monotoneMailboxes.add(mailbox); } else if (kind == MessageKind.ANTI_MONOTONE) { group.nonMonotoneMailboxes.add(mailbox); } else { throw new IllegalArgumentException(); } }</code><technical_language>is this kind==null</technical_language>

Target:
public void notifyHasMessage(Mailbox mailbox, MessageKind kind) { final Receiver receiver = mailbox.getReceiver(); final CommunicationGroup group = demandCreateGroup(receiver); if (kind == null) { group.defaultMailboxes.add(mailbox); } else if (kind == MessageKind.MONOTONE) { group.monotoneMailboxes.add(mailbox); } else if (kind == MessageKind.ANTI_MONOTONE) { group.nonMonotoneMailboxes.add(mailbox); } else { throw new IllegalArgumentException(); } }
Source:
<code>public CaptureSettings withNewStorageAccountForCapturedData( final Creatable<StorageAccount> creatableStorageAccount, final String containerName) { this.ensureSettings().destination().withStorageAccountResourceId("temp-id"); this.ensureSettings().destination().withBlobContainer(containerName); addDependency(context -> creatableStorageAccount .createAsync() .last() .flatMap(indexable -> { StorageAccount storageAccount = (StorageAccount) indexable; ensureSettings().destination().withStorageAccountResourceId(storageAccount.id()); return createContainerIfNotExistsAsync(storageAccount, containerName) <START> .flatMap(blobContainer -> context.voidMono()); <END> })); return this; }</code><technical_language>blobContainer is a indexable, flatmap void</technical_language>

Target:
public CaptureSettings withNewStorageAccountForCapturedData( final Creatable<StorageAccount> creatableStorageAccount, final String containerName) { this.ensureSettings().destination().withStorageAccountResourceId("temp-id"); this.ensureSettings().destination().withBlobContainer(containerName); addDependency(context -> creatableStorageAccount .createAsync() .last() .flatMap(indexable -> { StorageAccount storageAccount = (StorageAccount) indexable; ensureSettings().destination().withStorageAccountResourceId(storageAccount.id()); return createContainerIfNotExistsAsync(storageAccount, containerName); })); return this; }
Source:
<code>public Type toStorageType(Type type) { if (type.equals(BOOLEAN) || type.equals(BIGINT) || type.equals(INTEGER) || type.equals(SMALLINT) || type.equals(TINYINT) || type.equals(DOUBLE) || type.equals(REAL) || type.equals(DATE) || isCharType(type) || isVarcharType(type) || isLongDecimal(type) || isShortDecimal(type) || type.equals(VARBINARY)) { <START> return type; <END> } if (type.equals(TIME) || type.equals(TIMESTAMP)) { return BIGINT; } if (type instanceof ArrayType) { return new ArrayType(toStorageType(((ArrayType) type).getElementType())); } if (type instanceof MapType) { return mapType(toStorageType(((MapType) type).getKeyType()), toStorageType(((MapType) type).getValueType())); } throw new PrestoException(NOT_SUPPORTED, "Type not supported: " + type); }</code><technical_language>return, assert underlying java type change</technical_language>

Target:
public Type toStorageType(Type type) { Type storageType; if (type.equals(BOOLEAN) || type.equals(BIGINT) || type.equals(INTEGER) || type.equals(SMALLINT) || type.equals(TINYINT) || type.equals(DOUBLE) || type.equals(REAL) || type.equals(DATE) || isCharType(type) || isVarcharType(type) || isLongDecimal(type) || isShortDecimal(type) || type.equals(VARBINARY)) { storageType = type; } else if (type.equals(TIME) || type.equals(TIMESTAMP)) { storageType = BIGINT; } else if (type instanceof ArrayType) { storageType = new ArrayType(toStorageType(((ArrayType) type).getElementType())); } else if (type instanceof MapType) { storageType = mapType(toStorageType(((MapType) type).getKeyType()), toStorageType(((MapType) type).getValueType())); } else { throw new PrestoException(NOT_SUPPORTED, "Type not supported: " + type); } checkState(storageType.getJavaType().equals(type.getJavaType())); return storageType; }
Source:
<code>public ActionDefinition(String tenantId, String actionPlugin, String actionId, boolean global, Map<String, String> properties, Set<String> states, TimeConstraint calendar) { this.tenantId = tenantId; this.actionPlugin = actionPlugin; this.actionId = actionId; <START> this.global = false; <END> this.properties = properties != null ? new HashMap<>(properties) : new HashMap<>(); this.states = states != null ? new HashSet<>(states) : new HashSet<>(); this.calendar = calendar; }</code><technical_language>this.global = global;</technical_language>

Target:
public ActionDefinition(String tenantId, String actionPlugin, String actionId, boolean global, Map<String, String> properties, Set<String> states, TimeConstraint calendar) { this.tenantId = tenantId; this.actionPlugin = actionPlugin; this.actionId = actionId; this.global = global; this.properties = properties != null ? new HashMap<>(properties) : new HashMap<>(); this.states = states != null ? new HashSet<>(states) : new HashSet<>(); this.calendar = calendar; }
Source:
<code>public Binding apply(TextHit hit) { BindingMap bmap = BindingFactory.create(binding); bmap.add(match, hit.getNode()); if (score != null) { bmap.add(score, NodeFactoryExtra.floatToNode(hit.getScore())); } return bmap; <START> } <END></code><technical_language>Minor improvement: BindingMap is a map bigger slot binding. This is slightly returning score: public Binding apply(TextHit hit) { if (score == null) return BindingFactory.binding(binding, match, hit.getNode()) ; BindingMap bmap = BindingFactory.create(binding); bmap.add(match, hit.getNode()); bmap.add(score, NodeFactoryExtra.floatToNode(hit.getScore())); return bmap ; }</technical_language>

Target:
public Binding apply(TextHit hit) { if (score == null) return BindingFactory.binding(binding, match, hit.getNode()); BindingMap bmap = BindingFactory.create(binding); bmap.add(match, hit.getNode()); bmap.add(score, NodeFactoryExtra.floatToNode(hit.getScore())); return bmap; }
Source:
<code>private void setWorkflowVersionSubset(Workflow workflow, String include, String versionName) { sessionFactory.getCurrentSession().detach(workflow); <START> List<WorkflowVersion> ids = this.workflowVersionDAO.getWorkflowVersionsByWorkflowId(workflow.getId(), 200, 0); <END> SortedSet<WorkflowVersion> workflowVersions = new TreeSet<>(ids); if (versionName != null && workflowVersions.stream().noneMatch(version -> version.getName().equals(versionName))) { List<WorkflowVersion> workflowVersionByWorkflowIdAndVersionName = this.workflowVersionDAO .getWorkflowVersionByWorkflowIdAndVersionName(workflow.getId(), versionName); if (workflowVersionByWorkflowIdAndVersionName.size() == 1) { WorkflowVersion workflowVersion = workflowVersionByWorkflowIdAndVersionName.get(0); workflowVersions.add(workflowVersion); } } workflow.setWorkflowVersionsOverride(workflowVersions); initializeAdditionalFields(include, workflow); ids.forEach(id -> sessionFactory.getCurrentSession().detach(id)); }</code><technical_language>200 constant</technical_language>

Target:
private void setWorkflowVersionSubset(Workflow workflow, String include, String versionName) { sessionFactory.getCurrentSession().detach(workflow); List<WorkflowVersion> ids = this.workflowVersionDAO.getWorkflowVersionsByWorkflowId(workflow.getId(), VERSION_PAGINATION_LIMIT, 0); SortedSet<WorkflowVersion> workflowVersions = new TreeSet<>(ids); if (versionName != null && workflowVersions.stream().noneMatch(version -> version.getName().equals(versionName))) { WorkflowVersion workflowVersionByWorkflowIdAndVersionName = this.workflowVersionDAO .getWorkflowVersionByWorkflowIdAndVersionName(workflow.getId(), versionName); if (workflowVersionByWorkflowIdAndVersionName != null) { workflowVersions.add(workflowVersionByWorkflowIdAndVersionName); } } workflow.setWorkflowVersionsOverride(workflowVersions); initializeAdditionalFields(include, workflow); ids.forEach(id -> sessionFactory.getCurrentSession().detach(id)); }
Source:
<code>public HttpResponse getTierPermissionsPage() throws APIManagerIntegrationTestException { try { checkAuthentication(); return HttpRequestUtil.doGet(backEndUrl + "/publisher/site/pages/tiers.jag", requestHeaders); <START> } catch (Exception e) { <END> throw new APIManagerIntegrationTestException("Exception when retrieving the Tier Permissions page", e); } }</code><technical_language>This generic exception is thrown test framework. need fix in next release</technical_language>

Target:
public HttpResponse getTierPermissionsPage() throws APIManagerIntegrationTestException { try { checkAuthentication(); return HttpRequestUtil.doGet(backendURL + "/publisher/site/pages/tiers.jag", requestHeaders); } catch (Exception e) { throw new APIManagerIntegrationTestException("Exception when retrieving the Tier Permissions page", e); } }
Source:
<code>public void log(final Long accountId, final DateTime lastSleepCycleEnd, final DateTime now, final DateTime nextRingTime, final DateTime nextRegularRingTime){ final Map<String, AttributeValue> items = new HashMap<>(); items.put(ACCOUNT_ID_ATTRIBUTE_NAME, new AttributeValue().withN(accountId.toString())); items.put(CURRENT_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(now.toString(DATETIME_FORMAT))); items.put(EXPECTED_RING_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(nextRegularRingTime.toString(DATETIME_FORMAT))); items.put(SMART_RING_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(nextRingTime.toString(DATETIME_FORMAT))); items.put(LAST_SLEEP_CYCLE_ATTRIBUTE_NAME, new AttributeValue().withS(lastSleepCycleEnd.toString(DATETIME_FORMAT))); final PutItemRequest putItemRequest = new PutItemRequest(this.tableName, items); try { final PutItemResult result = this.dynamoDBClient.putItem(putItemRequest); }catch (AmazonServiceException awsEx){ LOGGER.error("Log smart alarm for account failed, client error", accountId); }catch (AmazonClientException awcEx){ <START> LOGGER.error("Log smart alarm for account failed, client error.", accountId); <END> } }</code><technical_language>want failed</technical_language>

Target:
public void log(final Long accountId, final DateTime lastSleepCycleEnd, final DateTime now, final DateTime nextRingTime, final DateTime nextRegularRingTime){ final Map<String, AttributeValue> items = new HashMap<>(); items.put(ACCOUNT_ID_ATTRIBUTE_NAME, new AttributeValue().withN(accountId.toString())); items.put(CURRENT_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(now.toString(DATETIME_FORMAT))); items.put(EXPECTED_RING_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(nextRegularRingTime.toString(DATETIME_FORMAT))); items.put(SMART_RING_TIME_ATTRIBUTE_NAME, new AttributeValue().withS(nextRingTime.toString(DATETIME_FORMAT))); items.put(LAST_SLEEP_CYCLE_ATTRIBUTE_NAME, new AttributeValue().withS(lastSleepCycleEnd.toString(DATETIME_FORMAT))); final PutItemRequest putItemRequest = new PutItemRequest(this.tableName, items); try { final PutItemResult result = this.dynamoDBClient.putItem(putItemRequest); }catch (AmazonServiceException awsEx){ LOGGER.error("Log smart alarm for account failed, aws service error {}", accountId, awsEx.getMessage()); }catch (AmazonClientException awcEx){ LOGGER.error("Log smart alarm for account failed, client error.", accountId, awcEx.getMessage()); } }
Source:
<code>protected void updateTriggerName(NotificationContext context) { String newTriggerName = context.getTrigger().getName(); Metric triggeredMetric = context.getTriggeredMetric(); <START> newTriggerName = newTriggerName.replaceAll("\\$\\{scope\\}", triggeredMetric.getScope()); <END> newTriggerName = newTriggerName.replaceAll("\\$\\{metric\\}", triggeredMetric.getMetric()); Map<String, String> tags = triggeredMetric.getTags(); Matcher m = Pattern.compile("\\$\\{.*?\\}").matcher(newTriggerName); while (m.find()) { String currentRegex = m.group(), currentTagKey = currentRegex.substring(2, currentRegex.length()-1); if (tags.containsKey(currentTagKey)) newTriggerName = newTriggerName.replace(currentRegex, tags.get(currentTagKey)); } context.getTrigger().setName(newTriggerName); }</code><technical_language>is do case insensitive match for variables</technical_language>

Target:
protected void updateTriggerName(NotificationContext context) { String newTriggerName = context.getTrigger().getName(); Metric triggeredMetric = context.getTriggeredMetric(); newTriggerName = newTriggerName.replaceAll("(?i)\\$\\{scope\\}", triggeredMetric.getScope()); newTriggerName = newTriggerName.replaceAll("(?i)\\$\\{metric\\}", triggeredMetric.getMetric()); Map<String, String> tags = triggeredMetric.getTags(); Map<String, String> lowerCaseTagMap = getLowerCaseTagMap(tags); Matcher m = Pattern.compile("(?i)\\$\\{.*?\\}").matcher(newTriggerName); while (m.find()) { String currentRegex = m.group(), currentTagKey = currentRegex.substring(2, currentRegex.length()-1).toLowerCase(); if (lowerCaseTagMap.containsKey(currentTagKey)) newTriggerName = newTriggerName.replace(currentRegex, lowerCaseTagMap.get(currentTagKey)); } context.getTrigger().setName(newTriggerName); }
Source:
<code>public Tag saveIfDoesntExists(Tag newTag) { <START> Tag existingTag = findBySluggedName(newTag.getUriName()); <END> if (existingTag == null){ session.save(newTag); return newTag; } return existingTag; }</code><technical_language>name for both: "sluggedName" "uriName"</technical_language>

Target:
public Tag saveIfDoesntExists(Tag newTag) { Tag existingTag = findByUriName(newTag.getUriName()); if (existingTag == null){ session.save(newTag); return newTag; } return existingTag; }
Source:
<code><START> protected void doSetValue(T value) { <END> if (this.value != value) { fireValueChange(Diffs.createValueDiff(this.value, this.value = value)); } }</code><technical_language>final This this.value = some point... do if isListening = true</technical_language>

Target:
protected final void doSetValue(T value) { if (this.value != value) { fireValueChange(Diffs.createValueDiff(this.value, this.value = value)); } }
Source:
<code>private Folder createExtension(final IConfigurationElement element, final String classAttribute) throws Exception { Folder folder = null; try { Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()); URL url = extensionBundle.getResource(classAttribute); if (null != url) { <START> URI uri = URI.createURI(url.toURI().toASCIIString()); <END> String creationMenuId = getCreationMenuId(uri); folder = getCreationMenuModel(uri); defaultValues.put(creationMenuId, folder.isVisible()); String visible = preferences.get(creationMenuId, "true"); folder.setVisible(Boolean.valueOf(visible)); rootFolders.put(creationMenuId, folder); } } catch (URISyntaxException e) { throw new Exception(Messages.CreationMenuRegistry_Error_UnableToCreateExtension + e); } return folder; }</code><technical_language>extension contribution, access bundle ID (element.getContributor()) path bundle. easily create a Platform:/plugin URI instead of conversions end in a confusing URI platform:/plugin URIs work require substrings replacements. easier distinguish extensions (platform:/plugin URIs) local/workspace contributions (platform:/resource) computing menu ID</technical_language>

Target:
private Folder createExtension(final IConfigurationElement element, final String classAttribute) throws Exception { Folder folder = null; try { Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()); URL url = extensionBundle.getResource(classAttribute); if (null != url) { URI uri = URI.createPlatformPluginURI(element.getContributor().getName() + File.separator + classAttribute, false); String creationMenuId = getCreationMenuId(uri); folder = getCreationMenuModel(uri); defaultValues.put(creationMenuId, folder.isVisible()); String visible = preferences.get(creationMenuId, "true"); folder.setVisible(Boolean.valueOf(visible)); rootFolders.put(creationMenuId, folder); } } catch (URISyntaxException e) { throw new Exception(Messages.CreationMenuRegistry_Error_UnableToCreateExtension + e); } return folder; }
Source:
<code><START> protected void setAttachments(SQLDatabase db,BasicDocumentRevision rev, PreparedAndSavedAttachments preparedAndSavedAttachments) throws AttachmentNotSavedException, AttachmentException { <END> if (preparedAndSavedAttachments == null || preparedAndSavedAttachments.isEmpty()) { return; } try { for (PreparedAttachment a : preparedAndSavedAttachments.preparedAttachments) { this.addAttachment(db,a, rev); } for (SavedAttachment a : preparedAndSavedAttachments.savedAttachments) { long parentSequence = ((SavedAttachment) a).seq; long newSequence = rev.getSequence(); this.copyAttachment(db,parentSequence, newSequence, a.name); } } catch (SQLException sqe) { throw new AttachmentException("SQLException setting attachment for rev"+rev, sqe); } }</code><technical_language>AttachmentNotSavedException is reduandant a subclass of AttachmentException</technical_language>

Target:
protected void setAttachments(SQLDatabase db,BasicDocumentRevision rev, PreparedAndSavedAttachments preparedAndSavedAttachments) throws AttachmentNotSavedException, DatastoreException { if (preparedAndSavedAttachments == null || preparedAndSavedAttachments.isEmpty()) { return; } try { for (PreparedAttachment a : preparedAndSavedAttachments.preparedAttachments) { this.addAttachment(db,a, rev); } for (SavedAttachment a : preparedAndSavedAttachments.savedAttachments) { long parentSequence = ((SavedAttachment) a).seq; long newSequence = rev.getSequence(); this.copyAttachment(db,parentSequence, newSequence, a.name); } } catch (SQLException sqe) { throw new DatastoreException("SQLException setting attachment for rev"+rev, sqe); } }
Source:
<code>private void deleteRepositoryPath(Repository repository, Path path) throws IOException { String url = getContextBaseUrl() + "/delete"; RepositoryPath repositoryPath = (RepositoryPath) path.toRealPath(); String repositoryPathStr = RepositoryFiles.relativizePath(repositoryPath); <START> PathForm pathForm = buildPathForm(repository.getStorage().getId(), repository.getId(), repositoryPathStr, false); <END> givenCustom().contentType(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE) .body(pathForm) .when() .delete(url) .prettyPeek() .then() .body(containsString(SUCCESSFUL_PATH_REMOVAL)); }</code><technical_language>Cosmetic: please, chop parameters line indent properly? Thanks! :)</technical_language>

Target:
private void deleteRepositoryPath(Repository repository, Path path) throws IOException { String url = getContextBaseUrl() + "/delete"; assertThat(Files.exists(path)) .as("Failed to locate repository path '" + path + "'!") .isTrue(); RepositoryPath repositoryPath = (RepositoryPath) path.toRealPath(); String repositoryPathStr = RepositoryFiles.relativizePath(repositoryPath); PathForm pathForm = buildPathForm(repository.getStorage().getId(), repository.getId(), repositoryPathStr, false); givenCustom().contentType(MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON_VALUE) .body(pathForm) .when() .delete(url) .prettyPeek() .then() .body(containsString(SUCCESSFUL_REPOSITORY_PATH_REMOVAL)); assertThat(Files.notExists(path)) .as("Failed to delete repository path '" + path + "'!") .isTrue(); }
Source:
<code>public static String removeUnwantedCharacters(String key, String unwantedCharacters) { List<Character> unwantedChars = new ArrayList<>(); <START> for (char ch : unwantedCharacters.toCharArray()) { <END> unwantedChars.add(ch); } String newKey = key.chars() .filter(c -> unwantedCharacters.indexOf(c) == -1) .filter(c -> !DISALLOWED_CHARACTERS.contains((char) c)) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); return StringUtil.replaceSpecialCharacters(newKey); }</code><technical_language>need unwantedChars variable, do we? please delete for loop variable? --> code line 86 accesses method parameter unwantedChararacters! Side note: This is example similar variable names mixed up</technical_language>

Target:
public static String removeUnwantedCharacters(String key, String unwantedCharacters) { String newKey = key.chars() .filter(c -> unwantedCharacters.indexOf(c) == -1) .filter(c -> !DISALLOWED_CHARACTERS.contains((char) c)) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); return StringUtil.replaceSpecialCharacters(newKey); }
Source:
<code><START> public void markDiskDown() { <END> }</code><technical_language>Recommend throwing UnsupportedOperationException if disk methods called</technical_language>

Target:
public void markDiskDown() { throw new UnsupportedOperationException("markDiskDown() is not supported."); }