auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static boolean checkAclRight(List<OzoneAclInfo> acls, RequestContext context) throws OMException { String[] userGroups = context.getClientUgi().getGroupNames(); for (OzoneAclInfo a : acls) { BitSet rights = BitSet.valueOf(a.getRights().toByteArray()); switch (a.getType()) { case USER: <START> if (a.getName().equals(context.getClientUgi().getUserName())) { <END> return ((rights.get(context.getAclRights().ordinal()) || rights.get(ALL.ordinal())) && !rights.get(NONE.ordinal())); } break; case GROUP: for (String grp : userGroups) { if (a.getName().equals(grp)) { return ((rights.get(context.getAclRights().ordinal()) || rights.get(ALL.ordinal())) && !rights.get(NONE.ordinal())); } } break; default: throw new OMException("Unexpected type:" + a.getType(), INTERNAL_ERROR); } } return false; }</code><technical_language>move context.getClientUgi().getUserName() out of for loop</technical_language>

Target:
public static boolean checkAclRight(List<OzoneAclInfo> acls, RequestContext context) throws OMException { String[] userGroups = context.getClientUgi().getGroupNames(); String userName = context.getClientUgi().getUserName(); ACLType aclToCheck = context.getAclRights(); for (OzoneAclInfo a : acls) { if(checkAccessInAcl(a, userGroups, userName, aclToCheck)) { return true; } } return false; }
Source:
<code>public void waitForCopyEmailPopoverVisible() { String selector = "#copy-email-button + div.popover"; <START> waitForElementPresence(By.cssSelector(selector)); <END> }</code><technical_language>waitForElementVisibility instead waitForElementPresence checks if element is present in DOM, of is visible not</technical_language>

Target:
public void waitForCopyEmailPopoverVisible() { String cssSelector = "#copy-email-button + div.popover"; WebElement copyEmailPopover = browser.driver.findElement(By.cssSelector(cssSelector)); waitForElementVisibility(copyEmailPopover); }
Source:
<code>public Object aggregateArguments(ArgumentsAccessor accessor, ParameterContext context) { Map<String, Object> m = new HashMap<>(); IntStream.range(0, accessor.size()).forEach(i -> m.put(Integer.toString(i), accessor.get(i))); <START> return m; <END> }</code><technical_language>In personal experience, idiomatic write this sort of code either: java // Imperative option Map<String, Object> map = new HashMap<>(); for (int i = 0; i < accessor.size(); i++) { map.put(Integer.toString(i), accessor.get(i)); } return map; or: java // More functional option return IntStream.range(0, accessor.size()) .collect( toMap( i -> Integer.toString(i), i -> accessor.get(i))); unclear JUnit 5 team of creating maps done it, wait for feedback changing anything. :)</technical_language>

Target:
public Object aggregateArguments(ArgumentsAccessor accessor, ParameterContext context) { return IntStream .range(0, accessor.size()) .boxed() .collect( toMap( i -> Integer.toString(i), i -> accessor.get(i) ) ); }
Source:
<code>public Set<CoLocationGroupDesc> getCoLocationGroupDescriptors() { <START> final Set<CoLocationGroup> coLocationGroups = new HashSet<>(); for (JobVertex vertex : getVertices()) { CoLocationGroup coLocationGroup = vertex.getCoLocationGroup(); if (coLocationGroup != null) { coLocationGroups.add(coLocationGroup); } <END> } final Set<CoLocationGroupDesc> coLocationGroupDescs = coLocationGroups .stream() .map(CoLocationGroupDesc::from) .collect(Collectors.toSet()); return Collections.unmodifiableSet(coLocationGroupDescs); }</code><technical_language>suggestion final Set<CoLocationGroupDesc> coLocationGroupDescs = new HashSet<>(); for (JobVertex vertex : getVertices()) { CoLocationGroup coLocationGroup = vertex.getCoLocationGroup(); if (coLocationGroup != null) { CoLocationGroupDesc coLocationGroupDesc = CoLocationGroupDesc.from(coLocationGroup) coLocationGroupDescs.add(coLocationGroupDesc); } }</technical_language>

Target:
public Set<CoLocationGroupDesc> getCoLocationGroupDescriptors() { final Set<CoLocationGroupDesc> coLocationGroups = IterableUtils .toStream(getVertices()) .map(JobVertex::getCoLocationGroup) .filter(Objects::nonNull) .distinct() .map(CoLocationGroupDesc::from) .collect(Collectors.toSet()); return Collections.unmodifiableSet(coLocationGroups); }
Source:
<code>private void createVehicleList() { List<Vehicle> vehicleList = new ArrayList<>(vehicleListSize); long id = 0; for (int i = 0; i < vehicleListSize; i++) { Vehicle vehicle = new Vehicle(); vehicle.setId(id); id++; vehicle.setCapacity(capacity); if(depotList.size() == vehicleListSize){ vehicle.setDepot(depotList.get(i)); } else { vehicle.setDepot(depotList.get(0)); } <START> vehicle.setDepot(depotList.get(0)); <END> vehicleList.add(vehicle); } solution.setVehicleList(vehicleList); }</code><technical_language>this line removed? puts vehicle's depot depo 0</technical_language>

Target:
private void createVehicleList() { List<Vehicle> vehicleList = new ArrayList<>(vehicleListSize); long id = 0; for (int i = 0; i < vehicleListSize; i++) { Vehicle vehicle = new Vehicle(); vehicle.setId(id); id++; vehicle.setCapacity(capacity); depotList.get(i % depotList.size()); vehicle.setDepot(depotList.get(0)); vehicleList.add(vehicle); } solution.setVehicleList(vehicleList); }
Source:
<code>public static IPath getXmlFilesPath() { IPath path = Activator.getDefault().getStateLocation(); path = path.addTrailingSeparator().append(XML_DIRECTORY); File dir = path.toFile(); <START> if (!dir.exists()) { <END> dir.mkdirs(); } return path; }</code><technical_language>if "dir" exists is a file? Is gonna break on</technical_language>

Target:
public static IPath getXmlFilesPath() { IPath path = Activator.getDefault().getStateLocation(); path = path.addTrailingSeparator().append(XML_DIRECTORY); File dir = path.toFile(); if (!dir.exists() || !dir.isDirectory()) { dir.mkdirs(); } return path; }
Source:
<code>public void testTaskRestoreStateIsNulledAfterDeployment() throws Exception { final JobVertex jobVertex = createNoOpJobVertex(); final JobVertexID jobVertexId = jobVertex.getID(); final SingleSlotTestingSlotOwner slotOwner = new SingleSlotTestingSlotOwner(); final ProgrammedSlotProvider slotProvider = createProgrammedSlotProvider( 1, Collections.singleton(jobVertexId), slotOwner); final SchedulerBase scheduler = SchedulerTestingUtils .newSchedulerBuilderWithDefaultSlotAllocator(new JobGraph(jobVertex), slotProvider) .build(); scheduler.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); ExecutionJobVertex executionJobVertex = scheduler.getExecutionJobVertex(jobVertexId); ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0]; final Execution execution = executionVertex.getCurrentExecutionAttempt(); final JobManagerTaskRestore taskRestoreState = new JobManagerTaskRestore(1L, new TaskStateSnapshot()); execution.setInitialState(taskRestoreState); assertThat(execution.getTaskRestore(), is(notNullValue())); <START> scheduler.startScheduling(); <END> assertThat(execution.getTaskRestore(), is(nullValue())); }</code><technical_language>scheduler.startScheduling wait for anything, easier call Execution::deploy</technical_language>

Target:
public void testTaskRestoreStateIsNulledAfterDeployment() throws Exception { final JobVertex jobVertex = createNoOpJobVertex(); final JobVertexID jobVertexId = jobVertex.getID(); final SingleSlotTestingSlotOwner slotOwner = new SingleSlotTestingSlotOwner(); final ProgrammedSlotProvider slotProvider = createProgrammedSlotProvider( 1, Collections.singleton(jobVertexId), slotOwner); final SchedulerBase scheduler = SchedulerTestingUtils .newSchedulerBuilderWithDefaultSlotAllocator(new JobGraph(jobVertex), slotProvider) .build(); scheduler.initialize(ComponentMainThreadExecutorServiceAdapter.forMainThread()); ExecutionJobVertex executionJobVertex = scheduler.getExecutionJobVertex(jobVertexId); ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0]; final Execution execution = executionVertex.getCurrentExecutionAttempt(); final JobManagerTaskRestore taskRestoreState = new JobManagerTaskRestore(1L, new TaskStateSnapshot()); execution.setInitialState(taskRestoreState); assertThat(execution.getTaskRestore(), is(notNullValue())); scheduler.startScheduling(); assertThat(execution.getTaskRestore(), is(nullValue())); }
Source:
<code>public void firstBatchHasNoValidation() { Runnable validationStep = mock(Runnable.class); Set<Cell> puts = putColumns(BATCH_SIZE + 5); int limit = BATCH_SIZE - 1; Iterator<Map.Entry<Cell, byte[]>> iteratorUnderTest = createIteratorUnderTest(validationStep); List<Map.Entry<Cell, byte[]>> firstBatchBarOne = ImmutableList.copyOf(Iterators.limit(iteratorUnderTest, limit)); verifyNoInteractions(validationStep); Map.Entry<Cell, byte[]> lastInFirstBatch = Iterators.getNext(iteratorUnderTest, null); assertThat(lastInFirstBatch).isNotNull(); verifyNoInteractions(validationStep); Map.Entry<Cell, byte[]> firstInSecondBatch = Iterators.getNext(iteratorUnderTest, null); assertThat(firstInSecondBatch).isNotNull(); verify(validationStep, times(1)).run(); ImmutableList<Map.Entry<Cell, byte[]>> restOfSecondBatch = ImmutableList.copyOf(iteratorUnderTest); verifyNoMoreInteractions(validationStep); Map<Cell, byte[]> returnedEntries = ImmutableMap.<Cell, byte[]>builder() .putAll(firstBatchBarOne) .put(lastInFirstBatch) .put(firstInSecondBatch) .putAll(restOfSecondBatch) .build(); assertThat(returnedEntries.keySet()) .as("we can read all that we wrote") <START> .isEqualTo(puts); <END> }</code><technical_language>good check ordering (~we a SortedSet copy of this - ~Cell compare is based byte order of rows columns - build a List a Map of returnedEntries check ordering)</technical_language>

Target:
public void firstBatchHasNoValidation() { Runnable validationStep = mock(Runnable.class); Set<Cell> puts = putColumns(BATCH_SIZE + 5); int limit = BATCH_SIZE - 1; Iterator<Map.Entry<Cell, byte[]>> iteratorUnderTest = createIteratorUnderTest(validationStep); List<Map.Entry<Cell, byte[]>> firstBatchBarOne = ImmutableList.copyOf(Iterators.limit(iteratorUnderTest, limit)); verifyNoInteractions(validationStep); Map.Entry<Cell, byte[]> lastInFirstBatch = Iterators.getNext(iteratorUnderTest, null); assertThat(lastInFirstBatch).isNotNull(); verifyNoInteractions(validationStep); Map.Entry<Cell, byte[]> firstInSecondBatch = Iterators.getNext(iteratorUnderTest, null); assertThat(firstInSecondBatch).isNotNull(); verify(validationStep, times(1)).run(); ImmutableList<Map.Entry<Cell, byte[]>> restOfSecondBatch = ImmutableList.copyOf(iteratorUnderTest); verifyNoMoreInteractions(validationStep); List<Cell> cellsReadInOrder = Streams.stream(Iterables.concat( firstBatchBarOne, ImmutableList.of(lastInFirstBatch, firstInSecondBatch), restOfSecondBatch)) .map(Map.Entry::getKey) .collect(Collectors.toList()); assertThat(cellsReadInOrder) .as("we can read all that we wrote") .hasSameElementsAs(puts) .as("iterator returns cells back in sorted order") .isSorted(); }
Source:
<code>public Collection<IAnyResource> findCandidates(String theResourceType, IAnyResource theResource) { Map<Long, IAnyResource> matchedPidsToResources = new HashMap<>(); List<EmpiFilterSearchParamJson> filterSearchParams = myEmpiConfig.getEmpiRules().getCandidateFilterSearchParams(); List<String> filterCriteria = buildFilterQuery(filterSearchParams, theResourceType); List<EmpiResourceSearchParamJson> candidateSearchParams = myEmpiConfig.getEmpiRules().getCandidateSearchParams(); <START> if (candidateSearchParams == null || candidateSearchParams.isEmpty()) { <END> searchForIdsAndAddToMap(theResourceType, theResource, matchedPidsToResources, filterCriteria, null); } else { for (EmpiResourceSearchParamJson resourceSearchParam : candidateSearchParams) { if (!isSearchParamForResource(theResourceType, resourceSearchParam)) { continue; } searchForIdsAndAddToMap(theResourceType, theResource, matchedPidsToResources, filterCriteria, resourceSearchParam); } } if (theResource.getIdElement().getIdPart() != null) { matchedPidsToResources.remove(myIdHelperService.getPidOrNull(theResource)); } return matchedPidsToResources.values(); }</code><technical_language>is for candidateSearchParams null? I thought validated this json deserialization, I wrong</technical_language>

Target:
public Collection<IAnyResource> findCandidates(String theResourceType, IAnyResource theResource) { Map<Long, IAnyResource> matchedPidsToResources = new HashMap<>(); List<EmpiFilterSearchParamJson> filterSearchParams = myEmpiConfig.getEmpiRules().getCandidateFilterSearchParams(); List<String> filterCriteria = buildFilterQuery(filterSearchParams, theResourceType); List<EmpiResourceSearchParamJson> candidateSearchParams = myEmpiConfig.getEmpiRules().getCandidateSearchParams(); if (candidateSearchParams.isEmpty()) { searchForIdsAndAddToMap(theResourceType, theResource, matchedPidsToResources, filterCriteria, null); } else { for (EmpiResourceSearchParamJson resourceSearchParam : candidateSearchParams) { if (!isSearchParamForResource(theResourceType, resourceSearchParam)) { continue; } searchForIdsAndAddToMap(theResourceType, theResource, matchedPidsToResources, filterCriteria, resourceSearchParam); } } if (theResource.getIdElement().getIdPart() != null) { matchedPidsToResources.remove(myIdHelperService.getPidOrNull(theResource)); } return matchedPidsToResources.values(); }
Source:
<code>private void proposeLeadershipOrWaitForBackoff(LeadershipState currentState) throws InterruptedException { if (pingLeader()) { Thread.sleep(updatePollingRateInMs); return; } boolean learnedNewState = updateLearnedStateFromPeers(currentState.greatestLearnedValue()); if (learnedNewState) { return; } long backoffTime = (long) (randomWaitBeforeProposingLeadership * Math.random()); <START> log.debug("Waited for ms before proposing leadership", SafeArg.of("waitTimeMs", backoffTime)); <END> Thread.sleep(backoffTime); proposeLeadershipAfter(currentState.greatestLearnedValue()); }</code><technical_language>log message wait occurred, sleep is below. want move log line sleep adjust message wording indicating wait for backoff</technical_language>

Target:
private void proposeLeadershipOrWaitForBackoff(LeadershipState currentState) throws InterruptedException { if (pingLeader()) { Thread.sleep(updatePollingRateInMs); return; } boolean learnedNewState = updateLearnedStateFromPeers(currentState.greatestLearnedValue()); if (learnedNewState) { return; } long backoffTime = (long) (randomWaitBeforeProposingLeadership * Math.random()); log.debug("Waiting for ms before proposing leadership", SafeArg.of("waitTimeMs", backoffTime)); Thread.sleep(backoffTime); proposeLeadershipAfter(currentState.greatestLearnedValue()); }
Source:
<code>private Plugin loadPlugin(File jarFile) throws IOException, ClassNotFoundException { Manifest jarManifest = new JarFile(jarFile).getManifest(); <START> ClassLoader jarClassLoader = URLClassLoader.newInstance(getPluginURLs(jarFile), PluginLoader.class.getClassLoader()); <END> Attributes attrs = jarManifest.getMainAttributes(); String pluginName = attrs.getValue("Gerrit-Plugin"); String moduleName = attrs.getValue("Gerrit-SshModule"); Class<?> moduleClass = jarClassLoader.loadClass(moduleName); return new Plugin(pluginName, moduleClass); }</code><technical_language>please try line wrap lines longer 80 columns more direct: ClassLoader parent = PluginLoader.class.getClassLoader(); new URLClassLoader(getPluginURLs(jarFile), parent)</technical_language>

Target:
private Plugin loadPlugin(File jarFile) throws IOException, ClassNotFoundException { Manifest jarManifest = new JarFile(jarFile).getManifest(); ClassLoader parentLoader = PluginLoader.class.getClassLoader(); ClassLoader jarClassLoader = URLClassLoader.newInstance(getPluginURLs(jarFile), parentLoader); Attributes attrs = jarManifest.getMainAttributes(); String pluginName = attrs.getValue("Gerrit-Plugin"); String moduleName = attrs.getValue("Gerrit-SshModule"); Class<?> moduleClass = Class.forName(moduleName, false, jarClassLoader); return new Plugin(pluginName, moduleClass); }
Source:
<code>public static void main(final String args[]) throws IOException, SignatureException { if (args.length < 2) { System.out.println("Usage: bucketname foldername"); return; } final String bucketname = args[0]; String foldername = args[1]; if (!foldername.endsWith("/")) { foldername += "/"; } try (final Ds3Client client = Ds3ClientBuilder.fromEnv().withHttps(false).build()) { final PutObjectResponse putObjectResponse = client.putObject(new PutObjectRequest(bucketname, foldername, new EmptySeekableByteChannel(), 0L)); } catch (final UnknownHostException e) { System.out.println("Invalid Endpoint Server Name or IP Address"); } catch (final FailedRequestUsingMgmtPortException e) { System.out.println("Attempted data access on management port -- check endpoint"); } catch (final FailedRequestException e) { if (e.getStatusCode() == 403) { System.out.println("ERROR: Invalid Access ID or Secret Key"); } else if (e.getStatusCode() == 409) { System.out.println("ERROR: Object Exists"); } else { System.out.println("BlackPearl returned an unexpected status code"); } } catch (final IOException e) { System.out.println("Encountered a networking error"); <START> } <END> }</code><technical_language>Add some extra code show directory created interact it. A good example list a bucket delimiter set / printing out common prefixes</technical_language>

Target:
public static void main(final String args[]) throws IOException, SignatureException { if (args.length < 2) { System.out.println("Usage: bucketname foldername"); return; } final String bucketname = args[0]; String foldername = args[1]; if (!foldername.endsWith("/")) { foldername += "/"; } try (final Ds3Client client = Ds3ClientBuilder.fromEnv().withHttps(false).build()) { final PutObjectResponse putObjectResponse = client.putObject(new PutObjectRequest(bucketname, foldername, new EmptySeekableByteChannel(), 0L)); final Ds3ClientHelpers helper = Ds3ClientHelpers.wrap(client); final Iterable<Contents> objects = helper.listObjects(bucketname, foldername); for (final Contents object : objects) { System.out.println("Created folder: " + object.getKey() ); } } catch (final UnknownHostException e) { System.out.println("Invalid Endpoint Server Name or IP Address"); } catch (final FailedRequestUsingMgmtPortException e) { System.out.println("Attempted data access on management port -- check endpoint"); } catch (final FailedRequestException e) { if (e.getStatusCode() == 403) { System.out.println("ERROR: Invalid Access ID or Secret Key"); } else if (e.getStatusCode() == 409) { System.out.println("ERROR: Object Exists"); } else { System.out.println("BlackPearl returned an unexpected status code"); } } catch (final IOException e) { System.out.println("Encountered a networking error"); } }
Source:
<code>public void onChange(Entity oldEntity, Entity newEntity) throws FalconException{ if (oldEntity.getEntityType() != EntityType.PROCESS){ return; } Process newProcess = (Process) newEntity; if (newProcess.getSla() == null || newProcess.getSla().getShouldEndIn() == null){ backlogMetricStore.deleteEntityInstance(newProcess.getName()); entityBacklogs.remove(newProcess); Process process = EntityUtil.getEntity(oldEntity.getEntityType(), oldEntity.getName()); for(Cluster cluster : process.getClusters().getClusters()){ dropMetric(cluster.getName(), process); } <START> }if (newProcess.getSla() != null){ <END> addToBacklog(newEntity); } }</code><technical_language>this else</technical_language>

Target:
public void onChange(Entity oldEntity, Entity newEntity) throws FalconException{ if (oldEntity.getEntityType() != EntityType.PROCESS){ return; } Process newProcess = (Process) newEntity; if (newProcess.getSla() == null || newProcess.getSla().getShouldEndIn() == null){ backlogMetricStore.deleteEntityInstance(newProcess.getName()); entityBacklogs.remove(newProcess); Process process = EntityUtil.getEntity(oldEntity.getEntityType(), oldEntity.getName()); for(Cluster cluster : process.getClusters().getClusters()){ dropMetric(cluster.getName(), process); } }else{ addToBacklog(newEntity); } }
Source:
<code>public void rescheduleForRescan() { if ( shouldSchedule && !hasMore ) { lockAnd( t -> { for ( RemoteRepository repo : repoQueue ) { if ( repo.isPrefetchRescan() ) { String rescanTime = repo.getPrefetchRescanTimestamp(); if ( StringUtils.isBlank( rescanTime ) || isNowAfter( rescanTime ) ) { repo.setPrefetchRescanTimestamp( getNextRescanTimeFromNow( config.getRescanIntervalSeconds() ) ); logger.trace( "repo's current rescan time: {}", rescanTime ); logger.trace( "repo's next rescan time: {}", repo.getPrefetchRescanTimestamp() ); final boolean isScheduledRescan = StringUtils.isNotBlank( rescanTime ) && isNowAfter( rescanTime ); if ( isScheduledRescan ) { <START> List<RescanablePath> rootPaths = buildPaths( repo, true ); <END> logger.trace( "Schedule rescan enabled resources: repo: {}, paths {}", repo, rootPaths ); scheduleRepo( repo, rootPaths ); } } break; } } return null; } ); } }</code><technical_language>Do a call store this updated copy of repo again? missing it? If don't, add it, need avoid a recursive loop (triggering listener method for prefetch scheduler)</technical_language>

Target:
public void rescheduleForRescan() { if ( shouldSchedule && !hasMore ) { lockAnd( t -> { for ( RemoteRepository repo : repoQueue ) { if ( repo.isPrefetchRescan() ) { String rescanTime = repo.getPrefetchRescanTimestamp(); logger.trace( "repo's current rescan time: {}", rescanTime ); if ( StringUtils.isBlank( rescanTime ) || isNowAfter( rescanTime ) ) { repo.setPrefetchRescanTimestamp( getNextRescanTimeFromNow( config.getRescanIntervalSeconds() ) ); try { storeDataManager.storeArtifactStore( repo, new ChangeSummary( ChangeSummary.SYSTEM_USER, "Update store for prefetch rescan update" ), false, false, new EventMetadata() ); } catch ( IndyDataException e ) { logger.error( String.format( "Can not update store in prefetching rescan for repo: %s", repo ), e ); } logger.trace( "Rescan time set. Repo's next rescan time: {}", repo.getPrefetchRescanTimestamp() ); final boolean isScheduledRescan = StringUtils.isNotBlank( rescanTime ) && isNowAfter( rescanTime ); if ( isScheduledRescan ) { List<RescanablePath> rootPaths = buildPaths( repo, true ); logger.trace( "Schedule rescan enabled resources: repo: {}, paths {}", repo, rootPaths ); scheduleRepo( repo, rootPaths ); } } break; } } return null; } ); } }
Source:
<code>public Object getNullableResult(ResultSet rs, String columnName) throws SQLException { Array array = rs.getArray(columnName); <START> return (array == null || rs.wasNull()) ? null : array.getArray(); <END> }</code><technical_language>A lot of changes of this logic. curious driver returns a null for object type returns true for rs.wasNull() happen for primitive types for object types</technical_language>

Target:
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException { Array array = rs.getArray(columnName); return array == null ? null : array.getArray(); }
Source:
<code>private static Multimap<String, String> loadGroups(String groupFilePath) throws ManageUsersException { try { Multimap<String, String> groupsMap = TreeMultimap.create(); String line = null; <START> try (BufferedReader reader = new BufferedReader(new FileReader(groupFilePath))) { <END> while ((line = reader.readLine()) != null) { if (!line.trim().isEmpty()) { String[] u2g = line.split(":"); if (u2g.length == 2) { groupsMap.put(u2g[0].trim(), u2g[1].trim()); } } } } return groupsMap; } catch (IOException e) { exitWithErrorMessage("could not read group file : " + groupFilePath, null, e); } return null; }</code><technical_language>Useless nested try? remove outer one</technical_language>

Target:
private static Multimap<String, String> loadGroups(String groupFilePath) throws ManageUsersException { Multimap<String, String> groupsMap = TreeMultimap.create(); String line = null; try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(groupFilePath)))) { while ((line = reader.readLine()) != null) { if (!line.trim().isEmpty()) { String[] u2g = line.split(":"); if (u2g.length == 2) { groupsMap.put(u2g[0].trim(), u2g[1].trim()); } } } } catch (IOException e) { exitWithErrorMessage("could not read group file : " + groupFilePath, null, e); } return groupsMap; }
Source:
<code>private void showLogs(IPod pod, ExecutionEvent event) { if(pod == null){ MessageDialog.openError(HandlerUtil.getActiveShell(event), "No pod selected", "No pod was selected to retrieve a log."); return; } if(!ArrayUtils.contains(STATES, pod.getStatus())) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Logs Unavailable", NLS.bind("The log is unavailable while the pod is in {0} state.", pod.getStatus())); return; } Collection<IContainer> containers = pod.getContainers(); String containerName = null; if(containers.size() > 1) { List<String> names = containers.stream().map(c->c.getName()).collect(Collectors.toList()); Collections.sort(names); ElementListSelectionDialog dialog = new ElementListSelectionDialog(HandlerUtil.getActiveShell(event), new LabelProvider()); dialog.setElements(names.toArray()); dialog.setTitle("Pod Containers"); <START> dialog.setMessage("Which container logs do you need?"); <END> dialog.setMultipleSelection(false); int result = dialog.open(); if(Window.CANCEL == result) { return; } containerName = (String) dialog.getFirstResult(); }else if (containers.size() == 1){ containerName = containers.iterator().next().getName(); } new PodLogsJob(pod, containerName).schedule(); }</code><technical_language>message "Select a log container"</technical_language>

Target:
private void showLogs(IPod pod, ExecutionEvent event) { if(pod == null){ MessageDialog.openError(HandlerUtil.getActiveShell(event), "No pod selected", "No pod was selected to retrieve a log."); return; } if(!ArrayUtils.contains(STATES, pod.getStatus())) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Logs Unavailable", NLS.bind("The log is unavailable while the pod is in {0} state.", pod.getStatus())); return; } Collection<IContainer> containers = pod.getContainers(); if(containers.isEmpty()) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Logs Unavailable", "There are no containers from which to retrieve logs"); return; } String containerName = null; if(containers.size() > 1) { List<String> names = containers.stream().map(c->c.getName()).collect(Collectors.toList()); Collections.sort(names); ElementListSelectionDialog dialog = new ElementListSelectionDialog(HandlerUtil.getActiveShell(event), new LabelProvider()); dialog.setElements(names.toArray()); dialog.setTitle("Pod Containers"); dialog.setMessage("Select a pod container"); dialog.setMultipleSelection(false); int result = dialog.open(); if(Window.CANCEL == result) { return; } containerName = (String) dialog.getFirstResult(); }else if (containers.size() == 1){ containerName = containers.iterator().next().getName(); } new PodLogsJob(pod, containerName).schedule(); }
Source:
<code>public void placeNewOrder(Market <START> m, String <END> symbol, int volume, double price, OrderType orderType) throws StockMarketExpection { Order newOrder; if (orderType == OrderType.BUY) { newOrder = new BuyOrder(symbol, volume, price, this); if ((double)volume * price > cashInHand) { throw new StockMarketExpection("Not enough cash in hand to place buy order."); } } else { newOrder = new SellOrder(symbol, volume, price, this); boolean ownsStock = false; for (Order order: position) { if (order.getStockSymbol() == newOrder.getStockSymbol()) { ownsStock = true; if (order.getSize() < newOrder.getSize()) { throw new StockMarketExpection("You do not own enough stock to place this order."); } } } if (ownsStock == false) { throw new StockMarketExpection("You must own the stock to sell it."); } } boolean alreadyPlacedOrder = false; for (Order order: ordersPlaced) { if (order.getStockSymbol() == newOrder.getStockSymbol()) alreadyPlacedOrder = true; } if (alreadyPlacedOrder) { throw new StockMarketExpection("Cannot place two orders for the same stock."); } ordersPlaced.add(newOrder); m.addOrder(newOrder); }</code><technical_language>needs named more relevant market</technical_language>

Target:
public void placeNewOrder(Market m, String symbol, int volume, double price, OrderType orderType) throws StockMarketExpection { Order newOrder; if (orderType == OrderType.BUY) { newOrder = new BuyOrder(symbol, volume, price, this); if ((double)volume * price > cashInHand) { throw new StockMarketExpection("Not enough cash in hand to place buy order."); } } else { newOrder = new SellOrder(symbol, volume, price, this); boolean ownsStock = false; for (Order order: possession) { if (order.getStockSymbol() == newOrder.getStockSymbol()) { ownsStock = true; if (order.getSize() < newOrder.getSize()) { throw new StockMarketExpection("You do not own enough stock to place this order."); } } } if (ownsStock == false) { throw new StockMarketExpection("You must own the stock to sell it."); } } boolean alreadyPlacedOrder = false; for (Order order: ordersPlaced) { if (order.getStockSymbol() == newOrder.getStockSymbol()) alreadyPlacedOrder = true; } if (alreadyPlacedOrder) { throw new StockMarketExpection("Cannot place two orders for the same stock."); } ordersPlaced.add(newOrder); m.addOrder(newOrder); }
Source:
<code>private Collection<OperatorState> createOperatorState(OperatorID... operatorIds) { <START> Random random = new Random(0x42); <END> Collection<OperatorState> operatorStates = new ArrayList<>(operatorIds.length); for (OperatorID operatorId : operatorIds) { final OperatorState operatorState = new OperatorState(operatorId, 1, 42); final OperatorSubtaskState subtaskState = new OperatorSubtaskState( new OperatorStreamStateHandle(Collections.emptyMap(), new ByteStreamStateHandle("foobar", new byte[0])), null, null, null, singleton(createNewInputChannelStateHandle(10, random)), singleton(createNewResultSubpartitionStateHandle(10, random))); operatorState.putState(0, subtaskState); operatorStates.add(operatorState); } return operatorStates; }</code><technical_language>question: do seed here</technical_language>

Target:
private Collection<OperatorState> createOperatorState(OperatorID... operatorIds) { Random random = new Random(); Collection<OperatorState> operatorStates = new ArrayList<>(operatorIds.length); for (OperatorID operatorId : operatorIds) { final OperatorState operatorState = new OperatorState(operatorId, 1, 42); final OperatorSubtaskState subtaskState = new OperatorSubtaskState( new OperatorStreamStateHandle(Collections.emptyMap(), new ByteStreamStateHandle("foobar", new byte[0])), null, null, null, singleton(createNewInputChannelStateHandle(10, random)), singleton(createNewResultSubpartitionStateHandle(10, random))); operatorState.putState(0, subtaskState); operatorStates.add(operatorState); } return operatorStates; }
Source:
<code>protected Map<String, String> build( String localModuleId, Node moduleBody, Set<String> knownGoogProvides) { Map<String, String> aliasMap = new HashMap<>(); if (localModuleId == null) { return aliasMap; } for (Node statement : moduleBody.children()) { if (isImportAssignment(statement)) { String importedModuleId = statement.getFirstFirstChild().getChildAtIndex(1).getString(); String variableName = statement.getFirstChild().getString(); String exportedSymbolName = buildWholeModuleExportSymbolName(importedModuleId); <START> aliasMap.put(buildWholeModuleExportSymbolName(localModuleId), exportedSymbolName); <END> aliasMap.put(buildNamedExportSymbolName(localModuleId, variableName), exportedSymbolName); } else if (isImportDestructuringAssignment(statement)) { String importedModuleId = statement.getFirstChild().getChildAtIndex(1).getChildAtIndex(1).getString(); for (Node destructured : statement.getFirstFirstChild().children()) { String originalName = destructured.getString(); String variableName; if (destructured.getFirstChild() != null) { variableName = destructured.getFirstChild().getString(); } else { variableName = originalName; } String exportedSymbolName = buildNamedExportSymbolName(importedModuleId, originalName); aliasMap.put(buildWholeModuleExportSymbolName(localModuleId), exportedSymbolName); aliasMap.put(buildNamedExportSymbolName(localModuleId, variableName), exportedSymbolName); } } } return aliasMap; }</code><technical_language>extract putting of entries aliasMap a helper function, is duplicated</technical_language>

Target:
protected Map<String, String> build( String localModuleId, Node moduleBody, Set<String> knownGoogProvides) { Map<String, String> aliasMap = new HashMap<>(); if (localModuleId == null) { return aliasMap; } for (Node statement : moduleBody.children()) { if (isImportAssignment(statement)) { String importedModuleId = statement.getFirstFirstChild().getChildAtIndex(1).getString(); String variableName = statement.getFirstChild().getString(); String exportedSymbolName = buildWholeModuleExportSymbolName(importedModuleId); aliasMap.putAll( buildNamedAndWholeModuleMappings(localModuleId, variableName, exportedSymbolName)); } else if (isImportDestructuringAssignment(statement)) { String importedModuleId = statement.getFirstChild().getChildAtIndex(1).getChildAtIndex(1).getString(); for (Node destructured : statement.getFirstFirstChild().children()) { String originalName = destructured.getString(); String variableName; if (destructured.getFirstChild() != null) { variableName = destructured.getFirstChild().getString(); } else { variableName = originalName; } String exportedSymbolName = buildNamedExportSymbolName(importedModuleId, originalName); aliasMap.putAll( buildNamedAndWholeModuleMappings(localModuleId, variableName, exportedSymbolName)); } } } return aliasMap; }
Source:
<code>public void run() { mUserAccountRepository.logout( new IRepositoryCallback<Void>() { @Override public void onSuccess(Void result) { <START> mMainExecutor.run(new Runnable() { <END> @Override public void run() { mCallback.onLogoutSuccess(); } }); } @Override public void onError(final Throwable throwable) { mMainExecutor.run(new Runnable() { @Override public void run() { mCallback.onLogoutError(throwable.getMessage()); } }); } }); }</code><technical_language>Extract notification method notify..</technical_language>

Target:
public void run() { mUserAccountRepository.logout( new IRepositoryCallback<Void>() { @Override public void onSuccess(Void result) { notifyOnLogoutSucces(); } @Override public void onError(Throwable throwable) { notifyOnLogoutError(throwable); } }); }
Source:
<code><START> public Set<Resource> getHasSelfImplyingProperty(final URI property) { END> return hasSelfByProperty.get(property); }</code><technical_language>Edit doc apply hasSelf opposed hasValue -- in particular, @return references "specific value(s)"</technical_language>

Target:
public Set<Resource> getHasSelfImplyingProperty(final URI property) { final Set<Resource> types = new HashSet<>(); final Set<Resource> baseTypes = hasSelfByProperty.get(property); if (baseTypes != null) { types.addAll(baseTypes); for (final Resource baseType : baseTypes) { if (baseType instanceof URI) { types.addAll(findParents(subClassOfGraph, (URI) baseType)); } } } return types; }
Source:
<code>private <T extends ObjectId> void findAllImpl(PackList packList, Collection<T> pending, List<FoundObject<T>> r) { DfsPackFile[] packs = packList.packs; int lastIdx = 0; <START> DfsPackFile lastPack = packs[lastIdx]; <END> boolean noGarbage = avoidUnreachable; OBJECT_SCAN: for (Iterator<T> it = pending.iterator(); it.hasNext();) { T t = it.next(); try { long p = lastPack.findOffset(this, t); if (0 < p) { r.add(new FoundObject<T>(t, lastIdx, lastPack, p)); it.remove(); continue; } } catch (IOException e) { } for (int i = 0; i < packs.length; i++) { if (i == lastIdx) continue; DfsPackFile pack = packs[i]; if (noGarbage && pack.isGarbage()) continue; try { long p = pack.findOffset(this, t); if (0 < p) { r.add(new FoundObject<T>(t, i, pack, p)); it.remove(); lastIdx = i; lastPack = pack; continue OBJECT_SCAN; } } catch (IOException e) { } } } last = lastPack; }</code><technical_language>need a check for packs.length == 0 return early. a protection empty repository throwing ArrayIndexOutOfBoundsException a list of objects find</technical_language>

Target:
private <T extends ObjectId> void findAllImpl(PackList packList, Collection<T> pending, List<FoundObject<T>> r) { DfsPackFile[] packs = packList.packs; if (packs.length == 0) { return; } int lastIdx = 0; DfsPackFile lastPack = packs[lastIdx]; boolean noGarbage = avoidUnreachable; OBJECT_SCAN: for (Iterator<T> it = pending.iterator(); it.hasNext();) { T t = it.next(); try { long p = lastPack.findOffset(this, t); if (0 < p) { r.add(new FoundObject<T>(t, lastIdx, lastPack, p)); it.remove(); continue; } } catch (IOException e) { } for (int i = 0; i < packs.length; i++) { if (i == lastIdx) continue; DfsPackFile pack = packs[i]; if (noGarbage && pack.isGarbage()) continue; try { long p = pack.findOffset(this, t); if (0 < p) { r.add(new FoundObject<T>(t, i, pack, p)); it.remove(); lastIdx = i; lastPack = pack; continue OBJECT_SCAN; } } catch (IOException e) { } } } last = lastPack; }
Source:
<code>protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) { <START> if (Guid.isNullOrEmpty(storagePoolId)) { <END> return new Pair<>(true, null); } if (FeatureSupported.refreshLunSupported(DbFacade.getInstance() .getStoragePoolDao() .get(storagePoolId) .getCompatibilityVersion())) { VDSReturnValue returnValue = Backend .getInstance() .getResourceManager() .RunVdsCommand( VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, storagePoolId, StorageType.FCP, Arrays.asList(getFCPConnection()))); boolean isSuccess = returnValue.getSucceeded(); EngineFault engineFault = null; if (!isSuccess && returnValue.getVdsError() != null) { engineFault = new EngineFault(); engineFault.setError(returnValue.getVdsError().getCode()); } return new Pair<>(isSuccess, engineFault); } else { return new Pair<>(true, null); } }</code><technical_language>change this if - if (Guid.isNullOrEmpty(storagePoolId) || !FeatureSupported.refreshLunSupported(DbFacade.getInstance() .getStoragePoolDao() .get(storagePoolId) .getCompatibilityVersion()))) end eliminate else cluse line 105</technical_language>

Target:
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) { if (Guid.isNullOrEmpty(storagePoolId) || !FeatureSupported.refreshLunSupported(DbFacade.getInstance() .getStoragePoolDao() .get(storagePoolId) .getCompatibilityVersion())) { return new Pair<>(true, null); } VDSReturnValue returnValue = Backend .getInstance() .getResourceManager() .RunVdsCommand( VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, storagePoolId, StorageType.FCP, Arrays.asList(getFCPConnection()))); boolean isSuccess = returnValue.getSucceeded(); EngineFault engineFault = null; if (!isSuccess && returnValue.getVdsError() != null) { engineFault = new EngineFault(); engineFault.setError(returnValue.getVdsError().getCode()); } return new Pair<>(isSuccess, engineFault); }
Source:
<code>private static Cluster createClusterWithNoCpuName() { Cluster group = new Cluster(); group.setName("Default"); group.setCpuName(""); group.setId(DEFAULT_CLUSTER_ID); group.setCompatibilityVersion(VERSION_1_1); group.setStoragePoolId(DC_ID1); group.setArchitecture(ArchitectureType.undefined); group.setClusterPolicyId(Guid.newGuid()); group.setMaxVdsMemoryOverCommit(100); <START> group.setBiosType(BiosType.CLUSTER_DEFAULT); <END> return group; }</code><technical_language>invalid anyway, it? meaning of CLUSTER_DEFAULT cluster, set it. autodetect==null, concrete values allowed</technical_language>

Target:
private static Cluster createClusterWithNoCpuName() { Cluster group = new Cluster(); group.setName("Default"); group.setCpuName(""); group.setId(DEFAULT_CLUSTER_ID); group.setCompatibilityVersion(VERSION_1_1); group.setStoragePoolId(DC_ID1); group.setArchitecture(ArchitectureType.undefined); group.setClusterPolicyId(Guid.newGuid()); group.setMaxVdsMemoryOverCommit(100); return group; }
Source:
<code>public Object getMetadata(@NonNull String section, @NonNull String key) { if (section != null && key != null) { return impl.getMetadata(section, key); } else { <START> error("getMetadata"); <END> return null; } }</code><technical_language>I logging sense for accessor method</technical_language>

Target:
public Object getMetadata(@NonNull String section, @NonNull String key) { if (section != null && key != null) { return impl.getMetadata(section, key); } else { logNull("getMetadata"); return null; } }
Source:
<code>public void adjust(Mechanism mechanism) { <START> if (mechanism.matches("max_fuse_ticks") && entity.getBukkitEntity() instanceof Creeper && mechanism.requireInteger()) { <END> ((Creeper) entity.getBukkitEntity()).setMaxFuseTicks(mechanism.getValue().asInt()); } }</code><technical_language>unneeded instanceof check for reason</technical_language>

Target:
public void adjust(Mechanism mechanism) { if (mechanism.matches("max_fuse_ticks") && mechanism.requireInteger()) { ((Creeper) entity.getBukkitEntity()).setMaxFuseTicks(mechanism.getValue().asInt()); } }
Source:
<code>public Header.Reader headerReader( Function<ByteBuffer,String> onError ) { return headerBytes -> { byte state = headerBytes.get(); if ( state == BYTE_FAILED ) { this.failureMessage = "Unexpectedly trying to read the header of a failed index: " + onError.apply( headerBytes ); } else { this.failureMessage = null; int typeId = headerBytes.getInt(); SpatialIndexType indexType = SpatialIndexType.get( typeId ); if ( indexType == null ) { this.failureMessage = "Unknown spatial index type in index header: " + typeId; } <START> indexType.readHeader( SpaceFillingCurveSettings.this, headerBytes ); <END> } }; }</code><technical_language>This result in NullPointerException if indexType null</technical_language>

Target:
public Header.Reader headerReader( Function<ByteBuffer,String> onError ) { return headerBytes -> { byte state = headerBytes.get(); if ( state == BYTE_FAILED ) { this.failureMessage = "Unexpectedly trying to read the header of a failed index: " + onError.apply( headerBytes ); } else { int typeId = headerBytes.getInt(); SpatialIndexType indexType = SpatialIndexType.get( typeId ); if ( indexType == null ) { markAsFailed( "Unknown spatial index type in index header: " + typeId ); } else { markAsSucceeded(); indexType.readHeader( SpaceFillingCurveSettings.this, headerBytes ); } } }; }
Source:
<code>protected void updateReadOnlyChangeability() { DiskInterface diskInterface = getDiskInterface().getSelectedItem(); if (diskInterface == DiskInterface.IDE) { getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableIdeInterfaceForReadOnlyDisk()); getIsReadOnly().setIsChangable(false); getIsReadOnly().setEntity(false); return; } <START> boolean isVirtIoScsiLun = Boolean.FALSE.equals(getIsInternal().getEntity()) && diskInterface == DiskInterface.VirtIO_SCSI; <END> if (isVirtIoScsiLun) { getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableVirtIoScsiInterfaceForLunReadOnlyDisk()); getIsReadOnly().setIsChangable(false); getIsReadOnly().setEntity(false); return; } getIsReadOnly().setIsChangable(isEditEnabled()); }</code><technical_language>for readability - instead of 'isVirtIoScsiLun' flag, try adding isDirectLUN flag replace condition with: * if (diskInterface == DiskInterface.VirtIO_SCSI && isDirectLUN)</technical_language>

Target:
protected void updateReadOnlyChangeability() { DiskInterface diskInterface = getDiskInterface().getSelectedItem(); if (diskInterface == DiskInterface.IDE) { getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableIdeInterfaceForReadOnlyDisk()); getIsReadOnly().setIsChangable(false); getIsReadOnly().setEntity(false); return; } boolean isDirectLUN = Boolean.FALSE.equals(getIsInternal().getEntity()); if (diskInterface == DiskInterface.VirtIO_SCSI && isDirectLUN) { getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableVirtIoScsiInterfaceForLunReadOnlyDisk()); getIsReadOnly().setIsChangable(false); getIsReadOnly().setEntity(false); return; } getIsReadOnly().setIsChangable(isEditEnabled()); }
Source:
<code>public static FinishedSpanHandler create(List<FinishedSpanHandler> handlers, AtomicBoolean noop) { if (handlers.isEmpty()) return FinishedSpanHandler.NOOP; if (handlers.size() == 1) { FinishedSpanHandler onlyHandler = handlers.get(0); return onlyHandler == FinishedSpanHandler.NOOP ? onlyHandler : new Single(onlyHandler, noop); } int i = 0; boolean alwaysSampleLocal = false, supportsOrphans = false; <START> FinishedSpanHandler[] copy = new FinishedSpanHandler[handlers.size()]; <END> for (FinishedSpanHandler handler : handlers) { if (handler.alwaysSampleLocal()) alwaysSampleLocal = true; if (handler.supportsOrphans()) supportsOrphans = true; copy[i++] = handler; } return new Multiple(copy, noop, alwaysSampleLocal, supportsOrphans); }</code><technical_language>toArray copy avoid mysterious i</technical_language>

Target:
public static FinishedSpanHandler create(List<FinishedSpanHandler> handlers, AtomicBoolean noop) { if (handlers.isEmpty()) return FinishedSpanHandler.NOOP; if (handlers.size() == 1) { FinishedSpanHandler onlyHandler = handlers.get(0); return onlyHandler == FinishedSpanHandler.NOOP ? onlyHandler : new Single(onlyHandler, noop); } boolean alwaysSampleLocal = false, supportsOrphans = false; for (FinishedSpanHandler handler : handlers) { if (handler.alwaysSampleLocal()) alwaysSampleLocal = true; if (handler.supportsOrphans()) supportsOrphans = true; } return new Multiple(handlers, noop, alwaysSampleLocal, supportsOrphans); }
Source:
<code><START> protected InputStream getAsInputStreamFromClassLoader(String filename) { <END> ClassLoader cl = getClass().getClassLoader(); InputStream is; try { is = cl == null ? null : cl.getResourceAsStream(filename); } catch (RuntimeException re) { is = null; } if (is == null) { try { is = getClass().getClassLoader().getResourceAsStream(filename); } catch (RuntimeException re) { is = null; } } return is; }</code><technical_language>above, is necessary</technical_language>

Target:
private InputStream getAsInputStreamFromClassLoader(String filename) { ClassLoader cl = getClass().getClassLoader(); InputStream is; try { is = cl == null ? null : cl.getResourceAsStream(filename); } catch (RuntimeException re) { is = null; } if (is == null) { try { is = getClass().getClassLoader().getResourceAsStream(filename); } catch (RuntimeException re) { is = null; } } return is; }
Source:
<code>public AsyncFSStorageAgent(String path, Configuration conf) { super(path, conf); try { File tempFile = File.createTempFile("chkp", null); tempFile.delete(); tempFile.mkdir(); <START> this.localBasePath = tempFile.getAbsolutePath(); <END> } catch (IOException ex) { throw new RuntimeException(ex); } logger.info("using as the basepath for checkpointing.", this.localBasePath); this.conf = conf == null ? new Configuration() : conf; }</code><technical_language>Files.createTempDirectory</technical_language>

Target:
public AsyncFSStorageAgent(String path, Configuration conf) { super(path, conf); try { this.localBasePath = Files.createTempDirectory("chkp").toString(); } catch (IOException ex) { throw new RuntimeException(ex); } logger.info("using as the basepath for checkpointing.", this.localBasePath); this.conf = conf == null ? new Configuration() : conf; }
Source:
<code>public void testDoubleComparison() { List<Double> values = ImmutableList.of( Double.NEGATIVE_INFINITY, -456.78, -123.45, -0.0, 0.0, 123.45, 456.78, Double.POSITIVE_INFINITY, Double.NaN); <START> List<Double> sorted = values.stream() <END> .sorted(comparingLong(FloatingPointUtil::doubleToSortableLong)) .collect(toList()); assertEquals(sorted, values); }</code><technical_language>shuffle sort</technical_language>

Target:
public void testDoubleComparison() { List<Double> expected = ImmutableList.of( Double.NEGATIVE_INFINITY, -456.78, -123.45, -0.0, 0.0, 123.45, 456.78, Double.POSITIVE_INFINITY, Double.NaN); List<Double> values = new ArrayList<>(expected); shuffle(values); values.sort(comparingLong(FloatingPointUtil::doubleToSortableLong)); assertEquals(values, expected); }