auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testVersionsLocation() { CreateContainerOptions options = new CreateContainerOptions().headers(ImmutableMultimap.of(CONTAINER_VERSIONS_LOCATION, "versions")); <START> assertEquals(ImmutableList.of("versions"), options.buildRequestHeaders().get(CONTAINER_VERSIONS_LOCATION)); <END> }</code><technical_language>For assertions: other around? TestNG is assertEquals(actual, expected)</technical_language>

Target:
public void testVersionsLocation() { CreateContainerOptions options = new CreateContainerOptions().headers(ImmutableMultimap.of(VERSIONS_LOCATION, "containerWithVersions")); assertEquals(options.buildRequestHeaders().get(VERSIONS_LOCATION), ImmutableList.of("containerWithVersions")); }
Source:
<code>Map<Long, ILogData> readRange(RuntimeLayout runtimeLayout, Set<Long> globalAddresses) { return globalAddresses.parallelStream() <START> .map(a -> new SimpleImmutableEntry<>(a, read(runtimeLayout, a))) <END> .collect(Collectors.toMap(SimpleImmutableEntry::getKey, SimpleImmutableEntry::getValue)); }</code><technical_language>need map</technical_language>

Target:
Map<Long, ILogData> readRange(RuntimeLayout runtimeLayout, Set<Long> globalAddresses) { return globalAddresses .parallelStream() .collect(Collectors.toMap(Function.identity(),a -> read(runtimeLayout, a))); }
Source:
<code>public static double[] findCoordinatesByIp() { double lat = 0; double lon = 0; try { URL geoIpUrl = new URL("<LINK_0>"); URLConnection conn = geoIpUrl.openConnection(); ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_BYTE_STREAM); org.apache.commons.io.IOUtils.copy(conn.getInputStream(), output); <START> output.close(); <END> String result = output.toString(); twitter4j.JSONObject myGeoLocation = new twitter4j.JSONObject(result); String[] loc = myGeoLocation.getString("loc").split(","); System.out.printf(loc[0]); lat = Double.parseDouble(loc[0]); lon = Double.parseDouble(loc[1]); } catch (Exception ex) { System.err.println(ex.getMessage()); } double[] coordinates = new double[2]; coordinates[0] = lat; coordinates[1] = lon; return coordinates; }</code><technical_language>finally</technical_language>

Target:
public static double[] findCoordinatesByIp() throws LocationException { double lat; double lon; try { URL geoIpUrl = new URL("<LINK_0>"); URLConnection conn = geoIpUrl.openConnection(); try (ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_BYTE_STREAM)) { org.apache.commons.io.IOUtils.copy(conn.getInputStream(), output); output.close(); String result = output.toString(); twitter4j.JSONObject myGeoLocation = new twitter4j.JSONObject(result); String[] loc = myGeoLocation.getString("loc").split(","); lat = Double.parseDouble(loc[0]); lon = Double.parseDouble(loc[1]); } catch (Exception ex) { throw new LocationException(ex.getMessage()); } } catch (Exception ex) { throw new LocationException(ex.getMessage()); } double[] coordinates = new double[]{lat, lon}; return coordinates; }
Source:
<code>protected boolean nextInner() throws IOException { <START> boolean more = false; <END> if (this.resultIt == null || !this.resultIt.hasNext()) { while (this.result.hasMoreRows()) { RowResultIterator nextRows = this.result.nextRows(); if (nextRows.hasNext()) { resultIt = nextRows; more = true; } } } else { more = true; } if (more) { RowResult next = resultIt.next(); key = ((KuduStore<K, T>) getDataStore()).extractKey(next); persistent = ((KuduStore<K, T>) getDataStore()).newInstance(next, getQuery().getFields()); } return more; }</code><technical_language>rename this variable is intuitive. Eg:- boolean hasMoreRows = false</technical_language>

Target:
protected boolean nextInner() throws IOException { boolean hasMoreRecords = false; if (this.resultIt == null || !this.resultIt.hasNext()) { while (this.result.hasMoreRows()) { RowResultIterator nextRows = this.result.nextRows(); if (nextRows.hasNext()) { resultIt = nextRows; hasMoreRecords = true; } } } else { hasMoreRecords = true; } if (hasMoreRecords) { RowResult next = resultIt.next(); key = ((KuduStore<K, T>) getDataStore()).extractKey(next); persistent = ((KuduStore<K, T>) getDataStore()).newInstance(next, getQuery().getFields()); } return hasMoreRecords; }
Source:
<code>public static MutableCTreeNetwork expand(MutableCTreeNetwork tree, MutableCTreeNetwork subTree) { Optional parent = tree.predecessor(subTree); Object parentEdge = parent.isPresent() ? Iterables.getOnlyElement(tree.inEdges(subTree)) : null; <START> tree.removeNode(subTree); <END> if (!subTree.root().isPresent()) { return tree; } if (parent.isPresent()) { TreeUtils.addSubTree(tree, subTree, parent.get(), parentEdge); return tree; } else { return subTree; } }</code><technical_language>this moved check for subtree root is present</technical_language>

Target:
public static MutableCTreeNetwork expand(MutableCTreeNetwork tree, MutableCTreeNetwork subTree) { Optional parent = tree.predecessor(subTree); Object parentEdge = parent.isPresent() ? Iterables.getOnlyElement(tree.inEdges(subTree)) : null; if (!subTree.root().isPresent()) { return tree; } tree.removeNode(subTree); if (parent.isPresent()) { TreeUtils.addSubTree(tree, subTree, parent.get(), parentEdge); return tree; } else { return subTree; } }
Source:
<code>ModularInputKindArgument(Map<String,String> template) { super(); for (String key : template.keySet()) { <START> put(key, template.get(key)); <END> } }</code><technical_language>Is InsertAll Merge in Java</technical_language>

Target:
ModularInputKindArgument(Map<String,String> template) { super(); putAll(template); }
Source:
<code>public static JSONObject convert(ImmutableGraph<?, ?> graph) { final JSONObject jsonGraph = new JSONObject(); final JSONArray jsonEdgesArray = new JSONArray(); final JSONArray jsonVerticesArray = new JSONArray(); jsonGraph.put("edges", jsonEdgesArray); jsonGraph.put("vertices", jsonVerticesArray); if (graph != null) { graph.asGenericGraph().getProperties().forEach((key, value) -> jsonGraph.put(key, value)); graph.getEdges().stream().forEach(edge -> { final GenericEdge genericEdge = edge.asGenericEdge(); final Map<String, Object> edgeProperties = new HashMap<>(genericEdge.getProperties()); edgeProperties.put("source", genericEdge.getSource().getId()); edgeProperties.put("target", genericEdge.getTarget().getId()); final JSONObject jsonEdge = new JSONObject(edgeProperties); jsonEdgesArray.put(jsonEdge); }); graph.getVertices().stream().forEach(vertex -> { final JSONObject jsonVertex = new JSONObject(vertex.asGenericVertex().getProperties()); jsonVerticesArray.put(jsonVertex); }); final Focus defaultFocus = graph.getDefaultFocus(); final JSONObject jsonFocus = new JSONObject(); jsonFocus.put("type", defaultFocus.getId()); jsonFocus.put("vertexIds", new JSONArray(defaultFocus.getVertexRefs())); <START> jsonGraph.put("defaultFocus", jsonFocus); <END> } return jsonGraph; }</code><technical_language>I if need a similar converter mechanism for serializing database: <LINK_0></technical_language>

Target:
public static JSONObject convert(ImmutableGraph<?, ?> graph) { final JSONObject jsonGraph = new JSONObject(); final JSONArray jsonEdgesArray = new JSONArray(); final JSONArray jsonVerticesArray = new JSONArray(); jsonGraph.put("edges", jsonEdgesArray); jsonGraph.put("vertices", jsonVerticesArray); if (graph != null) { graph.asGenericGraph().getProperties().forEach((key, value) -> jsonGraph.put(key, value)); graph.getEdges().stream() .sorted(Comparator.comparing(Edge::getId)) .forEach(edge -> { final GenericEdge genericEdge = edge.asGenericEdge(); final Map<String, Object> edgeProperties = new HashMap<>(genericEdge.getProperties()); edgeProperties.put("source", genericEdge.getSource().getId()); edgeProperties.put("target", genericEdge.getTarget().getId()); final JSONObject jsonEdge = new JSONObject(edgeProperties); jsonEdgesArray.put(jsonEdge); }); graph.getVertices().stream() .sorted(Comparator.comparing(Vertex::getId)) .forEach(vertex -> { final JSONObject jsonVertex = new JSONObject(vertex.asGenericVertex().getProperties()); jsonVerticesArray.put(jsonVertex); }); final Focus defaultFocus = graph.getDefaultFocus(); final JSONObject jsonFocus = new JSONObject(); jsonFocus.put("type", defaultFocus.getId()); jsonFocus.put("vertexIds", new JSONArray(defaultFocus.getVertexRefs())); jsonGraph.put("defaultFocus", jsonFocus); } return jsonGraph; }
Source:
<code>@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setIncludeEventTypes(EventType.EVTS_ALL); if (indexingDisabled) { GridQueryProcessor.idxCls = DummyQueryIndexing.class; <START> cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi() { <END> @Override protected void register(SystemView<?> sysView) { } }); } return cfg; }</code><technical_language>fix SqlViewExporterSpi instead of excluding (looks a bug in implementation)</technical_language>

Target:
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setIncludeEventTypes(EventType.EVTS_ALL); if (indexingDisabled) GridQueryProcessor.idxCls = DummyQueryIndexing.class; return cfg; }
Source:
<code>public void update() throws APIException { <START> Map<String, Object> body = new HashMap<String, Object>() {{ <END> put("name", name); }}; APIFileSet fileSet = postResource(selfURI, body, APIFileSet.class); clone(fileSet); }</code><technical_language>Collections.singletonMap</technical_language>

Target:
public void update() throws APIException { APIFileSet fileSet = postResource(selfURI, Collections.singletonMap("name", name), APIFileSet.class); clone(fileSet); }
Source:
<code>public void commitDropTable(Table table, boolean deleteData) throws MetaException { String dataSourceName = Preconditions .checkNotNull(table.getParameters().get(Constants.DRUID_DATA_SOURCE), <START> "WTF dataSource name is null !" <END> ); if (deleteData == true) { LOG.info(String.format("Dropping with purge all the data for data source [%s]", dataSourceName )); List<DataSegment> dataSegmentList = DruidStorageHandlerUtils .getDataSegment(connector, druidMetadataStorageTablesConfig, dataSourceName); if (dataSegmentList.isEmpty()) { LOG.info(String.format("Nothing to delete for data source [%s]", dataSourceName)); return; } for (DataSegment dataSegment : dataSegmentList) { try { deleteSegment(dataSegment); } catch (SegmentLoadingException e) { LOG.error(String.format("Error while deleting segment [%s]", dataSegment.getIdentifier()), e ); } } } if (DruidStorageHandlerUtils .disableDataSource(connector, druidMetadataStorageTablesConfig, dataSourceName)) { LOG.info(String.format("Successfully dropped druid data source [%s]", dataSourceName)); } }</code><technical_language>need for offensive language :)</technical_language>

Target:
public void commitDropTable(Table table, boolean deleteData) throws MetaException { if (MetaStoreUtils.isExternalTable(table)) { return; } String dataSourceName = Preconditions .checkNotNull(table.getParameters().get(Constants.DRUID_DATA_SOURCE), "DataSource name is null !" ); if (deleteData == true) { LOG.info(String.format("Dropping with purge all the data for data source [%s]", dataSourceName )); List<DataSegment> dataSegmentList = DruidStorageHandlerUtils .getDataSegmentList(connector, druidMetadataStorageTablesConfig, dataSourceName); if (dataSegmentList.isEmpty()) { LOG.info(String.format("Nothing to delete for data source [%s]", dataSourceName)); return; } for (DataSegment dataSegment : dataSegmentList) { try { deleteSegment(dataSegment); } catch (SegmentLoadingException e) { LOG.error(String.format("Error while deleting segment [%s]", dataSegment.getIdentifier()), e ); } } } if (DruidStorageHandlerUtils .disableDataSource(connector, druidMetadataStorageTablesConfig, dataSourceName)) { LOG.info(String.format("Successfully dropped druid data source [%s]", dataSourceName)); } }
Source:
<code>public AzureLeaderElector(LeaseBlobManager leaseBlobManager) { this.isLeader = new AtomicBoolean(false); <START> this.leaseBlobManager = leaseBlobManager; <END> this.isLeader = new AtomicBoolean(false); this.leaseId = new AtomicReference<>(null); }</code><technical_language>add nonNull precondition guard for leaseBlobManager here</technical_language>

Target:
public AzureLeaderElector(LeaseBlobManager leaseBlobManager) { this.isLeader = new AtomicBoolean(false); this.leaseBlobManager = leaseBlobManager; this.leaseId = new AtomicReference<>(null); }
Source:
<code>protected PlanNodeStatsEstimate visitComparisonExpression(ComparisonExpression node, Void context) { ComparisonExpressionType type = node.getType(); Expression left = node.getLeft(); Expression right = node.getRight(); if (!(left instanceof SymbolReference) && right instanceof SymbolReference) { return process(new ComparisonExpression(type.flip(), right, left)); } if (left instanceof Literal && !(right instanceof Literal)) { return process(new ComparisonExpression(type.flip(), right, left)); } if (right instanceof Literal) { Optional<Symbol> symbol = asSymbol(left); SymbolStatsEstimate leftStats = getSymbolStatsEstimate(left); <START> OptionalDouble literal = doubleValueFromLiteral(getType(left), (Literal) right); <END> return comparisonExpressionToLiteralStats(input, symbol, leftStats, literal, type); } if (right instanceof SymbolReference) { return comparisonSymbolToSymbolStats(input, Symbol.from(left), Symbol.from(right), type); } return filterStatsForUnknownExpression(input); }</code><technical_language>care of casts</technical_language>

Target:
protected PlanNodeStatsEstimate visitComparisonExpression(ComparisonExpression node, Void context) { ComparisonExpressionType type = node.getType(); Expression left = node.getLeft(); Expression right = node.getRight(); checkArgument(!(left instanceof Literal && right instanceof Literal), "Literal-to-literal not supported here, should be eliminated earlier"); if (!(left instanceof SymbolReference) && right instanceof SymbolReference) { return process(new ComparisonExpression(type.flip(), right, left)); } if (left instanceof Literal && !(right instanceof Literal)) { return process(new ComparisonExpression(type.flip(), right, left)); } Optional<Symbol> leftSymbol = asSymbol(left); SymbolStatsEstimate leftStats = getExpressionStats(left); if (right instanceof Literal) { OptionalDouble literal = doubleValueFromLiteral(getType(left), (Literal) right); return comparisonExpressionToLiteralStats(input, leftSymbol, leftStats, literal, type); } Optional<Symbol> rightSymbol = asSymbol(right); SymbolStatsEstimate rightStats = getExpressionStats(right); if (isSingleValue(rightStats)) { OptionalDouble value = isNaN(rightStats.getLowValue()) ? OptionalDouble.empty() : OptionalDouble.of(rightStats.getLowValue()); return comparisonExpressionToLiteralStats(input, leftSymbol, leftStats, value, type); } return comparisonExpressionToExpressionStats(input, leftSymbol, leftStats, rightSymbol, rightStats, type); }
Source:
<code>public void handleUnimprovedHoursSpentInputChange( ChangeEvent event ) { try { Long value = unimprovedHoursSpentInput.getValue().isEmpty() ? null : Long.parseLong( unimprovedHoursSpentInput.getValue() ); presenter.onUnimprovedHoursSpentChange( value ); } catch ( NumberFormatException e ) { <START> <END> } }</code><technical_language>Likewise.</technical_language>

Target:
public void handleUnimprovedHoursSpentInputChange( ChangeEvent event ) { boolean isNumeric = unimprovedHoursSpentInput.getValue().matches( "\\d+" ); if (isNumeric) { presenter.onUnimprovedHoursSpentChange( Long.parseLong( unimprovedHoursSpentInput.getValue() ) ); } else { presenter.onUnimprovedHoursSpentChange( 0l ); unimprovedHoursSpentInput.setValue( "0" ); } }
Source:
<code>public CapabilityList findAll() { List<Capability> capabilities = Lists.newArrayList(); <START> for (Map.Entry<Integer, Capability> entry : values.entrySet()) { <END> capabilities.add(entry.getValue()); } return new CapabilityList(capabilities); }</code><technical_language>is this stupid iteration? map.values() ?|?|?|</technical_language>

Target:
public CapabilityList findAll() { List<Capability> capabilities = Lists.newArrayList(this.capabilities.values()); return new CapabilityList(capabilities); }
Source:
<code>public List<ReplicaId> getReplicaIdsByState(ReplicaState state, String dcName) { List<ReplicaId> result = new ArrayList<>(); <START> if (state.equals(ReplicaState.STANDBY.name())) { <END> for (ReplicaId replicaId : replicas) { if (dcName == null || replicaId.getDataNodeId().getDatacenterName().equals(dcName)) { result.add(replicaId); } } } return result; }</code><technical_language>Change state == ReplicaState.STANDBY</technical_language>

Target:
public List<ReplicaId> getReplicaIdsByState(ReplicaState state, String dcName) { List<ReplicaId> result = new ArrayList<>(); if (state == ReplicaState.STANDBY) { result = replicas.stream() .filter(k -> dcName == null || k.getDataNodeId().getDatacenterName().equals(dcName)) .collect(Collectors.toList()); } return Collections.unmodifiableList(result); }
Source:
<code>public TypeVariableName withBounds(Type... bounds) { <START> return get(name, bounds); <END> }</code><technical_language>This loses existing bounds annotations. I want combine annotated does</technical_language>

Target:
public TypeVariableName withBounds(Type... bounds) { return withBounds(TypeName.list(bounds)); }
Source:
<code>public void testProjectWithNoTags() throws CoreException { IProject project = createProject("Project_1", (String) null); List knownTags = Arrays.asList(repositoryManager .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(project))); assertTrue(knownTags.isEmpty()); <START> repositoryManager.refreshDefinedTags( <END> CVSWorkspaceRoot.getCVSFolderFor(project), true, true, DEFAULT_MONITOR); assertTrue(knownTags.isEmpty()); }</code><technical_language>I reckon extracting this 3 lines a private method save some space in test</technical_language>

Target:
public void testProjectWithNoTags() throws CoreException { IProject project = createProject("Project_1", (String) null); CVSTag knownTags[] = repositoryManager.getKnownTags(CVSWorkspaceRoot .getCVSFolderFor(project)); assertEquals(0, knownTags.length); knownTags = refreshTags(project); assertEquals(0, knownTags.length); }
Source:
<code>public static Optional<Path> getFastpassPath(Project project) { Optional<Path> root = PantsUtil.findPantsExecutable(project).map(VirtualFile::getParent).map(r -> Paths.get(r.getCanonicalPath())); if(!root.isPresent()){ throw new PantsException("Not a pants project"); } <START> return root.map(r -> r.resolve("fastpass/bin/fastpass")); <END> }</code><technical_language>if fastpass/bin/fastpass exist? For instance, if I this plugin in other repo? return empty optional if file exist</technical_language>

Target:
public static Optional<Path> getFastpassPath(Project project) { Optional<Path> root = PantsUtil.findPantsExecutable(project).map(VirtualFile::getParent).map(r -> Paths.get(r.getCanonicalPath())); if(!root.isPresent()){ throw new PantsException("Not a Pants project"); } Optional<Path> fastpassPath = root.map(r -> r.resolve("fastpass/bin/fastpass")); if(fastpassPath.map(p -> p.toFile().exists()).orElse(false)){ return fastpassPath; } else { return Optional.empty(); } }
Source:
<code>private void editQuestion(FeedbackQuestionAttributes updatedQuestion) throws InvalidParametersException, EntityDoesNotExistException { String err = validateQuestionGiverRecipientVisibility(updatedQuestion); if (!err.isEmpty()) { statusToUser.add(new StatusMessage(err, StatusMessageColor.DANGER)); isError = true; } <START> String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); <END> FeedbackQuestionDetails updatedQuestionDetails = updatedQuestion.getQuestionDetails(); List<String> questionDetailsErrors = updatedQuestionDetails.validateQuestionDetails(courseId); List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>(); for (String error : questionDetailsErrors) { questionDetailsErrorsMessages.add(new StatusMessage(error, StatusMessageColor.DANGER)); } if (questionDetailsErrors.isEmpty()) { logic.updateFeedbackQuestionNumber(updatedQuestion); statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, StatusMessageColor.SUCCESS)); statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> edited.<br>" + "<span class=\"bold\">" + updatedQuestionDetails.getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(updatedQuestionDetails.getQuestionText()); } else { statusToUser.addAll(questionDetailsErrorsMessages); isError = true; } }</code><technical_language>getNonNullRequestParamValue</technical_language>

Target:
private void editQuestion(FeedbackQuestionAttributes updatedQuestion) throws InvalidParametersException, EntityDoesNotExistException { String err = validateQuestionGiverRecipientVisibility(updatedQuestion); if (!err.isEmpty()) { statusToUser.add(new StatusMessage(err, StatusMessageColor.DANGER)); isError = true; } String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); FeedbackQuestionDetails updatedQuestionDetails = updatedQuestion.getQuestionDetails(); List<String> questionDetailsErrors = updatedQuestionDetails.validateQuestionDetails(courseId); List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>(); for (String error : questionDetailsErrors) { questionDetailsErrorsMessages.add(new StatusMessage(error, StatusMessageColor.DANGER)); } if (questionDetailsErrors.isEmpty()) { logic.updateFeedbackQuestionNumber(updatedQuestion); statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, StatusMessageColor.SUCCESS)); statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> edited.<br>" + "<span class=\"bold\">" + updatedQuestionDetails.getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(updatedQuestionDetails.getQuestionText()); } else { statusToUser.addAll(questionDetailsErrorsMessages); isError = true; } }
Source:
<code>public void onTextSelected(ActionMode mode) { webViewActionMode = mode; Menu menu = mode.getMenu(); menu.findItem(getSystemMenuItemByName(menu, "select_all").getItemId()).setVisible(false); <START> menu.findItem(getSystemMenuItemByName(menu, "web_search").getItemId()).setVisible(false); <END> MenuItem shareItem = getSystemMenuItemByName(menu, "share"); if (shareItem == null) { shareItem = mode.getMenu().add(Menu.NONE, Menu.NONE, Menu.NONE, activity.getString(R.string.menu_share_page)); shareItem.setIcon(R.drawable.ic_share_dark); MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } if (WikipediaApp.getInstance().isFeatureSelectTextAndShareTutorialEnabled() && WikipediaApp.getInstance().getOnboardingStateMachine().isShareTutorialEnabled()) { showShareOnboarding(shareItem); WikipediaApp.getInstance().getOnboardingStateMachine().setShareTutorial(); } shareItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { requestTextSelection(); if (webViewActionMode != null) { webViewActionMode.finish(); webViewActionMode = null; } return true; } }); createFunnel(); funnel.logHighlight(); }</code><technical_language>1) getSystemMenuItemByName() function returns MenuItem call setVisible(). call findItem() again. 2) getSystemMenuItemByName() return null. Some older API versions support discovery of menu items name. So, need check for null calling setVisible()</technical_language>

Target:
public void onTextSelected(ActionMode mode) { webViewActionMode = mode; Menu menu = mode.getMenu(); hideSystemMenuItems(menu, "select_all", "web_search"); MenuItem shareItem = getSystemMenuItemByName(menu, "share"); if (shareItem == null) { shareItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, activity.getString(R.string.menu_share_page)); shareItem.setIcon(R.drawable.ic_share_dark); MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } if (WikipediaApp.getInstance().isFeatureSelectTextAndShareTutorialEnabled() && WikipediaApp.getInstance().getOnboardingStateMachine().isShareTutorialEnabled()) { showShareOnboarding(shareItem); WikipediaApp.getInstance().getOnboardingStateMachine().setShareTutorial(); } shareItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { requestTextSelection(); if (webViewActionMode != null) { webViewActionMode.finish(); webViewActionMode = null; } return true; } }); createFunnel(); funnel.logHighlight(); }
Source:
<code>public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException { SCM scm = getScm(); if(scm==null) return true; FilePath workspace = build.getWorkspace(); if(workspace!=null){ workspace.mkdirs(); } else{ <START> return true; <END> } boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile); if (r) { calcPollingBaseline(build, launcher, listener); } return r; }</code><technical_language>Sounds error suppression. please explain this change a bit</technical_language>

Target:
public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException { SCM scm = getScm(); if(scm==null) return true; FilePath workspace = build.getWorkspace(); if(workspace!=null){ workspace.mkdirs(); } else { throw new AbortException("Cannot checkout SCM, workspace is not defined"); } boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile); if (r) { calcPollingBaseline(build, launcher, listener); } return r; }
Source:
<code><START> Map<SectionMatcher, Project.NameKey> getAllSections() { <END> Map<SectionMatcher, Project.NameKey> all = Maps.newLinkedHashMap(); Project.NameKey p = getProject().getNameKey(); if (isAllProjects) { for (SectionMatcher m : getLocalAccessSections()) { all.put(m, p); } return all; } for (ProjectState s : tree()) { for (SectionMatcher m : s.getLocalAccessSections()) { all.put(m, s.getProject().getNameKey()); } } return all; }</code><technical_language>FWIW put Project.NameKey a SectionMatcher. internal hidden implementation detail of server. This clean some of Map usage code a bit more clear in PermissionCollection</technical_language>

Target:
List<SectionMatcher> getAllSections() { if (isAllProjects) { return getLocalAccessSections(); } List<SectionMatcher> all = Lists.newArrayList(); for (ProjectState s : tree()) { all.addAll(s.getLocalAccessSections()); } return all; }
Source:
<code>public void testIncludeExcludePatternNoConflict() throws IOException { ReliableEventReader reader = new ReliableSpoolingFileEventReader.Builder() .spoolDirectory(WORK_DIR) .ignorePattern("^file[013]$") .includePattern("^file2$") .deletePolicy(DeletePolicy.IMMEDIATE.toString()) .build(); List<File> before = listFiles(WORK_DIR); Assert.assertEquals("Expected 5, not: " + before, 5, before.size()); List<Event> events; do { events = reader.readEvents(10); reader.commit(); } while (!events.isEmpty()); List<File> after = listFiles(WORK_DIR); Assert.assertEquals("Expected 4, not: " + after, 4, after.size()); <START> Set<String> expectedLeftFiles = new HashSet<String>( <END> Arrays.asList("file0", "file1", "file3", "emptylineFile")); for (File f: after) { expectedLeftFiles.remove(f.getName()); } Assert.assertTrue("Unexpected files were sent", expectedLeftFiles.isEmpty()); List<File> trackerFiles = listFiles(new File(WORK_DIR, SpoolDirectorySourceConfigurationConstants.DEFAULT_TRACKER_DIR)); Assert.assertEquals("Expected 0, not: " + trackerFiles, 0, trackerFiles.size()); }</code><technical_language>Wrong indentation, in line Assert above. Note: 2 spaces for indentation. verify code conforms Flume's code formatting guidelines running checkstyle it: mvn clean verify -DskipTests -Drat.skip, please run it, a couple of other warnings too</technical_language>

Target:
public void testIncludeExcludePatternNoConflict() throws IOException { ReliableEventReader reader = new ReliableSpoolingFileEventReader.Builder() .spoolDirectory(WORK_DIR) .ignorePattern("^file[013]$") .includePattern("^file2$") .deletePolicy(DeletePolicy.IMMEDIATE.toString()) .build(); String[] beforeFiles = { "file0", "file1", "file2", "file3", "emptylineFile" }; Assert.assertTrue("Expected " + beforeFiles.length + " files in working dir", checkLeftFilesInDir(WORK_DIR, beforeFiles)); processEventsWithReader(reader, 10); String[] files = { "file0", "file1", "file3", "emptylineFile" }; Assert.assertTrue("Expected " + files.length + " files left in working dir", checkLeftFilesInDir(WORK_DIR, files)); Assert.assertTrue("Expected no files left in tracker dir", checkLeftFilesInDir(TRACKER_DIR, new String[0])); }
Source:
<code>public void dispose() { disposed = true; if(sourceDocument != null && documentListener != null) { sourceDocument.removeDocumentListener(documentListener); sourceDocument = null; documentListener = null; } if(sourcePage != null) { <START> Object outlinePage = sourcePage.getAdapter(IContentOutlinePage.class); <END> if(outlinePage instanceof ConfigurableContentOutlinePage) { ((ConfigurableContentOutlinePage) outlinePage).setEditorPart(null); } } MavenPluginActivator.getDefault().getMavenProjectManager().removeMavenProjectChangedListener(this); if(structuredModel != null) { structuredModel.releaseFromEdit(); } if(activationListener != null) { activationListener.dispose(); activationListener = null; } ResourcesPlugin.getWorkspace().removeResourceChangeListener(MavenPomEditor.this); super.dispose(); }</code><technical_language>this block added MavenStructuredPomEditorPageFactory</technical_language>

Target:
public void dispose() { disposed = true; if(sourceDocument != null && documentListener != null) { sourceDocument.removeDocumentListener(documentListener); sourceDocument = null; documentListener = null; } MavenPluginActivator.getDefault().getMavenProjectManager().removeMavenProjectChangedListener(this); if(structuredModel != null) { structuredModel.releaseFromEdit(); } if(activationListener != null) { activationListener.dispose(); activationListener = null; } ResourcesPlugin.getWorkspace().removeResourceChangeListener(MavenPomEditor.this); super.dispose(); }
Source:
<code>public ArticlePage navigateToCategoryMemberPage() { WebElement member = driver.findElement(categoryMembers); String memberName = member.getText(); <START> wait.forXMilliseconds(1500); <END> wait.forElementClickable(member); member.click(); new Loading(driver).handleAsyncPageReload(); PageObjectLogging.logInfo(String.format("You were redirected to page: \"%s\".", memberName)); return new ArticlePage(); }</code><technical_language>this for? new CategoryPage().open(categoryName) page is ready tested? Also, query DOM waiting, 1500 ms</technical_language>

Target:
public ArticlePage navigateToCategoryMemberPage() { new SkinHelper(driver).isSkin(Skin.MERCURY); WebElement member = driver.findElement(categoryMembers); String memberName = member.getText(); wait.forElementClickable(member); member.click(); new Loading(driver).handleAsyncPageReload(); PageObjectLogging.logInfo(String.format("You were redirected to page: \"%s\".", memberName)); new SkinHelper(driver).isSkin(Skin.MERCURY); return new ArticlePage(); }
Source:
<code><START> private SqlMap<InMemoryTableElement<InMemoryEdge>> newEdgeMap() { <END> return new SqlMap<InMemoryTableElement<InMemoryEdge>>( tableNameWithPrefix(EDGE_TABLE_NAME), KEY_COLUMN_NAME, VALUE_COLUMN_NAME, dataSource, serializer) { @Override protected Map<String, Object> additionalColumns(String key, InMemoryTableElement<InMemoryEdge> value) { SqlTableEdge edge = (SqlTableEdge) value; Map<String, Object> columns = new HashMap<>(); columns.put(IN_VERTEX_ID_COLUMN, edge.inVertexId()); columns.put(OUT_VERTEX_ID_COLUMN, edge.outVertexId()); return columns; } }; }</code><technical_language>This odd place for methods. in SqlGraph</technical_language>

Target:
protected SqlMap<InMemoryTableElement<InMemoryEdge>> newEdgeMap() { return new SqlMap<InMemoryTableElement<InMemoryEdge>>( tableNameWithPrefix(EDGE_TABLE_NAME), KEY_COLUMN_NAME, VALUE_COLUMN_NAME, dataSource, serializer) { @Override protected Map<String, Object> additionalColumns(String key, InMemoryTableElement<InMemoryEdge> value) { SqlTableEdge edge = (SqlTableEdge) value; Map<String, Object> columns = new HashMap<>(); columns.put(IN_VERTEX_ID_COLUMN, edge.inVertexId()); columns.put(OUT_VERTEX_ID_COLUMN, edge.outVertexId()); return columns; } }; }
Source:
<code>public void initializeGeneralConfigs () { GeneralConfig generalConfig = generalConfigRepository.getGeneralConfigByName("log.level"); <START> setLogLevel(generalConfig.getValue()); <END> }</code><technical_language>Again, static import this harder read</technical_language>

Target:
public void initializeGeneralConfigs () { GeneralConfig generalConfig = generalConfigRepository.getGeneralConfigByName("log.level"); LoggerUtil.setLogLevel(generalConfig.getValue()); }
Source:
<code>public Map<Import, String> getImportXML(final Metadata metadata, final List<Import> imports) { final Map<Import, String> importXML = new HashMap<>(); if (imports.size() > 0) { for (final String xml : getOtherDMNDiagramsXML(metadata)) { <START> try (StringReader sr = toStringReader(xml)) { <END> final Definitions definitions = marshaller.unmarshal(sr); findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importXML.put(anImport, xml); }); } } } return importXML; }</code><technical_language>please final StringReader sr</technical_language>

Target:
public Map<Import, String> getImportXML(final Metadata metadata, final List<Import> imports) { final Map<Import, String> importXML = new HashMap<>(); if (imports.size() > 0) { for (final String xml : getOtherDMNDiagramsXML(metadata)) { try (final StringReader sr = toStringReader(xml)) { final Definitions definitions = marshaller.unmarshal(sr); findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importXML.put(anImport, xml); }); } } } return importXML; }
Source:
<code>public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(String clientRegistrationId, String principalName) { Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty"); Assert.hasText(principalName, "principalName cannot be empty"); Object[] args = {clientRegistrationId, principalName}; int[] argTypes = {Types.VARCHAR, Types.VARCHAR}; PreparedStatementSetter pss = new ArgumentTypePreparedStatementSetter(args, argTypes); List<OAuth2AuthorizedClientData> result = this.jdbcOperations.query( LOAD_AUTHORIZED_CLIENT_SQL, pss, this.authorizedClientDataRowMapper); <START> return !result.isEmpty() ? (T) this.authorizedClientDataConverter.convert(result.get(0)) : null; <END> }</code><technical_language>for 0 1 results, queryForObject more sense here</technical_language>

Target:
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(String clientRegistrationId, String principalName) { Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty"); Assert.hasText(principalName, "principalName cannot be empty"); SqlParameterValue[] parameters = new SqlParameterValue[] { new SqlParameterValue(Types.VARCHAR, clientRegistrationId), new SqlParameterValue(Types.VARCHAR, principalName) }; PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters); List<OAuth2AuthorizedClient> result = this.jdbcOperations.query( LOAD_AUTHORIZED_CLIENT_SQL, pss, this.authorizedClientRowMapper); return !result.isEmpty() ? (T) result.get(0) : null; }
Source:
<code>public int hashCode() { <START> return 42; <END> }</code><technical_language>Objects.hashCode()</technical_language>

Target:
public int hashCode() { return Objects.hashCode(mPath); }
Source:
<code><START> protected boolean isHotPlugSupported() { <END> if (Config.<Boolean> GetValue(ConfigValues.HotPlugEnabled, getVds().getVdsGroupCompatibilityVersion() .getValue())) { return true; } addCanDoActionMessage(VdcBllMessages.HOT_PLUG_IS_NOT_SUPPORTED); return false; }</code><technical_language>this method replaced FeatureSupported.hotPlug(Version) performs same</technical_language>

Target:
protected boolean isHotPlugSupported() { if (FeatureSupported.hotPlug(getVds().getVdsGroupCompatibilityVersion())) { return true; } addCanDoActionMessage(VdcBllMessages.HOT_PLUG_IS_NOT_SUPPORTED); return false; }
Source:
<code>public void selectByValue(String value) { Optional<WebElement> matchingButton = getButtons().stream() <START> .filter(b -> b.getAttribute("value").equals(value)) <END> .findFirst(); selectButton(matchingButton .orElseThrow(() -> new NoSuchElementException( "Cannot locate radio button with value: " + value))); }</code><technical_language>NPE safe (order changed) value.equals(buttonValue) precondition check, StringUtils.equals(value, btnVal) if commons-lang3 in classpath</technical_language>

Target:
public void selectByValue(String value) { Optional<WebElement> matchingButton = getButtons().stream() .filter(b -> value.equals(b.getAttribute("value"))) .findFirst(); selectButton(matchingButton .orElseThrow(() -> new NoSuchElementException( String.format("Cannot locate radio button with value: %s", value)))); }
Source:
<code>static void encodeCubes(PacketBuffer out, Collection<Cube> cubes) { cubes.forEach(cube -> { out.writeBoolean(cube.isEmpty()); out.writeBoolean(cube.getStorage() != null); <START> out.writeBoolean(cube.getBiomeArray() != null); <END> }); cubes.forEach(cube -> { if (!cube.isEmpty()) { cube.getStorage().getData().write(out); } }); cubes.forEach(cube -> { if (cube.getStorage() != null) { out.writeBytes(cube.getStorage().getBlockLight().getData()); } }); cubes.forEach(cube -> { if (cube.getStorage() != null && cube.getWorld().provider.hasSkyLight()) { out.writeBytes(cube.getStorage().getSkyLight().getData()); } }); cubes.forEach(cube -> { if (!cube.isEmpty()) { byte[] heightmaps = ((ServerHeightMap) cube.getColumn().getOpacityIndex()).getDataForClient(); assert heightmaps.length == Cube.SIZE * Cube.SIZE * Integer.BYTES; out.writeBytes(heightmaps); } }); cubes.forEach(cube -> { if (cube.getBiomeArray() != null) out.writeBytes(cube.getBiomeArray()); }); }</code><technical_language>This is network-incompatible change. network-compatible, set right required remote versions. test non-dev builds, join older client, join older server</technical_language>

Target:
static void encodeCubes(PacketBuffer out, Collection<Cube> cubes) { cubes.forEach(cube -> { byte flags = 0; if(cube.isEmpty()) flags |= 1; if(cube.getStorage() != null) flags |= 2; if(cube.getBiomeArray() != null) flags |= 4; out.writeByte(flags); }); cubes.forEach(cube -> { if (!cube.isEmpty()) { cube.getStorage().getData().write(out); } }); cubes.forEach(cube -> { if (cube.getStorage() != null) { out.writeBytes(cube.getStorage().getBlockLight().getData()); } }); cubes.forEach(cube -> { if (cube.getStorage() != null && cube.getWorld().provider.hasSkyLight()) { out.writeBytes(cube.getStorage().getSkyLight().getData()); } }); cubes.forEach(cube -> { if (!cube.isEmpty()) { byte[] heightmaps = ((ServerHeightMap) cube.getColumn().getOpacityIndex()).getDataForClient(); assert heightmaps.length == Cube.SIZE * Cube.SIZE * Integer.BYTES; out.writeBytes(heightmaps); } }); cubes.forEach(cube -> { if (cube.getBiomeArray() != null) out.writeBytes(cube.getBiomeArray()); }); }
Source:
<code>protected final AuditMessageType getParticipantObjectIdentificationForRequest(T request, AssertionType assertion, AuditMessageType auditMsg) { ParticipantObjectIdentificationType participantObject = buildBaseParticipantObjectIdentificationType(getPayloadFromRequest(request)); <START> byte[] baos = marshallToByteArrayFromRequest(request); <END> TypeValuePairType oType = getTypeValuePairType(baos); participantObject.getParticipantObjectDetail().add(oType); auditMsg.getParticipantObjectIdentification().add(participantObject); return auditMsg; }</code><technical_language>need change for this PR, for future, baos is typically a name for a ByteArrayOutputStream, a byte[]</technical_language>

Target:
protected final AuditMessageType getParticipantObjectIdentificationForRequest(T request, AssertionType assertion, AuditMessageType auditMsg) { ParticipantObjectIdentificationType participantObject = buildBaseParticipantObjectIdentificationType(getPayloadFromRequest(request)); byte[] bArray = marshallToByteArrayFromRequest(request); TypeValuePairType oType = getTypeValuePairType(bArray); participantObject.getParticipantObjectDetail().add(oType); auditMsg.getParticipantObjectIdentification().add(participantObject); return auditMsg; }
Source:
<code>public DeploymentGroup getDeploymentGroup(final String name) throws DeploymentGroupDoesNotExistException { log.debug("getting deployment-group: {}", name); <START> final ZooKeeperClient client = provider.get("getDeploymentGroupResponse"); <END> return getDeploymentGroup(client, name); }</code><technical_language>this for easier debugging, match method name</technical_language>

Target:
public DeploymentGroup getDeploymentGroup(final String name) throws DeploymentGroupDoesNotExistException { log.debug("getting deployment-group: {}", name); final ZooKeeperClient client = provider.get("getDeploymentGroup"); return getDeploymentGroup(client, name); }
Source:
<code>private RateLimiterRegistry createRateLimiterRegistry( RateLimiterConfigurationProperties rateLimiterConfigurationProperties, RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer, CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) { Map<String, RateLimiterConfig> configs = rateLimiterConfigurationProperties.getConfigs() .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> rateLimiterConfigurationProperties .createRateLimiterConfig(entry.getValue(), compositeRateLimiterCustomizer, entry.getKey()))); return RateLimiterRegistry.of(configs, rateLimiterRegistryEventConsumer, <START> rateLimiterConfigurationProperties.getTags()); <END> }</code><technical_language>I create a defensive copy of Map</technical_language>

Target:
private RateLimiterRegistry createRateLimiterRegistry( RateLimiterConfigurationProperties rateLimiterConfigurationProperties, RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer, CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) { Map<String, RateLimiterConfig> configs = rateLimiterConfigurationProperties.getConfigs() .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> rateLimiterConfigurationProperties .createRateLimiterConfig(entry.getValue(), compositeRateLimiterCustomizer, entry.getKey()))); return RateLimiterRegistry.of(configs, rateLimiterRegistryEventConsumer, Map.copyOf(rateLimiterConfigurationProperties.getTags())); }
Source:
<code>public void returns_list_of_errors_in_the_order_they_were_asserted() { softly.assertThat(class1ForTesting).isClassy(); softly.assertThat(class2ForTesting).isNotClassy(); assertThat(softly.errorsCollected()).as("size").hasSize(2); assertThat(softly.errorsCollected().get(0)).as("0").hasMessage("Not classy"); <START> assertThat(softly.errorsCollected().get(1)).as("1").hasMessage("Classy"); <END> }</code><technical_language>add standard soft assertions mix</technical_language>

Target:
public void returns_list_of_errors_in_the_order_they_were_asserted() { softly.assertThat(class1ForTesting).isClassy(); softly.assertThat(class2ForTesting).isNotClassy(); softly.assertThat("String").isEqualTo("Strung"); List<Throwable> errorsCollected = softly.errorsCollected(); assertThat(errorsCollected).as("size").hasSize(3); assertThat(errorsCollected.get(0)).as("0").hasMessage("Not classy"); assertThat(errorsCollected.get(1)).as("1").hasMessage("Classy"); assertThat(errorsCollected.get(2)).as("2").hasMessageMatching("(?s).*String.*equal to.*Strung.*not.*"); assertThat(errorsCollected).isEqualTo(softly.assertionErrorsCollected()); }
Source:
<code>public boolean isHammingSimilar(ImmutableRoaringBitmap other, int tolerance) { final int size1 = highLowContainer.size(); final int size2 = other.highLowContainer.size(); int pos1 = 0; int pos2 = 0; int budget = tolerance; while(budget >= 0) { <START> short key1 = this.highLowContainer.getKeyAtIndex(pos1); <END> short key2 = other.highLowContainer.getKeyAtIndex(pos2); while(Util.compareUnsigned(key1, key2) < 0 && pos1 < size1) { budget -= highLowContainer.getContainerAtIndex(pos1).getCardinality(); key1 = highLowContainer.getKeyAtIndex(pos1++); } while(Util.compareUnsigned(key2, key1) < 0 && pos2 < size2) { budget -= other.highLowContainer.getContainerAtIndex(pos2).getCardinality(); key2 = other.highLowContainer.getKeyAtIndex(pos2++); } if(budget < 0) { return false; } if(pos1 == size1 || pos2 == size2) { break; } MappeableContainer left = highLowContainer.getContainerAtIndex(pos1++); MappeableContainer right = other.highLowContainer.getContainerAtIndex(pos2++); budget -= left.xorCardinality(right); } while(budget >= 0 && pos1 < size1) { MappeableContainer container = highLowContainer.getContainerAtIndex(pos1++); budget -= container.getCardinality(); } while(budget >= 0 && pos2 < size2) { MappeableContainer container = other.highLowContainer.getContainerAtIndex(pos2++); budget -= container.getCardinality(); } return budget >= 0; }</code><technical_language>rollback version. this a future improvement</technical_language>

Target:
public boolean isHammingSimilar(ImmutableRoaringBitmap other, int tolerance) { final int size1 = highLowContainer.size(); final int size2 = other.highLowContainer.size(); int pos1 = 0; int pos2 = 0; int budget = tolerance; while(budget >= 0 && pos1 < size1 && pos2 < size2) { final short key1 = highLowContainer.getKeyAtIndex(pos1); final short key2 = other.highLowContainer.getKeyAtIndex(pos2); MappeableContainer left = highLowContainer.getContainerAtIndex(pos1); MappeableContainer right = other.highLowContainer.getContainerAtIndex(pos2); if(key1 == key2) { budget -= left.xorCardinality(right); ++pos1; ++pos2; } else if(Util.compareUnsigned(key1, key2) < 0) { budget -= left.getCardinality(); ++pos1; } else { budget -= right.getCardinality(); ++pos2; } } while(budget >= 0 && pos1 < size1) { MappeableContainer container = highLowContainer.getContainerAtIndex(pos1++); budget -= container.getCardinality(); } while(budget >= 0 && pos2 < size2) { MappeableContainer container = other.highLowContainer.getContainerAtIndex(pos2++); budget -= container.getCardinality(); } return budget >= 0; }
Source:
<code>public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final Factory<? extends V> factory) { <START> if (factory == null) { <END> throw new NullPointerException("Factory must not be null"); } return new DefaultedMap<>(map, FactoryTransformer.factoryTransformer(factory)); }</code><technical_language>quite, NPE route, a liner Objects.requireNonNull()</technical_language>

Target:
public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final Factory<? extends V> factory) { return new DefaultedMap<>(map, FactoryTransformer.factoryTransformer( Objects.requireNonNull(factory, "Factory must not be null"))); }
Source:
<code>public void test_evalute_Cookies () { browser.setUrl("<LINK_0>"); <START> waitForMilliseconds(1000); <END> browser.evaluate("document.cookie = \"cookie1=value1\";"); browser.evaluate("document.cookie = \"cookie2=value2\";"); String res = (String) browser.evaluate("return document.cookie;"); assertTrue(!res.isEmpty()); }</code><technical_language>hard-coded wait tests slow. Is waitForPassCondition(() -> <Condition>) instead? (See snippets below). In general, wait for page load, wait for condition. reduce test speeds ~200ms</technical_language>

Target:
public void test_evalute_Cookies () { final AtomicBoolean loaded = new AtomicBoolean(false); browser.addProgressListener(ProgressListener.completedAdapter(event -> loaded.set(true))); browser.setUrl("<LINK_0>"); waitForPassCondition(() -> loaded.get()); browser.evaluate("document.cookie = \"cookie1=value1\";"); browser.evaluate("document.cookie = \"cookie2=value2\";"); String res = (String) browser.evaluate("return document.cookie;"); assertTrue(!res.isEmpty()); }