auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Checksum fileChecksum(File file) throws IOException { String location = file.getCanonicalPath(); <START> if (checksumsByPath.containsKey(location)) { <END> return checksumsByPath.get(location); } Checksum cs; synchronized (this) { cs = Checksum.forFile(file); } checksumsByPath.put(location, cs); return cs; }</code><technical_language>checksumsByPath is correctly synchronized here. contains() get() separate calls, item removed calls</technical_language>

Target:
private Checksum fileChecksum(File file) throws IOException { String location = file.getCanonicalPath(); synchronized (checksumsByPath) { Checksum checksum = checksumsByPath.get(location); if (checksum != null) return checksum; checksum = Checksum.forFile(file); checksumsByPath.put(location, checksum); return checksum; } }
Source:
<code>public void process(JSONRequestContext jsonRequestContext) { StudentGroupContactLogEntryCommentDAO entryCommentDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryCommentDAO(); try { Long commentId = jsonRequestContext.getLong("commentId"); <START> StudentGroupContactLogEntryComment comment = entryCommentDAO.findById(commentId); <END> String commentText = jsonRequestContext.getRequest().getParameter("commentText"); String commentCreatorName = jsonRequestContext.getRequest().getParameter("commentCreatorName"); Date commentDate = new Date(NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("commentDate"))); entryCommentDAO.update(comment, commentText, commentDate, commentCreatorName); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", comment.getId()); info.put("creatorName", comment.getCreatorName()); info.put("timestamp", comment.getCommentDate().getTime()); info.put("text", comment.getText()); info.put("entryId", comment.getEntry().getId()); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }</code><technical_language>Null-check</technical_language>

Target:
public void process(JSONRequestContext jsonRequestContext) { StudentGroupContactLogEntryCommentDAO entryCommentDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryCommentDAO(); Long commentId = jsonRequestContext.getLong("commentId"); if (commentId == null) throw new SmvcRuntimeException(StatusCode.UNDEFINED, "CommentId was not defined."); try { StudentGroupContactLogEntryComment comment = entryCommentDAO.findById(commentId); String commentText = jsonRequestContext.getString("commentText"); String commentCreatorName = jsonRequestContext.getString("commentCreatorName"); Date commentDate = jsonRequestContext.getDate("commentDate"); entryCommentDAO.update(comment, commentText, commentDate, commentCreatorName); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", comment.getId()); info.put("creatorName", comment.getCreatorName()); info.put("timestamp", comment.getCommentDate() != null ? comment.getCommentDate().getTime() : ""); info.put("text", comment.getText()); info.put("entryId", comment.getEntry().getId()); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }
Source:
<code>public void setAcceptableValues(Collection<String> values) { panels.clear(); wrapperPanel.clear(); if (values != null) { for (final String value : values) { if(! checkBoxes.containsKey(value)) { addCheckBoxOptions(value); } } } int row = 0; int column = 0; for(String currentCheckBoxLabel : panels.keySet()) { if(column == <START> 4) { <END> column = 0; row++; } weekDaysTable.setWidget(row, column, panels.get(currentCheckBoxLabel)); column++; } selectedItems = initSelectedItems(); if (selectedItemsString != null) { setSelections(Arrays.asList(selectedItemsString.split(","))); } wrapperPanel.add(weekDaysTable); }</code><technical_language>if (column == NUM_COLUMNS) ... private static final int NUM_COLUMNS = 4;</technical_language>

Target:
public void setAcceptableValues(Collection<String> values) { panels.clear(); wrapperPanel.clear(); if (values != null) { for (final String value : values) { if(! checkBoxes.containsKey(value)) { addCheckBox(value); } } } int row = 0; int column = 0; for(String currentCheckBoxLabel : panels.keySet()) { if(column == MAX_COLUMNS_IN_A_ROW) { column = 0; row++; } checkBoxesTable.setWidget(row, column, panels.get(currentCheckBoxLabel)); column++; } selectedItems = initSelectedItems(); if (selectedItemsString != null) { setSelections(Arrays.asList(selectedItemsString.split(","))); } wrapperPanel.add(checkBoxesTable); }
Source:
<code>public static void listVolumes(ServerContext context) throws Exception { try { listTable(Ample.DataLevel.ROOT, context); } catch (UnsupportedOperationException ex) { <START> } <END> System.out.println(); listTable(Ample.DataLevel.METADATA, context); System.out.println(); listTable(Ample.DataLevel.USER, context); }</code><technical_language>suppressing error here? error thrown, other calls listTable</technical_language>

Target:
public static void listVolumes(ServerContext context) throws Exception { listTable(Ample.DataLevel.ROOT, context); System.out.println(); listTable(Ample.DataLevel.METADATA, context); System.out.println(); listTable(Ample.DataLevel.USER, context); }
Source:
<code>private static void initFactoryClassList() { if (factoryClassNames.isEmpty()) { <START> String baseODK = BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/compileCommcareDebugJavaWithJavac/classes/"; <END> String baseCC = BuildConfig.PROJECT_DIR + "/../../commcare-core/build/classes/java/main/"; addExternalizableClassesFromDir(baseODK.replace("/", File.separator), factoryClassNames); addExternalizableClassesFromDir(baseCC.replace("/", File.separator), factoryClassNames); } }</code><technical_language>Is investigate ways for estimate files from? totally fine if answer is 'no' 'it's a lot of work check,' worries relying this hard coded of a setup</technical_language>

Target:
private static void initFactoryClassList() { if (factoryClassNames.isEmpty()) { String[] baseODK = new String[]{BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/compileCommcareDebugJavaWithJavac/classes/" , BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/classes/"}; String baseCC = BuildConfig.PROJECT_DIR + "/../../commcare-core/build/classes/java/main/"; for(String variant : baseODK) { addExternalizableClassesFromDir(variant.replace("/", File.separator), factoryClassNames); } addExternalizableClassesFromDir(baseCC.replace("/", File.separator), factoryClassNames); } }
Source:
<code>public void handleError(String error) { if (error != null && !error.isEmpty()) { mErrorView.setVisibility(View.VISIBLE); mErrorView.setText(error); <START> mInputView.setContentDescription(String.format("%s. %s. Error, %s.", <END> mInputView.getSelectedItemName(), mField.getInstructions(), error)); } else { logger.warn("error message not provided, so not informing the user about this error"); } }</code><technical_language>localization issue here</technical_language>

Target:
public void handleError(String error) { if (error != null && !error.isEmpty()) { mErrorView.setVisibility(View.VISIBLE); mErrorView.setText(error); final String errorTag = mInputView.getResources().getString(R.string.label_error); mInputView.setContentDescription(String.format("%s. %s. %s, %s.", mInputView.getSelectedItemName(), mField.getInstructions(), errorTag, error)); } else { logger.warn("error message not provided, so not informing the user about this error"); } }
Source:
<code>public boolean isDuplicateConcurRequestCashAdvance(ConcurRequestedCashAdvance concurRequestedCashAdvance) { Collection<ConcurRequestedCashAdvance> concurRequestedCashAdvances = null; Map<String, String> fieldValues = new HashMap<String, String>(); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.EMPLOYEE_ID, concurRequestedCashAdvance.getEmployeeId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.REQUEST_ID, concurRequestedCashAdvance.getRequestId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.PAYMENT_AMOUNT, concurRequestedCashAdvance.getPaymentAmount().toString()); concurRequestedCashAdvances = businessObjectService.findMatching(ConcurRequestedCashAdvance.class, fieldValues); <START> boolean isDuplicate = (CollectionUtils.isEmpty(concurRequestedCashAdvances)) ? false : true; <END> return isDuplicate; }</code><technical_language>simpler negate condition CollectionUtils.isNotEmpty(), avoid ternary operator here</technical_language>

Target:
public boolean isDuplicateConcurRequestCashAdvance(ConcurRequestedCashAdvance concurRequestedCashAdvance) { Collection<ConcurRequestedCashAdvance> concurRequestedCashAdvances = null; Map<String, String> fieldValues = new HashMap<String, String>(); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.EMPLOYEE_ID, concurRequestedCashAdvance.getEmployeeId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.REQUEST_ID, concurRequestedCashAdvance.getRequestId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.PAYMENT_AMOUNT, concurRequestedCashAdvance.getPaymentAmount().toString()); concurRequestedCashAdvances = businessObjectService.findMatching(ConcurRequestedCashAdvance.class, fieldValues); boolean isDuplicate = CollectionUtils.isNotEmpty(concurRequestedCashAdvances); return isDuplicate; }
Source:
<code>public TabletData(KeyExtent extent, VolumeManager fs, TabletMetadata meta) { this.time = meta.getTime(); this.compactID = meta.getCompactId().orElse(-1); this.flushID = meta.getFlushId().orElse(-1); this.directoryName = meta.getDirName(); this.logEntries.addAll(meta.getLogs()); meta.getScans() <START> .forEach(tabletFile -> scanFiles.add(new FileRef(tabletFile.getMetadataEntry()))); <END> if (meta.getLast() != null) this.lastLocation = new TServerInstance(meta.getLast()); meta.getFilesMap().forEach((tabletFile, dfv) -> { dataFiles.put(new FileRef(tabletFile.getMetadataEntry()), dfv); }); meta.getLoaded().forEach((path, txid) -> { bulkImported.computeIfAbsent(txid, k -> new ArrayList<FileRef>()).add(new FileRef(path)); }); }</code><technical_language>useful a FileRef constructor takes a TabletFile type. This converted easily consistently</technical_language>

Target:
public TabletData(KeyExtent extent, VolumeManager fs, TabletMetadata meta) { this.time = meta.getTime(); this.compactID = meta.getCompactId().orElse(-1); this.flushID = meta.getFlushId().orElse(-1); this.directoryName = meta.getDirName(); this.logEntries.addAll(meta.getLogs()); meta.getScans().forEach(tabletFile -> scanFiles.add(new FileRef(tabletFile))); if (meta.getLast() != null) this.lastLocation = new TServerInstance(meta.getLast()); meta.getFilesMap().forEach((tabletFile, dfv) -> { dataFiles.put(new FileRef(tabletFile), dfv); }); meta.getLoaded().forEach((path, txid) -> { bulkImported.computeIfAbsent(txid, k -> new ArrayList<FileRef>()).add(new FileRef(path)); }); }
Source:
<code>public void makeProgress(int progress) { <START> new Handler().postDelayed(() -> { <END> circularProgressBar.setCurrentProgress(progress); if (progress == MAX_PROGRESS) { new Handler().postDelayed(() -> { setCircularProgressVisibility(GONE); circularProgressBar.setCurrentProgress(NO_PROGRESS); }, FINAL_LOAD_DELAY); } }, NO_DELAY); }</code><technical_language>Is a reason for post()ing this, instead of executing it</technical_language>

Target:
public void makeProgress(int progress) { circularProgressBar.setCurrentProgress(progress); }
Source:
<code>public static String appendClause(String query, String clause) { if (StringUtils.isEmpty(query)) { return clause; <START> } else if (StringUtils.isEmpty(query)) { <END> return query; } else { return query + " AND " + clause; } }</code><technical_language>clause</technical_language>

Target:
public static String appendClause(String query, String clause) { if (StringUtils.isBlank(query)) { return clause; } else if (StringUtils.isBlank(clause)) { return query; } else { return query + " AND " + clause; } }
Source:
<code>public void testCountProjectsByFilter() throws MiddlewareQueryException { final List<Project> projects = this.workbenchDataManager.getProjects(); final Map<ProgramFilters, Object> filters = new HashMap<>(); if(!projects.isEmpty()){ <START> Project project = projects.get(0); <END> filters.put(ProgramFilters.CROP_TYPE, project.getCropType()); filters.put(ProgramFilters.PROGRAM_NAME, project.getProjectName()); long count = this.workbenchDataManager.countProjectsByFilter(filters); assertThat(new Long(1),is(equalTo(count))); } }</code><technical_language>add final</technical_language>

Target:
public void testCountProjectsByFilter() throws MiddlewareQueryException { final List<Project> projects = this.workbenchDataManager.getProjects(); final Map<ProgramFilters, Object> filters = new HashMap<>(); if(!projects.isEmpty()){ final Project project = projects.get(0); filters.put(ProgramFilters.CROP_TYPE, project.getCropType()); filters.put(ProgramFilters.PROGRAM_NAME, project.getProjectName()); final long count = this.workbenchDataManager.countProjectsByFilter(filters); assertThat(new Long(1),is(equalTo(count))); } }
Source:
<code><START> public boolean isTheNewDesignAvailable() { <END> if (Jenkins.getVersion().isNewerThan(new VersionNumber("2.88"))) { return true; } return false; }</code><technical_language>@Restricted(DoNotUse.class)</technical_language>

Target:
public boolean isTheNewDesignAvailable() { final VersionNumber version = Jenkins.getVersion(); if (version != null && version.isNewerThan(new VersionNumber("2.103"))) { return true; } return false; }
Source:
<code><START> public Binding[] getBindings() { <END> Set<Binding> bindings = new HashSet<Binding>(); bindings.addAll(bindingService.getActiveBindings()); for (Binding binding : manager.getBindings()) { bindings.add(binding); } return bindings.toArray(new Binding[0]); }</code><technical_language>This place for modifying list of bindings seen. I progammatically created bindings added model survive</technical_language>

Target:
public Binding[] getBindings() { return manager.getBindings(); }
Source:
<code>Sample to(SampleDto sampleDto) throws IOException { authorizationManager.throwIfUnauthenticated(); checkArgument(sampleDto.getProjectId() != null, "A Project id must be provided to construct Sample."); Sample sample = Dtos.to(sampleDto); Project project = sqlProjectDAO.get(sampleDto.getProjectId()); ServiceUtils.throwIfNull(project, "projectId", sampleDto.getProjectId()); sample.setProject(project); <START> if (sampleDto.getSampleAdditionalInfo().getParentId() != null) { <END> Sample parent = sampleDao.getSample(sampleDto.getSampleAdditionalInfo().getParentId()); ServiceUtils.throwIfNull(parent, "parentId", sampleDto.getSampleAdditionalInfo().getParentId()); sample.getSampleAdditionalInfo().setParent(parent); } if (sampleDto.getSampleIdentity() != null) { sample.setIdentity(identityService.to(sampleDto.getSampleIdentity())); } if (sampleDto.getSampleAnalyte() != null) { sample.setSampleAnalyte(sampleAnalyteService.to(sampleDto.getSampleAnalyte())); } if (sampleDto.getSampleTissue() != null) { sample.setSampleTissue(sampleTissueService.to(sampleDto.getSampleTissue())); } return sample; }</code><technical_language>Check sampleDto.getSampleAdditionalInfo() null well</technical_language>

Target:
Sample to(SampleDto sampleDto) throws IOException { authorizationManager.throwIfUnauthenticated(); checkArgument(sampleDto.getProjectId() != null, "A Project id must be provided to construct Sample."); Sample sample = Dtos.to(sampleDto); Project project = sqlProjectDAO.get(sampleDto.getProjectId()); ServiceUtils.throwIfNull(project, "projectId", sampleDto.getProjectId()); sample.setProject(project); if (sampleDto.getSampleAdditionalInfo() != null && sampleDto.getSampleAdditionalInfo().getParentId() != null) { Sample parent = sampleDao.getSample(sampleDto.getSampleAdditionalInfo().getParentId()); ServiceUtils.throwIfNull(parent, "parentId", sampleDto.getSampleAdditionalInfo().getParentId()); sample.getSampleAdditionalInfo().setParent(parent); } if (sampleDto.getSampleIdentity() != null) { sample.setIdentity(identityService.to(sampleDto.getSampleIdentity())); } if (sampleDto.getSampleAnalyte() != null) { sample.setSampleAnalyte(sampleAnalyteService.to(sampleDto.getSampleAnalyte())); } if (sampleDto.getSampleTissue() != null) { sample.setSampleTissue(sampleTissueService.to(sampleDto.getSampleTissue())); } return sample; }
Source:
<code>protected String createProcessTitle(Map<String, String> context) { <START> return "MoveIndexAlias"; <END> }</code><technical_language>Strings.apply("Movin Elasticsearch Index %s %s, ....) - _very nice_</technical_language>

Target:
protected String createProcessTitle(Map<String, String> context) { return Strings.apply("Moving active elasticsearch alias from index '%s' to '%s'", Strings.join(elastic.getLowLevelClient() .getIndicesForAlias(mixing.getDescriptor(context.get("ed"))), ","), context.get("destination")); }
Source:
<code>public Response doExport(Action action) { validateParameters(action, "storageDomain.id|name"); Disk disk = get(); <START> Guid sourceStorageDomainId = new Guid(disk.getStorageDomains().getStorageDomains().get(0).getId()); <END> Guid sourceStoragePoolId = StorageDomainHelper.getStoragePoolIdForDomain(this, sourceStorageDomainId); ExportRepoImageParameters exportParameters = new ExportRepoImageParameters(new Guid(disk.getImageId())); exportParameters.setStoragePoolId(sourceStoragePoolId); exportParameters.setStorageDomainId(sourceStorageDomainId); exportParameters.setImageGroupID(new Guid(disk.getId())); exportParameters.setDestinationDomainId(getStorageDomainId(action)); return doAction(VdcActionType.ExportRepoImage, exportParameters, action); }</code><technical_language>please asGuid()</technical_language>

Target:
public Response doExport(Action action) { validateParameters(action, "storageDomain.id|name"); Disk disk = get(); ExportRepoImageParameters exportParameters = new ExportRepoImageParameters(asGuid(disk.getImageId())); exportParameters.setStorageDomainId(asGuid(disk.getStorageDomains().getStorageDomains().get(0).getId())); exportParameters.setStoragePoolId(getDataCenterId(exportParameters.getStorageDomainId())); exportParameters.setImageGroupID(asGuid(disk.getId())); exportParameters.setDestinationDomainId(getStorageDomainId(action)); return doAction(VdcActionType.ExportRepoImage, exportParameters, action); }
Source:
<code>public void drawLicenseIcons(ImageLicense license, Canvas canvas, Context context) { final int bottom = SnippetImage.HEIGHT - SnippetImage.BOTTOM_PADDING; final int top = bottom - SnippetImage.ICONS_HEIGHT; int left = SnippetImage.HORIZONTAL_PADDING; int right = left + SnippetImage.ICONS_WIDTH; if (isArticleRTL) { right = SnippetImage.WIDTH - SnippetImage.HORIZONTAL_PADDING; left = right - SnippetImage.ICONS_WIDTH; } <START> if (!license.isMainPage()) { <END> Drawable d = context.getResources().getDrawable(license.getLicenseIcon()); d.setBounds(left, top, right, bottom); d.draw(canvas); } }</code><technical_language>adding a license icon sharing a main page? If a valid reason sense skip method</technical_language>

Target:
public void drawLicenseIcons(ImageLicense license, Canvas canvas, Context context) { final int bottom = SnippetImage.HEIGHT - SnippetImage.BOTTOM_PADDING; final int top = bottom - SnippetImage.ICONS_HEIGHT; int left = SnippetImage.HORIZONTAL_PADDING; int right = left + SnippetImage.ICONS_WIDTH; if (isArticleRTL) { right = SnippetImage.WIDTH - SnippetImage.HORIZONTAL_PADDING; left = right - SnippetImage.ICONS_WIDTH; } Drawable d = context.getResources().getDrawable(leadImageBitmap == null ? R.drawable.ic_license_cc : license.getLicenseIcon()); d.setBounds(left, top, right, bottom); d.draw(canvas); }
Source:
<code>private static boolean getLoginStatus(final String page) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.checkLogin: No page given"); return false; } setActualStatus(res.getString(R.string.init_login_popup_ok)); setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME)); if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); setActualMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")); <START> setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,\\.]", ""))); <END> return true; } setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME_LOGIN_PAGE)); if (isActualLoginStatus()) { setActualUserName(Settings.getUsername()); setActualMemberStatus(Settings.getMemberStatus()); return true; } setActualStatus(res.getString(R.string.init_login_popup_failed)); return false; }</code><technical_language>dot escaped here. This match . , \. discused this a months I introduced new pattern</technical_language>

Target:
private static boolean getLoginStatus(final String page) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.checkLogin: No page given"); return false; } setActualStatus(res.getString(R.string.init_login_popup_ok)); setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME)); if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); setActualMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")); setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", ""))); return true; } setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME_LOGIN_PAGE)); if (isActualLoginStatus()) { setActualUserName(Settings.getUsername()); setActualMemberStatus(Settings.getMemberStatus()); return true; } setActualStatus(res.getString(R.string.init_login_popup_failed)); return false; }
Source:
<code>List<String> getAllSeeds() { <START> final ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); <END> return builder.addAll(currentSeeds).addAll(newSeeds).addAll(oldSeeds).build(); }</code><technical_language>chain this java return ImmutableList.<String>builder() .addAll(currentSeeds) .addAll(newSeeds) .addAll(oldSeeds) .build();</technical_language>

Target:
List<String> getAllSeeds() { return new ImmutableList.Builder<String>() .addAll(currentSeeds) .addAll(newSeeds) .addAll(oldSeeds) .build(); }
Source:
<code>public void filter() { final String filterText = view.getFilterText(); final List<SocialUser> filteredUsers = allUsers.stream() <START> .filter(user -> user.getName().contains(filterText) || user.getUserName().contains(filterText)) <END> .collect(Collectors.toList()); listUsers(filteredUsers); }</code><technical_language>In ContributorsManagementListItemPresenter.java Line 55 checking user.getName() for null not. NPE</technical_language>

Target:
public void filter() { final String filterText = view.getFilterText(); final List<SocialUser> filteredUsers = allUsers.stream() .filter(user -> { final String name = user.getName(); final String userName = user.getUserName(); final boolean nameMatch = name != null && name.contains(filterText); final boolean userNameMatch = userName.contains(filterText); return nameMatch || userNameMatch; }) .collect(Collectors.toList()); listUsers(filteredUsers); }
Source:
<code>public synchronized PartitioningSpillResult partitionAndSpill(Page page, IntPredicate spillPartitionMask) { requireNonNull(page, "page is null"); requireNonNull(spillPartitionMask, "spillPartitionMask is null"); checkArgument(page.getChannelCount() == types.size(), "Wrong page channel count, expected %s but got %s", types.size(), page.getChannelCount()); checkState(!readingStarted, "reading already started"); IntArrayList unspilledPositions = partitionPage(page, spillPartitionMask); ListenableFuture<?> future = flushFullBuilders(); <START> return new PartitioningSpillResult(future, page.getPositions(unspilledPositions.toIntArray(), 0, unspilledPositions.size())); <END> }</code><technical_language>use: page.getPositions(unspilledPositions.elements(), 0, unspilledPositions.size())); avoid copyinig</technical_language>

Target:
public synchronized PartitioningSpillResult partitionAndSpill(Page page, IntPredicate spillPartitionMask) { requireNonNull(page, "page is null"); requireNonNull(spillPartitionMask, "spillPartitionMask is null"); checkArgument(page.getChannelCount() == types.size(), "Wrong page channel count, expected %s but got %s", types.size(), page.getChannelCount()); checkState(!readingStarted, "reading already started"); IntArrayList unspilledPositions = partitionPage(page, spillPartitionMask); ListenableFuture<?> future = flushFullBuilders(); return new PartitioningSpillResult(future, page.getPositions(unspilledPositions.elements(), 0, unspilledPositions.size())); }
Source:
<code>void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK_VERSION >= OS.VERSION (3, 10, 0)) { long context = OS.gtk_widget_get_style_context (handle); String css = "GtkWindow {background-color: rgb(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); <START> } else if (OS.GTK_VERSION < OS.VERSION (3, 10, 0) && OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) { <END> GdkColor color = background.handle; GdkRGBA rgba = new GdkRGBA(); rgba.alpha = 1; rgba.red = (color.red & 0xFFFF) / (float)0xFFFF; rgba.green = (color.green & 0xFFFF) / (float)0xFFFF; rgba.blue = (color.blue & 0xFFFF) / (float)0xFFFF; OS.gtk_widget_override_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }</code><technical_language>Try if merge if gtk3.0 - gtk3.10+ a single block check if works pre gtk 3.10</technical_language>

Target:
void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK3) { long context = OS.gtk_widget_get_style_context (handle); String css = "GtkWindow {background-color: rgb(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }
Source:
<code>public void test() { SampleResult samplerResult = new SampleResult(); samplerResult.setResponseData(responseData, null); JMESPathAssertion instance = new JMESPathAssertion(); instance.setJmesPath(jmesPath); instance.setJsonValidationBool(isValidation == ValidationType.USE_VALIDATION); instance.setInvert(isInverted == InvertType.USE_INVERT); instance.setIsRegex(isRegex == ComparisonType.USE_REGEX); instance.setExpectNull(isExpectedNull == ResultNullity.EXPECT_NULL); instance.setExpectedValue(expectedValue); AssertionResult expResult = new AssertionResult(""); AssertionResult result = instance.getResult(samplerResult); assertEquals(expResult.getName(), result.getName()); switch (resultType) { case SUCCESS: assertFalse(result.isError()); <START> assertFalse(result.isFailure()); <END> break; case FAILURE: assertFalse(result.isError()); assertTrue(result.isFailure()); break; case ERROR: assertTrue(result.isError()); assertFalse(result.isFailure()); break; default: throw new IllegalArgumentException("Unexpected type:"+resultType); } assertEquals(failureMessage, result.getFailureMessage()); }</code><technical_language>Asserttrue/false produce hard-to-understand error messages. if convert result.isError()+result.isFailure() ResultType enum, assert expected of enum</technical_language>

Target:
public void test() { SampleResult samplerResult = new SampleResult(); samplerResult.setResponseData(responseData, null); JMESPathAssertion instance = new JMESPathAssertion(); instance.setJmesPath(jmesPath); instance.setJsonValidationBool(isValidation == ValidationType.USE_VALIDATION); instance.setInvert(isInverted == InvertType.USE_INVERT); instance.setIsRegex(isRegex == ComparisonType.USE_REGEX); instance.setExpectNull(isExpectedNull == ResultNullity.EXPECT_NULL); instance.setExpectedValue(expectedValue); AssertionResult expResult = new AssertionResult(""); AssertionResult result = instance.getResult(samplerResult); assertEquals(expResult.getName(), result.getName()); if (result.isError() && !result.isFailure()) { assertEquals(resultType, ResultType.ERROR); } else if (result.isFailure() && !result.isError()) { assertEquals(resultType, ResultType.FAILURE); } else if (!result.isError() && !result.isFailure()){ assertEquals(resultType, ResultType.SUCCESS); } else { fail("Got unexpected state where AssertionResult is in error and in failure"); } assertEquals(failureMessage, result.getFailureMessage()); }
Source:
<code>public void testPherfMain() throws Exception{ String[] args = {"-q", "--scenarioFile", ".*prod_test_unsalted_scenario.*" }; try { Pherf.main(args); } catch (Exception e) { fail("Test encountered an exception."); <START> throw e; <END> } }</code><technical_language>throw e executed</technical_language>

Target:
public void testPherfMain() { String[] args = { "-q", "--scenarioFile", ".*prod_test_unsalted_scenario.*", "-m", "--monitorFrequency", "10" }; Pherf.main(args); }
Source:
<code>public void testAddBeforeExecutionFileFilterAsChild() throws Exception { final Checker checker = new Checker(); final TestBeforeExecutionFileFilter fileFilter = new TestBeforeExecutionFileFilter(); final PackageObjectFactory factory = new PackageObjectFactory( new HashSet<>(), Thread.currentThread().getContextClassLoader()) { @Override public Object createModule(String name) throws CheckstyleException { Object filter = fileFilter; if (!name.equals(TestBeforeExecutionFileFilter.class.getName())) { filter = super.createModule(name); } return filter; } }; checker.setModuleFactory(factory); checker.setupChild(createCheckConfig(TestBeforeExecutionFileFilter.class)); <START> getAcceptFileStarted().invoke(checker, "test_file.name"); <END> assertTrue("Checker.acceptFileStarted() doesn't call listener", fileFilter.wasCalled()); }</code><technical_language>call checker - checker.process(.....)</technical_language>

Target:
public void testAddBeforeExecutionFileFilterAsChild() throws Exception { final Checker checker = new Checker(); final TestBeforeExecutionFileFilter fileFilter = new TestBeforeExecutionFileFilter(); final PackageObjectFactory factory = new PackageObjectFactory( new HashSet<>(), Thread.currentThread().getContextClassLoader()) { @Override public Object createModule(String name) throws CheckstyleException { Object filter = fileFilter; if (!name.equals(TestBeforeExecutionFileFilter.class.getName())) { filter = super.createModule(name); } return filter; } }; checker.setModuleFactory(factory); checker.setupChild(createCheckConfig(TestBeforeExecutionFileFilter.class)); checker.process(Collections.singletonList(new File("dummy.java"))); assertTrue("Checker.acceptFileStarted() doesn't call listener", fileFilter.wasCalled()); }
Source:
<code>public CompletableFuture<V> replaceAsync(K key, V value) { <START> return super.replaceAsync(keyToStorage(key), valueToStorage(value)).thenApply(transcodeValueForRead); <END> }</code><technical_language>missing some variables here. I if a common method for configuring if add more 'with' methods invoke proper method instead of adding of lines</technical_language>

Target:
public CompletableFuture<V> replaceAsync(K key, V value) { return super.replaceAsync(keyToStorage(key), valueToStorage(value)).thenApply(decodedValueForRead); }
Source:
<code>public static byte[] safelyLoadFileBytes(String fullyQualifiedFileName) { InputStream fileContents; byte[] fileByteContent; try { fileContents = new FileInputStream(fullyQualifiedFileName); } catch (FileNotFoundException e1) { LOG.error("safelyLoadFileBytes: Batch file not found [" + fullyQualifiedFileName + "]. " + e1.getMessage()); throw new RuntimeException("Batch File not found [" + fullyQualifiedFileName + "]. " + e1.getMessage(), e1); } try { fileByteContent = IOUtils.toByteArray(fileContents); } catch (IOException e1) { LOG.error("safelyLoadFileBytes: IO Exception loading: [" + fullyQualifiedFileName + "]. " + e1.getMessage()); throw new RuntimeException("IO Exception loading: [" + fullyQualifiedFileName + "]. " + e1.getMessage(), e1); } finally { try { IOUtils.closeQuietly(fileContents); } catch (Exception e) { <START> LOG.error("safelyLoadFileBytes, unable tlose input stream.", e); <END> } } return fileByteContent; }</code><technical_language>Do need this try-catch block IOUtils.closeQuietly? I impression method null-safe, avoid throwing exceptions if close failed. If this try-catch is needed, please fix typo in this error message (should "to close" instead of "tlose")</technical_language>

Target:
public static byte[] safelyLoadFileBytes(String fullyQualifiedFileName) { InputStream fileContents; byte[] fileByteContent; try { fileContents = new FileInputStream(fullyQualifiedFileName); } catch (FileNotFoundException e1) { LOG.error("safelyLoadFileBytes: Batch file not found [" + fullyQualifiedFileName + "]. " + e1.getMessage()); throw new RuntimeException("Batch File not found [" + fullyQualifiedFileName + "]. " + e1.getMessage(), e1); } try { fileByteContent = IOUtils.toByteArray(fileContents); } catch (IOException e1) { LOG.error("safelyLoadFileBytes: IO Exception loading: [" + fullyQualifiedFileName + "]. " + e1.getMessage()); throw new RuntimeException("IO Exception loading: [" + fullyQualifiedFileName + "]. " + e1.getMessage(), e1); } finally { IOUtils.closeQuietly(fileContents); } return fileByteContent; }
Source:
<code>public static StyledString markLTR(StyledString styledString) { if (!USE_TEXT_PROCESSOR) return styledString; String inputString= styledString.getString(); String string= TextProcessor.process(inputString); if <START> (!Objects.equals(string, inputString)) <END> insertMarks(styledString, inputString, string); return styledString; }</code><technical_language>This written this way. code readable</technical_language>

Target:
public static StyledString markLTR(StyledString styledString) { if (!USE_TEXT_PROCESSOR) return styledString; String inputString= styledString.getString(); String string= TextProcessor.process(inputString); if ((string == null && inputString != null) || (string != null && !string.equals(inputString))) insertMarks(styledString, inputString, string); return styledString; }
Source:
<code>public Frame decorrelateRel(Sort rel) { assert !cm.mapRefRelToCorRef.containsKey(rel); final RelNode oldInput = rel.getInput(); final Frame frame = getInvoke(oldInput, rel); if (frame == null) { return null; } final RelNode newInput = frame.r; Mappings.TargetMapping mapping = Mappings.target(frame.oldToNewOutputs, oldInput.getRowType().getFieldCount(), newInput.getRowType().getFieldCount()); RelCollation oldCollation = rel.getCollation(); RelCollation newCollation = RexUtil.apply(mapping, oldCollation); final Sort newSort = <START> (Sort) relBuilder <END> .push(newInput) .sortLimit(newCollation, rel.offset, rel.fetch) .build(); return register(rel, newSort, frame.oldToNewOutputs, frame.corDefOutputs); }</code><technical_language>is guaranteed relbuilder return a sort (for example if newInput correct collation?)</technical_language>

Target:
public Frame decorrelateRel(Sort rel) { assert !cm.mapRefRelToCorRef.containsKey(rel); final RelNode oldInput = rel.getInput(); final Frame frame = getInvoke(oldInput, rel); if (frame == null) { return null; } final RelNode newInput = frame.r; Mappings.TargetMapping mapping = Mappings.target(frame.oldToNewOutputs, oldInput.getRowType().getFieldCount(), newInput.getRowType().getFieldCount()); RelCollation oldCollation = rel.getCollation(); RelCollation newCollation = RexUtil.apply(mapping, oldCollation); final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); final int fetch = rel.fetch == null ? 0 : RexLiteral.intValue(rel.fetch); final RelNode newSort = relBuilder .push(newInput) .sortLimit(offset, fetch, relBuilder.fields(newCollation)) .build(); return register(rel, newSort, frame.oldToNewOutputs, frame.corDefOutputs); }
Source:
<code>public void testInspectNode() throws Exception { final DefaultDockerClient dockerClient = new DefaultDockerClient(builder); <START> server.enqueue(new MockResponse() <END> .setResponseCode(200) .addHeader("Content-Type", "application/json") .setBody( createObjectNode() .put("ApiVersion", "1.28") .put("Arch", "foobar") .put("GitCommit", "foobar") .put("GoVersion", "foobar") .put("KernelVersion", "foobar") .put("Os", "foobar") .put("Version", "1.20") .toString() ) ); server.enqueue(new MockResponse() .setResponseCode(200) .addHeader("Content-Type", "application/json") .setBody( fixture("fixtures/1.28/nodeInfo.json") ) ); NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk"); assertThat(nodeInfo, notNullValue()); assertThat(nodeInfo.id(), is("24ifsmvkjbyhk")); assertThat(nodeInfo.status(), notNullValue()); assertThat(nodeInfo.status().addr(), is("172.17.0.2")); assertThat(nodeInfo.managerStatus(), notNullValue()); assertThat(nodeInfo.managerStatus().addr(), is("172.17.0.2:2377")); assertThat(nodeInfo.managerStatus().leader(), is(true)); assertThat(nodeInfo.managerStatus().reachability(), is("reachable")); }</code><technical_language>this is repeated times, abstract separate method enqueueServerApiVersion(final String apiVersion)</technical_language>

Target:
public void testInspectNode() throws Exception { final DefaultDockerClient dockerClient = new DefaultDockerClient(builder); enqueueServerApiVersion("1.28"); server.enqueue(new MockResponse() .setResponseCode(200) .addHeader("Content-Type", "application/json") .setBody( fixture("fixtures/1.28/nodeInfo.json") ) ); NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk"); assertThat(nodeInfo, notNullValue()); assertThat(nodeInfo.id(), is("24ifsmvkjbyhk")); assertThat(nodeInfo.status(), notNullValue()); assertThat(nodeInfo.status().addr(), is("172.17.0.2")); assertThat(nodeInfo.managerStatus(), notNullValue()); assertThat(nodeInfo.managerStatus().addr(), is("172.17.0.2:2377")); assertThat(nodeInfo.managerStatus().leader(), is(true)); assertThat(nodeInfo.managerStatus().reachability(), is("reachable")); }
Source:
<code>public void testTransientCleanup() throws IOException { Path path = Files.createTempFile("pfouh","pfouh"); FileBlob blob = new FileBlob("pfouh"); <START> Files.move(path, blob.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING); <END> String key = downloadService.store(Collections.singletonList(blob)); ByteArrayOutputStream out = new ByteArrayOutputStream(); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getMethod()).thenReturn("GET"); HttpServletResponse response = mock(HttpServletResponse.class); ServletOutputStream sos = new ServletOutputStream() { @Override public void write(int b) throws IOException { out.write(b); } }; @SuppressWarnings("resource") PrintWriter printWriter = new PrintWriter(sos); when(response.getOutputStream()).thenReturn(sos); when(response.getWriter()).thenReturn(printWriter); NuxeoPrincipal principal = new UserPrincipal("bob", Collections.singletonList("members"), false, false); LoginStack loginStack = ClientLoginModule.getThreadLocalLogin(); loginStack.push(principal, null, null); try { downloadService.downloadBlob(request, response, key, "download"); } finally { loginStack.pop(); } assertFalse(blob.getFile().exists()); }</code><technical_language>Please a static import for REPLACE_EXISTING</technical_language>

Target:
public void testTransientCleanup() throws IOException { Path path = Files.createTempFile("pfouh","pfouh"); FileBlob blob = new FileBlob("pfouh"); Files.move(path, blob.getFile().toPath(), REPLACE_EXISTING); String key = downloadService.storeBlobs(Collections.singletonList(blob)); ByteArrayOutputStream out = new ByteArrayOutputStream(); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getMethod()).thenReturn("GET"); HttpServletResponse response = mock(HttpServletResponse.class); ServletOutputStream sos = new ServletOutputStream() { @Override public void write(int b) throws IOException { out.write(b); } }; @SuppressWarnings("resource") PrintWriter printWriter = new PrintWriter(sos); when(response.getOutputStream()).thenReturn(sos); when(response.getWriter()).thenReturn(printWriter); NuxeoPrincipal principal = new UserPrincipal("bob", Collections.singletonList("members"), false, false); LoginStack loginStack = ClientLoginModule.getThreadLocalLogin(); loginStack.push(principal, null, null); try { downloadService.downloadBlob(request, response, key, "download"); } finally { loginStack.pop(); } assertFalse(blob.getFile().exists()); }
Source:
<code>public static URL sizedURL(Context context, String url, float dpSize) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpSize, r.getDisplayMetrics()); try { <START> return new URL(ZulipApp.get().getServerHostUri() + url + "&s=" + px); <END> } catch (MalformedURLException e) { ZLog.logException(e); return null; } }</code><technical_language>confirm: Zulip sends relative URLs (for custom avatars) absolute URLs (for default gravatars); this code handle cases</technical_language>

Target:
public static URL sizedURL(Context context, String url, float dpSize) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpSize, r.getDisplayMetrics()); try { return new URL(UrlHelper.addHost(url) + "&s=" + px); } catch (MalformedURLException e) { ZLog.logException(e); return null; } }
Source:
<code>public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DataConversion that = (DataConversion) o; return Objects.equals(encoder, that.encoder) && Objects.equals(wrapper, that.wrapper) && Objects.equals(transcoder, that.transcoder) && <START> isKey == that.isKey; <END> }</code><technical_language>Putting isKey == that.isKey comparison fail faster :)</technical_language>

Target:
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DataConversion that = (DataConversion) o; return isKey == that.isKey && Objects.equals(encoder, that.encoder) && Objects.equals(wrapper, that.wrapper) && Objects.equals(transcoder, that.transcoder); }
Source:
<code>public static CassandraKeyValueService createForTesting(CassandraKeyValueServiceConfig config) { MetricsManager metricsManager = MetricsManagers.createForTests(); Logger log = LoggerFactory.getLogger(CassandraKeyValueService.class); Pair<CassandraClientPool, Optional<AsyncClusterSession>> connections; try { <START> connections = config.servers() <END> .visit((thriftServers, maybeCqlServers) -> { CassandraClientPool clientPool = CassandraClientPoolImpl.createImplForTest(metricsManager, config, CassandraClientPoolImpl.StartupChecks.RUN, new Blacklist(config)); log.info("Maybe creating AsyncClusterSession"); AsyncClusterSession asyncClusterSession = maybeCqlServers .map(servers -> { log.info("Creating an AsyncClusterSession"); return AsyncSessionManager .getOrInitializeAsyncSessionManager() .getAsyncSession(config, servers); }).orElse(null); return new Pair<>(clientPool, Optional.of(asyncClusterSession)); }); } catch (Exception e) { log.warn("AsyncClusterSession cretion exception", e); throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } return createOrShutdownClientPool(metricsManager, config, CassandraKeyValueServiceRuntimeConfig::getDefault, connections.lhSide, connections.rhSide, CassandraMutationTimestampProviders.legacyModeForTestsOnly(), log, AtlasDbConstants.DEFAULT_INITIALIZE_ASYNC); }</code><technical_language>able share some code here</technical_language>

Target:
public static CassandraKeyValueService createForTesting(CassandraKeyValueServiceConfig config) { try { MetricsManager metricsManager = MetricsManagers.createForTests(); CqlClusterManager cqlClusterManager = config.cqlClusterManager() .orElseGet(DefaultCqlClusterManager::getInstance); CassandraClientPool clientPool = CassandraClientPoolImpl.createImplForTest(metricsManager, config, CassandraClientPoolImpl.StartupChecks.RUN, new Blacklist(config)); Optional<CqlClusterClient> asyncClusterSession = config.servers() .visit((thriftServers, maybeCqlServers) -> maybeCqlServers .map(servers -> cqlClusterManager.createCqlClusterClient(config, servers))); return createOrShutdownClientPool(metricsManager, config, CassandraKeyValueServiceRuntimeConfig::getDefault, clientPool, asyncClusterSession, CassandraMutationTimestampProviders.legacyModeForTestsOnly(), LoggerFactory.getLogger(CassandraKeyValueService.class), AtlasDbConstants.DEFAULT_INITIALIZE_ASYNC); } catch (Exception e) { throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } }
Source:
<code>public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) { MobileTestSession mobileSession = Grid.getMobileTestSession(); capabilities.setCapability(MobileCapabilityType.APP, mobileSession.getAppName()); if (StringUtils.isBlank(mobileSession.getAppName())) { capabilities.setCapability(MobileCapabilityType.APP, mobileSession.getAppPath()); } capabilities.setCapability(MOBILE_NODE_TYPE, mobileSession.getMobileNodeType().getAsString()); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, mobileSession.getDeviceType()); <START> if (mobileSession.getDeviceType() != null) { <END> capabilities.setBrowserName(mobileSession.getDeviceType().toLowerCase()); } capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, mobileSession.getPlatformVersion()); capabilities.setCapability(APPIUM_LOCALE_TYPE, mobileSession.getAppLocale()); capabilities.setCapability(APPIUM_LANGUAGE_TYPE, mobileSession.getAppLanguage()); if (mobileSession.getPlatform() == WebDriverPlatform.ANDROID) { capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_ANDROID_PLATFORM_TYPE); capabilities.setPlatform(Platform.ANDROID); } if (mobileSession.getPlatform() == WebDriverPlatform.IOS) { capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_IOS_PLATFORM_TYPE); capabilities.setPlatform(Platform.MAC); } return capabilities; }</code><technical_language>StringUtils.isNotBlank instead? Also, swapping lines 47 & 48 pull 47 this if block</technical_language>

Target:
public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) { MobileTestSession mobileSession = Grid.getMobileTestSession(); capabilities.setCapability(MobileCapabilityType.APP, mobileSession.getAppName()); if (StringUtils.isBlank(mobileSession.getAppName())) { capabilities.setCapability(MobileCapabilityType.APP, mobileSession.getAppPath()); } capabilities.setCapability(MOBILE_NODE_TYPE, mobileSession.getMobileNodeType().getAsString()); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, mobileSession.getDeviceType()); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, mobileSession.getPlatformVersion()); capabilities.setCapability(APPIUM_LOCALE_TYPE, mobileSession.getAppLocale()); capabilities.setCapability(APPIUM_LANGUAGE_TYPE, mobileSession.getAppLanguage()); if (mobileSession.getPlatform() == WebDriverPlatform.ANDROID) { capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_ANDROID_PLATFORM_TYPE); } if (mobileSession.getPlatform() == WebDriverPlatform.IOS) { capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_IOS_PLATFORM_TYPE); } return capabilities; }