auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static WorkProcessor<PageWithPosition> pageWithPositions(WorkProcessor<Page> pages, AggregatedMemoryContext aggregatedMemoryContext) { return pages.flatMap(page -> { LocalMemoryContext memoryContext = aggregatedMemoryContext.newLocalMemoryContext(MergeSortedPages.class.getSimpleName()); memoryContext.setBytes(page.getRetainedSizeInBytes()); return WorkProcessor.create(new WorkProcessor.Process<PageWithPosition>() { int position; @Override public ProcessState<PageWithPosition> process() { <START> if (position >= page.getPositionCount()) { <END> memoryContext.close(); return finished(); } return ofResult(new PageWithPosition(page, position++)); } }); }); }</code><technical_language>static import state methods for TransformationState/ProcessState, a big issue</technical_language>

Target:
private static WorkProcessor<PageWithPosition> pageWithPositions(WorkProcessor<Page> pages, AggregatedMemoryContext aggregatedMemoryContext) { return pages.flatMap(page -> { LocalMemoryContext memoryContext = aggregatedMemoryContext.newLocalMemoryContext(MergeSortedPages.class.getSimpleName()); memoryContext.setBytes(page.getRetainedSizeInBytes()); return WorkProcessor.create(new WorkProcessor.Process<PageWithPosition>() { int position; @Override public ProcessState<PageWithPosition> process() { if (position >= page.getPositionCount()) { memoryContext.close(); return ProcessState.finished(); } return ProcessState.ofResult(new PageWithPosition(page, position++)); } }); }); }
Source:
<code><START> public UIConfiguration getUIConfiguration() { <END> return this.uiConfiguration; }</code><technical_language>create index view, is a slightly more hydrated version of ui configuration sent. want a new pojo mimics that. includes shell commands/etc ares of singularity configuration</technical_language>

Target:
public IndexView getUIConfiguration() { return this.indexView; }
Source:
<code>private void setUp(String url) { try { URL webServicePort = new URL(url); jiraSoapServiceLocator = new JiraSoapServiceServiceLocator(); if (webServicePort == null) { <START> jiraSoapService = jiraSoapServiceLocator.getJirasoapserviceV2(); <END> } else { jiraSoapService = jiraSoapServiceLocator.getJirasoapserviceV2(webServicePort); log.info("SOAP Session service endpoint at " + webServicePort.toExternalForm()); } } catch (ServiceException e) { throw new RuntimeException("ServiceException during JiraService contruction", e); } catch (MalformedURLException e) { log.error("malformed url"); } }</code><technical_language>Dead code..</technical_language>

Target:
private void setUp(String url) { try { URL webServicePort = new URL(url); jiraSoapServiceLocator = new JiraSoapServiceServiceLocator(); jiraSoapService = jiraSoapServiceLocator.getJirasoapserviceV2(webServicePort); log.info("SOAP Session service endpoint at " + webServicePort.toExternalForm()); } catch (ServiceException e) { throw new RuntimeException("ServiceException during JiraService contruction", e); } catch (MalformedURLException e) { log.error("malformed jiraURI"); } }
Source:
<code>public static String getRootPassword(Entity entity) { String password = entity.config().get(MongoDBAuthenticationMixins.ROOT_PASSWORD); if (Strings.isEmpty(password)) { LOG.debug(entity + " has no password specified for " + MongoDBAuthenticationMixins.ROOT_PASSWORD.getName() + "; using a random string"); <START> password = Strings.makeRandomId(8); <END> entity.sensors().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); entity.config().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); } return password; }</code><technical_language>characters? long</technical_language>

Target:
public static String getRootPassword(Entity entity) { String password = entity.config().get(MongoDBAuthenticationMixins.ROOT_PASSWORD); if (Strings.isEmpty(password)) { LOG.debug(entity + " has no password specified for " + MongoDBAuthenticationMixins.ROOT_PASSWORD.getName() + "; using a random string"); password = Strings.makeRandomId(16); entity.sensors().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); entity.config().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); } return password; }
Source:
<code>public FeedbackConstantSumQuestionDetails() { super(FeedbackQuestionType.CONSTSUM); this.numOfConstSumOptions = 0; this.constSumOptions = new ArrayList<>(); this.distributeToRecipients = false; this.pointsPerOption = false; this.points = 100; this.minPoints = 0; <START> this.maxPoints = points; <END> this.requireMin = false; this.requireMax = false; this.forceUnevenDistribution = false; }</code><technical_language>I wondering if initialise minPoints maxPoints other special 0/-1. is a bit confuse initialise a valid maxPoints while requireMax is false</technical_language>

Target:
public FeedbackConstantSumQuestionDetails() { super(FeedbackQuestionType.CONSTSUM); this.numOfConstSumOptions = 0; this.constSumOptions = new ArrayList<>(); this.distributeToRecipients = false; this.pointsPerOption = false; this.points = 100; this.minPointsConstraint = NO_MIN_MAX_CONSTRAINT; this.maxPointsConstraint = NO_MIN_MAX_CONSTRAINT; this.forceUnevenDistribution = false; this.distributePointsFor = FeedbackConstantSumDistributePointsType.NONE.getDisplayedOption(); }
Source:
<code>private void openLogin() { Intent i = new Intent(this, LoginActivity.class); <START> String server_url = getSharedPreferences(LoginActivity.Prefs_name,MODE_PRIVATE).getString(LoginActivity.Prefs_server,null); <END> i.putExtra("server_url",server_url); startActivity(i); finish(); }</code><technical_language>lowerCamelCase too</technical_language>

Target:
private void openLogin() { Intent i = new Intent(this, LoginActivity.class); i.putExtra("server_url",server_url); startActivity(i); finish(); }
Source:
<code>private static ProcessMetadata processSampleInformation() { XPathExpression[] expr = RunProcessor.compileXPath(" return (document, dto) -> { String well = (String) expr[0].evaluate(document, XPathConstants.STRING); String name = (String) expr[1].evaluate(document, XPathConstants.STRING); if (LimsUtils.isStringBlankOrNull(name) || LimsUtils.isStringBlankOrNull(well)) { return; } Map<String, String> poolInfo = dto.getPoolNames(); if (poolInfo == null) { poolInfo = new HashMap<>(); dto.setPoolNames(poolInfo); } else if (poolInfo.containsKey(well)) { name = ""; <START> } <END> poolInfo.put(well, name); }; }</code><technical_language>alert log more aware of happening if</technical_language>

Target:
private static ProcessMetadata processSampleInformation() { XPathExpression[] expr = RunProcessor.compileXPath(" return (document, dto) -> { String well = (String) expr[0].evaluate(document, XPathConstants.STRING); String name = (String) expr[1].evaluate(document, XPathConstants.STRING); if (LimsUtils.isStringBlankOrNull(name) || LimsUtils.isStringBlankOrNull(well)) { return; } Map<String, String> poolInfo = dto.getPoolNames(); if (poolInfo == null) { poolInfo = new HashMap<>(); dto.setPoolNames(poolInfo); } else if (poolInfo.containsKey(well)) { log.error(String.format("Multiple pools in well %s on run %s; abandoing automatic pool assignment", well, dto.getRunAlias())); name = ""; } poolInfo.put(well, name); }; }
Source:
<code>public void addBinding(final Binding binding) { try { if (logger.isTraceEnabled()) { logger.trace("addBinding(" + binding + ") being called"); } if (binding.isExclusive()) { <START> if (!exclusiveBindings.contains(binding)) { <END> exclusiveBindings.add(binding); } } else { SimpleString routingName = binding.getRoutingName(); List<Binding> bindings = routingNameBindingMap.get(routingName); if (bindings == null) { bindings = new CopyOnWriteArrayList<>(); List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings); if (oldBindings != null) { bindings = oldBindings; } } if (!bindings.contains(binding)) { bindings.add(binding); } } bindingsIdMap.put(binding.getID(), binding); bindingsNameMap.put(binding.getUniqueName(), binding); if (logger.isTraceEnabled()) { logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings()); } } finally { updated(); } }</code><technical_language>CopyOnWriteArraySet exclusiveBindings perform this check atomically</technical_language>

Target:
public void addBinding(final Binding binding) { try { if (logger.isTraceEnabled()) { logger.trace("addBinding(" + binding + ") being called"); } if (binding.isExclusive()) { exclusiveBindings.add(binding); } else { SimpleString routingName = binding.getRoutingName(); List<Binding> bindings = routingNameBindingMap.get(routingName); if (bindings == null) { bindings = new CopyOnWriteArrayList<>(); List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings); if (oldBindings != null) { bindings = oldBindings; } } if (!bindings.contains(binding)) { bindings.add(binding); } } bindingsIdMap.put(binding.getID(), binding); bindingsNameMap.put(binding.getUniqueName(), binding); if (logger.isTraceEnabled()) { logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings()); } } finally { updated(); } }
Source:
<code>public boolean isConnectedToWifi() { if (androidVersion.isMarshmallowOrHigher()) { return connectedToNetworkTypeForMarshmallow(ConnectivityManager.TYPE_WIFI); <START> } else { <END> NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return networkInfo != null && networkInfo.isConnected(); } }</code><technical_language>dropping else return in branch</technical_language>

Target:
public boolean isConnectedToWifi() { return isConnectedTo(ConnectivityManager.TYPE_WIFI); }
Source:
<code>private static boolean isEqualsMethod(MethodInvocationTree syntaxNode) { if (syntaxNode.arguments().size() == 1) { <START> final ExpressionTree methodSelect = syntaxNode.methodSelect(); <END> if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree expression = (MemberSelectExpressionTree) methodSelect; return "equals".equals(expression.identifier().name()); } } return false; }</code><technical_language>Remove final modifier</technical_language>

Target:
private static boolean isEqualsMethod(MethodInvocationTree syntaxNode) { if (syntaxNode.arguments().size() == 1) { ExpressionTree methodSelect = syntaxNode.methodSelect(); if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree expression = (MemberSelectExpressionTree) methodSelect; if ("equals".equals(expression.identifier().name()) && syntaxNode.symbol().isMethodSymbol()) { Symbol.MethodSymbol symbol = (Symbol.MethodSymbol) syntaxNode.symbol(); return symbol.parameterTypes().get(0).is("java.lang.Object"); } } } return false; }
Source:
<code>public boolean destroyNetworkRulesForNic(final Connect conn, final String vmName, final NicTO nic) { if (!_canBridgeFirewall) { return false; } final List<String> nicSecIps = nic.getNicSecIps(); String secIpsStr; final StringBuilder sb = new StringBuilder(); if (nicSecIps != null) { for (final String ip : nicSecIps) { <START> sb.append(ip).append(";"); <END> } secIpsStr = sb.toString(); } else { secIpsStr = "0;"; } final List<InterfaceDef> intfs = getInterfaces(conn, vmName); if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } final InterfaceDef intf = intfs.get(nic.getDeviceId()); final String brname = intf.getBrName(); final String vif = intf.getDevName(); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("destroy_network_rules_for_vm"); cmd.add("--vmname", vmName); if (nic.getIp() != null) { cmd.add("--vmip", nic.getIp()); } cmd.add("--vmmac", nic.getMac()); cmd.add("--vif", vif); cmd.add("--nicsecips", secIpsStr); final String result = cmd.execute(); if (result != null) { return false; } return true; }</code><technical_language>a globally defined separator for this</technical_language>

Target:
public boolean destroyNetworkRulesForNic(final Connect conn, final String vmName, final NicTO nic) { if (!_canBridgeFirewall) { return false; } final List<String> nicSecIps = nic.getNicSecIps(); String secIpsStr; final StringBuilder sb = new StringBuilder(); if (nicSecIps != null) { for (final String ip : nicSecIps) { sb.append(ip).append(SecurityGroupRulesCmd.RULE_COMMAND_SEPARATOR); } secIpsStr = sb.toString(); } else { secIpsStr = "0" + SecurityGroupRulesCmd.RULE_COMMAND_SEPARATOR; } final List<InterfaceDef> intfs = getInterfaces(conn, vmName); if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } final InterfaceDef intf = intfs.get(nic.getDeviceId()); final String brname = intf.getBrName(); final String vif = intf.getDevName(); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("destroy_network_rules_for_vm"); cmd.add("--vmname", vmName); if (nic.getIp() != null) { cmd.add("--vmip", nic.getIp()); } cmd.add("--vmmac", nic.getMac()); cmd.add("--vif", vif); cmd.add("--nicsecips", secIpsStr); final String result = cmd.execute(); if (result != null) { return false; } return true; }
Source:
<code>protected void checkMultipleEditors() { fVM= ScrapbookLauncher.getDefault().getDebugTarget(getFile()); if (fVM != null) { DebugPlugin.getDefault().addDebugEventFilter(this); try { for (IThread <START> iThread : <END> fVM.getThreads()) { if (iThread.isSuspended()) { iThread.resume(); } } } catch (DebugException de) { JDIDebugUIPlugin.log(de); } } }</code><technical_language>rename thread</technical_language>

Target:
protected void checkMultipleEditors() { fVM= ScrapbookLauncher.getDefault().getDebugTarget(getFile()); if (fVM != null) { DebugPlugin.getDefault().addDebugEventFilter(this); try { for (IThread thread : fVM.getThreads()) { if (thread.isSuspended()) { thread.resume(); } } } catch (DebugException de) { JDIDebugUIPlugin.log(de); } } }
Source:
<code>protected ServletBinder register(ServletBinder binder) { if (resolver == null) throw new IllegalStateException(HttpServerText.get().noResolverAvailable); <START> binder = binder.through(new WWWAuthenticationFilter(realmName)); <END> binder = binder.through(new NoCacheFilter()); binder = binder.through(new RepositoryFilter(resolver)); return binder; }</code><technical_language>if server implements another authentication method basic authentication ? I in case set Authentication header</technical_language>

Target:
protected ServletBinder register(ServletBinder binder) { if (resolver == null) throw new IllegalStateException(HttpServerText.get().noResolverAvailable); binder = binder.through(new WWWAuthenticateFilter(authMethod, realmName)); binder = binder.through(new NoCacheFilter()); binder = binder.through(new RepositoryFilter(resolver)); return binder; }
Source:
<code>public void cleanup() throws IOException { <START> getMetastoreClient(TEST_DB_NAME).dropDatabase(TEST_DB_NAME); <END> deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); }</code><technical_language>Nice fix</technical_language>

Target:
public void cleanup() throws IOException { try { getMetastoreClient(TEST_DB_NAME).dropDatabase(TEST_DB_NAME); } finally { deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); } }
Source:
<code>public void testGetContentWithSyntaxErrors() throws IOException { final WDLHandler wdlHandler = new WDLHandler(); final File wdlFile = new File(ResourceHelpers.resourceFilePath("brokenWDL.wdl")); final Set<SourceFile> emptySet = Collections.emptySet(); final ToolDAO toolDAO = Mockito.mock(ToolDAO.class); when(toolDAO.findAllByPath(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(null); try { wdlHandler.getContent("/brokenWDL.wdl", FileUtils.readFileToString(wdlFile, StandardCharsets.UTF_8), emptySet, LanguageHandlerInterface.Type.TOOLS, toolDAO); } catch (CustomWebApplicationException e) { Assert.assertEquals(e.getResponse().getStatus(), 400); <START> Assert.assertTrue("Should contain parsing error statement, found: " + e.errorMessage, e.errorMessage.contains(WDLHandler.WDL_PARSE_ERROR)); <END> } }</code><technical_language>AssertThat(blah blah).contains(blah blah)</technical_language>

Target:
public void testGetContentWithSyntaxErrors() throws IOException { final WDLHandler wdlHandler = new WDLHandler(); final File wdlFile = new File(ResourceHelpers.resourceFilePath("brokenWDL.wdl")); final Set<SourceFile> emptySet = Collections.emptySet(); final ToolDAO toolDAO = Mockito.mock(ToolDAO.class); when(toolDAO.findAllByPath(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(null); try { wdlHandler.getContent("/brokenWDL.wdl", FileUtils.readFileToString(wdlFile, StandardCharsets.UTF_8), emptySet, LanguageHandlerInterface.Type.TOOLS, toolDAO); Assert.fail("Expected parsing error"); } catch (CustomWebApplicationException e) { Assert.assertEquals(400, e.getResponse().getStatus()); assertThat(e.getErrorMessage()).contains(WDLHandler.WDL_PARSE_ERROR); } }
Source:
<code>private ContactCache() { accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build( new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() { @Override public Map<String, List<BlackboardArtifact>> load(String key) { try { return buildMap(); } catch (SQLException | TskCoreException ex) { logger.log(Level.WARNING, "Failed to build account to contact map", ex); } return new HashMap<>(); } }); <START> PropertyChangeListener ingestListener = pce -> { <END> String eventType = pce.getPropertyName(); if (eventType.equals(DATA_ADDED.toString())) { ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue(); if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT.getTypeID()) { invalidateCache(); } } }; IngestManager.getInstance().addIngestModuleEventListener(EnumSet.of(DATA_ADDED), ingestListener); }</code><technical_language>In current state, switching cases return artifacts. invalidate cache a case is closed</technical_language>

Target:
private ContactCache() { accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build( new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() { @Override public Map<String, List<BlackboardArtifact>> load(String key) { try { return buildMap(); } catch (SQLException | TskCoreException ex) { logger.log(Level.WARNING, "Failed to build account to contact map", ex); } return new HashMap<>(); } }); PropertyChangeListener ingestListener = pce -> { String eventType = pce.getPropertyName(); if (eventType.equals(DATA_ADDED.toString())) { ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue(); if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT.getTypeID()) { invalidateCache(); } } }; Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent event) -> { if (event.getNewValue() == null) { invalidateCache(); } }); IngestManager.getInstance().addIngestModuleEventListener(EnumSet.of(DATA_ADDED), ingestListener); }
Source:
<code>private void handleCheckpointSaved( CheckpointManager.StatefulConsistentCheckpointSaved message) { <START> LOG.info("Received a StatefulCheckpointSaved message:with checkpoint id: " <END> + message.getConsistentCheckpoint().getCheckpointId()); InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder() .setStatefulCheckpointSaved(message) .build(); inControlQueue.offer(instanceControlMsg); }</code><technical_language>remove :</technical_language>

Target:
private void handleCheckpointSaved( CheckpointManager.StatefulConsistentCheckpointSaved message) { LOG.info("Received a StatefulCheckpointSaved message with checkpoint id: " + message.getConsistentCheckpoint().getCheckpointId()); InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder() .setStatefulCheckpointSaved(message) .build(); inControlQueue.offer(instanceControlMsg); }
Source:
<code>public GrillClient(GrillClientConfig conf, String username, String password) { this.conf = conf; conf.setUser(username); this.password = password; try { <START> String user = ShimLoader.getHadoopShims().getUGIForConf(conf).getUserName(); <END> this.conf.set("grill.session.cluster.user", user); } catch (LoginException e) { LOG.error(e); } catch (IOException e) { LOG.error(e); } connectToGrillServer(); statement = new GrillStatement(conn); }</code><technical_language>Do this if grill.session.cluster.user is set</technical_language>

Target:
public GrillClient(GrillClientConfig conf, String username, String password) { this.conf = conf; conf.setUser(username); this.password = password; if(this.conf.get(GrillClientConfig.GRILL_SESSION_CLUSTER_USER) == null) { this.conf.set(GrillClientConfig.GRILL_SESSION_CLUSTER_USER, System.getProperty("user.name")); } connectToGrillServer(); statement = new GrillStatement(conn); }
Source:
<code>public void testShift_JISEncoding() throws Exception { HTTPArgument arg; arg = new HTTPArgument("name.?", "value_ here", false, "Shift_JIS"); assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); <START> arg = new HTTPArgument("name.?", "value_ here", true, "Shift_JIS"); <END> assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); arg = new HTTPArgument("name.%3F", "value_+here", true, "Shift_JIS"); assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); arg = new HTTPArgument("", "\00\01\07", "", false, "Shift_JIS"); arg.setAlwaysEncoded(false); assertEquals("", arg.getEncodedName()); assertEquals("\00\01\07", arg.getEncodedValue()); }</code><technical_language>a new method for next case. I advise a spock test cases. I tabular data format in tests a great fit for tests</technical_language>

Target:
public void testShift_JISEncoding() throws Exception { testEncodings("Shift_JIS"); }
Source:
<code>public ColoredDataProcessor() { <START> super(stack -> ColorUtil.getItemStackColor(stack).isPresent(), Keys.COLOR); <END> }</code><technical_language>util check supports color instead of get color twice</technical_language>

Target:
public ColoredDataProcessor() { super(ColorUtil::hasColor, Keys.COLOR); }
Source:
<code><START> String getViewFullName(View view) { <END> String n = view.getOwnerItemGroup().getFullName(); if(n.length()==0) return view.getViewName(); else return n+'/'+ view.getViewName(); }</code><technical_language>This code invoked frequently. sense replace recursive call a loop StringBuilder</technical_language>

Target:
String getViewFullName(View view) { StringBuilder sb = new StringBuilder(); sb.append(view.getOwnerItemGroup().getFullName()); if(sb.length()==0) { return view.getViewName(); } else { sb.append("/" + view.getViewName()); return sb.toString(); } }
Source:
<code>private void promptToRefreshAll() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_prompt_refresh_all_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { <START> markAllPagesOutdated(); <END> } }); builder.setNegativeButton(R.string.no, null); builder.create().show(); }</code><technical_language>This appropriate. user wish download pages</technical_language>

Target:
private void promptToRefreshAll() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_prompt_refresh_all_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { refreshAll(); } }); builder.setNegativeButton(R.string.no, null); builder.create().show(); }
Source:
<code>public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { } catch (Exception e) { e.printStackTrace(); <START> } <END> try { } catch (Exception e) { e.printStackTrace(); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); return item; }</code><technical_language>BTW NetBeans drops nasty yellow flags foo.printStackTrace() approves foo.printStackTrace(System.err) thing. However, this is servlet code, printing stack traces all; if needed logged. [LOG.error("What happened", e);]</technical_language>

Target:
public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { Collection c = obj.getOwningCollection(); if (c != null) { item.setOwningCollection(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting owning collection for item"+item.getHandle(), e); } try { Collection c = obj.getTemplateItemOf(); if (c != null) { item.setTemplateItemOf(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting template item of for item "+item.getHandle(), e); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); return item; }
Source:
<code>void init(Drawable drawable, GCData data, long gdkGC) { if (GTK.GTK3) { if (data.foregroundRGBA != null) data.state &= ~FOREGROUND; if (data.backgroundRGBA != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } else { if (data.foreground != null) data.state &= ~FOREGROUND; if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } if (data.font != null) data.state &= ~FONT; Image image = data.image; if (image != null) { image.memGC = this; if (image.transparentPixel != -1) image.destroyMask(); } this.drawable = drawable; this.data = data; handle = gdkGC; long cairo = data.cairo = handle; Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET); setClipping(data.clipRgn); if ((data.style & SWT.MIRRORED) != 0) { <START> initCairo(); <END> if (GTK.GTK_VERSION >= OS.VERSION (3, 14, 0)) { int[] w = new int[1], h = new int[1]; getSize(w, h); Cairo.cairo_translate(cairo, w[0], 0); Cairo.cairo_scale(cairo, -1.0, 1.0); } else { Cairo.cairo_set_matrix(data.cairo, identity()); } } if (cairoTransformationMatrix == null) cairoTransformationMatrix = new double[6]; Cairo.cairo_get_matrix(data.cairo, cairoTransformationMatrix); clipping = getClipping(); }</code><technical_language>This moved if, need this in branches</technical_language>

Target:
void init(Drawable drawable, GCData data, long gdkGC) { if (GTK.GTK3) { if (data.foregroundRGBA != null) data.state &= ~FOREGROUND; if (data.backgroundRGBA != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } else { if (data.foreground != null) data.state &= ~FOREGROUND; if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } if (data.font != null) data.state &= ~FONT; Image image = data.image; if (image != null) { image.memGC = this; if (image.transparentPixel != -1) image.destroyMask(); } this.drawable = drawable; this.data = data; handle = gdkGC; long cairo = data.cairo = handle; Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET); setClipping(data.clipRgn); initCairo(); if ((data.style & SWT.MIRRORED) != 0) { if (GTK.GTK_VERSION >= OS.VERSION (3, 14, 0)) { int[] w = new int[1], h = new int[1]; getSize(w, h); Cairo.cairo_translate(cairo, w[0], 0); Cairo.cairo_scale(cairo, -1.0, 1.0); } else { Cairo.cairo_set_matrix(data.cairo, identity()); } } if (cairoTransformationMatrix == null) cairoTransformationMatrix = new double[6]; Cairo.cairo_get_matrix(data.cairo, cairoTransformationMatrix); clipping = getClipping(); }
Source:
<code>public void customize() { Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort())); newScript(CUSTOMIZING) .body.append( <START> String.format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()), <END> "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq", "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq", "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml" ) .execute(); String configFileContents = processTemplate(getTemplateConfigurationUrl()); String destinationConfigFile = format("%s/conf/activemq.xml", getRunDir()); getMachine().copyTo(new ByteArrayInputStream(configFileContents.getBytes()), destinationConfigFile); }</code><technical_language>Bonus points if statically import String.format, done elsewhere</technical_language>

Target:
public void customize() { Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort())); newScript(CUSTOMIZING) .body.append( format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()), "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq", "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq", "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml" ) .execute(); String destinationConfigFile = Os.mergePathsUnix(getRunDir(), "conf/activemq.xml"); copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile); }
Source:
<code>public void create() throws EntityAlreadyExistsException { EntityRef<E, C> ref = getEntityRef(); try { while (true) { ref.create(configuration); try { ref.fetchEntity().close(); return; } catch (EntityNotFoundException e) { } } } catch (EntityNotProvidedException e) { <START> LOGGER.error("Unable to create clustered tier manager for id {}", entityIdentifier, e); <END> throw new AssertionError(e); } catch (EntityVersionMismatchException e) { LOGGER.error("Unable to create clustered tier manager for id {}", entityIdentifier, e); throw new AssertionError(e); } }</code><technical_language>Copy pasted exception messages need adapted</technical_language>

Target:
public void create() throws EntityAlreadyExistsException { EntityRef<E, C> ref = getEntityRef(); try { while (true) { ref.create(configuration); try { ref.fetchEntity().close(); return; } catch (EntityNotFoundException e) { } } } catch (EntityNotProvidedException e) { LOGGER.error("Unable to create entity for id {}", entityType.getName(), entityIdentifier, e); throw new AssertionError(e); } catch (EntityVersionMismatchException e) { LOGGER.error("Unable to create entity for id {}", entityType.getName(), entityIdentifier, e); throw new AssertionError(e); } }
Source:
<code>public void read(BitBuffer input) { final long longNegBit = 0x0000000080000000L; int align = (int) declaration.getAlignment(); int pos = input.position() + ((align-(input.position() % align))%align); input.position(pos); boolean signed = declaration.isSigned(); int length = declaration.getLength(); long bits = 0; if (length == 64) { long low = input.getInt(32, false); low = low & 0x00000000FFFFFFFFL; long high = input.getInt(32, false); high = high & 0x00000000FFFFFFFFL; if (this.declaration.getByteOrder() != ByteOrder.BIG_ENDIAN) { bits = (high << 32) | low; } else { bits = (low << 32) | high; } } else { ByteOrder byteOrder = input.getByteOrder(); <START> if ( (this.declaration.getByteOrder() != null) && (this.declaration.getByteOrder() != input.getByteOrder()) ) { <END> input.setByteOrder(this.declaration.getByteOrder()); } bits = input.getInt(length, signed); bits = bits & 0x00000000FFFFFFFFL; if( (longNegBit == (bits & longNegBit)) && signed) { bits |= 0xffffffff00000000L; } if (byteOrder != input.getByteOrder()) { input.setByteOrder(byteOrder); } } value = bits; }</code><technical_language>extra space ( (</technical_language>

Target:
public void read(BitBuffer input) { final long longNegBit = 0x0000000080000000L; int align = (int) declaration.getAlignment(); int pos = input.position() + ((align-(input.position() % align))%align); input.position(pos); boolean signed = declaration.isSigned(); int length = declaration.getLength(); long bits = 0; ByteOrder byteOrder = input.getByteOrder(); if ( (this.declaration.getByteOrder() != null) && (this.declaration.getByteOrder() != input.getByteOrder()) ) { input.setByteOrder(this.declaration.getByteOrder()); } if (length == 64) { long low = input.getInt(32, false); low = low & 0x00000000FFFFFFFFL; long high = input.getInt(32, false); high = high & 0x00000000FFFFFFFFL; if (this.declaration.getByteOrder() != ByteOrder.BIG_ENDIAN) { bits = (high << 32) | low; } else { bits = (low << 32) | high; } } else { bits = input.getInt(length, signed); bits = bits & 0x00000000FFFFFFFFL; if( (longNegBit == (bits & longNegBit)) && signed) { bits |= 0xffffffff00000000L; } } if (byteOrder != input.getByteOrder()) { input.setByteOrder(byteOrder); } value = bits; }
Source:
<code>public SampleRecord(long rowid, Random rand, Date tsNotNull) { this.rowid = rowid; this.rowid_group = (byte)((rowid % 255) - 127); this.type_null_tinyint = nextTinyint(rand, true); this.type_not_null_tinyint = nextTinyint(rand); this.type_null_smallint = nextSmallint(rand, true); this.type_not_null_smallint = nextSmallint(rand); this.type_null_integer = nextInteger(rand, true); this.type_not_null_integer = nextInteger(rand); this.type_null_bigint = nextBigint(rand, true); this.type_not_null_bigint = nextBigint(rand); this.type_null_timestamp = nextTimestamp(rand, true); this.type_not_null_timestamp = nextTimestamp(rand); this.type_null_float = nextFloat(rand, true); <START> this.type_not_null_float = tsNotNull; <END> this.type_null_decimal = nextDecimal(rand, true); this.type_not_null_decimal = nextDecimal(rand); this.type_null_varchar25 = nextVarchar(rand, true, 1, 25); this.type_not_null_varchar25 = nextVarchar(rand, 1, 25); this.type_null_varchar128 = nextVarchar(rand, true, 25, 128); this.type_not_null_varchar128 = nextVarchar(rand, 25, 128); this.type_null_varchar1024 = nextVarchar(rand, true, 128, 1024); this.type_not_null_varchar1024 = nextVarchar(rand, 128, 1024); }</code><technical_language>Is this correct? this.type_not_null_timestamp = tsNotNull instead</technical_language>

Target:
public SampleRecord(long rowid, Random rand, Date tsNotNull) { this.rowid = rowid; this.rowid_group = (byte)((rowid % 255) - 127); this.type_null_tinyint = nextTinyint(rand, true); this.type_not_null_tinyint = nextTinyint(rand); this.type_null_smallint = nextSmallint(rand, true); this.type_not_null_smallint = nextSmallint(rand); this.type_null_integer = nextInteger(rand, true); this.type_not_null_integer = nextInteger(rand); this.type_null_bigint = nextBigint(rand, true); this.type_not_null_bigint = nextBigint(rand); this.type_null_timestamp = nextTimestamp(rand, true); this.type_not_null_timestamp = tsNotNull; this.type_null_float = nextFloat(rand, true); this.type_not_null_float = nextFloat(rand); this.type_null_decimal = nextDecimal(rand, true); this.type_not_null_decimal = nextDecimal(rand); this.type_null_varchar25 = nextVarchar(rand, true, 1, 25); this.type_not_null_varchar25 = nextVarchar(rand, 1, 25); this.type_null_varchar128 = nextVarchar(rand, true, 25, 128); this.type_not_null_varchar128 = nextVarchar(rand, 25, 128); this.type_null_varchar1024 = nextVarchar(rand, true, 128, 1024); this.type_not_null_varchar1024 = nextVarchar(rand, 128, 1024); }
Source:
<code>public RevocationOp(PoolCurator poolCurator, List<Pool> pools) { entitlementsToRevoke = new HashSet<Entitlement>(); <START> entitlementsToAdjust = new HashMap<Entitlement, Long>(); <END> sharedPools = new HashMap<Pool, List<Pool>>(); this.poolCurator = poolCurator; this.pools = pools; }</code><technical_language>if I understood right, shared ents in this list. sense change name sharedEntitlementsToAdjust</technical_language>

Target:
public RevocationOp(PoolCurator poolCurator, List<Pool> pools) { entitlementsToRevoke = new HashSet<Entitlement>(); shareEntitlementsToAdjust = new HashMap<Entitlement, Long>(); sharedPools = new HashMap<Pool, List<Pool>>(); poolNewConsumed = new HashMap<Pool, Long>(); this.poolCurator = poolCurator; this.pools = pools; }
Source:
<code>protected ComboViewer createComboViewer(final Composite parent, final EEnum eEnum) { final CCombo combo = new CCombo(parent, SWT.BORDER); <START> combo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_CYAN)); <END> combo.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event argEvent) { combo.setText(combo.getText()); } }); combo.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { combo.clearSelection(); } @Override public void focusGained(FocusEvent e) { } }); combo.setEditable(true); final MatchItemComboViewer viewer = new MatchItemComboViewer(combo) { @Override public void onEnter(int selectedIndex) { if (!isEmptyBuffer() && selectedIndex > -1) { final String closestMatch = getCCombo().getItems()[selectedIndex]; final Optional<EEnumLiteral> findLiteral = findLiteral(eEnum.getELiterals(), closestMatch); if (findLiteral.isPresent()) { setSelection(new StructuredSelection(findLiteral.get().getInstance())); } } else { setClosestMatch(getCCombo().getText()); } combo.clearSelection(); } }; return viewer; }</code><technical_language>set background color? Leftover</technical_language>

Target:
protected ComboViewer createComboViewer(final Composite parent, final EEnum eEnum) { final CCombo combo = new CCombo(parent, SWT.BORDER); combo.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event argEvent) { combo.setText(combo.getText()); } }); combo.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { combo.clearSelection(); } @Override public void focusGained(FocusEvent e) { } }); combo.setEditable(true); final MatchItemComboViewer viewer = new MatchItemComboViewer(combo) { @Override public void onEnter(int selectedIndex) { if (!isEmptyBuffer() && selectedIndex > -1) { final String closestMatch = getCCombo().getItems()[selectedIndex]; final Optional<EEnumLiteral> findLiteral = findLiteral(eEnum.getELiterals(), closestMatch); if (findLiteral.isPresent()) { setSelection(new StructuredSelection(findLiteral.get().getInstance())); } } else { setClosestMatch(getCCombo().getText()); } combo.clearSelection(); } }; return viewer; }
Source:
<code>public static WebAPICommand build(final String commandName, final ParameterSet options) throws CommandSpecException { if (!MAPPINGS.containsKey(commandName)) { throw new CommandSpecException("'" + commandName + "' is not a geogig command"); } WebAPICommand command = MAPPINGS.get(commandName).apply(options); if (command instanceof AbstractWebAPICommand) { <START> ((AbstractWebAPICommand) command).setTransactionId(options.getFirstValue( <END> "transactionId", null)); } return command; }</code><technical_language>@jdgarrett @groldan more sense move **setTransactionId** **getTransactionId** WebAPICommand interface, avoid calling **instance of** here</technical_language>

Target:
public static WebAPICommand build(final String commandName, final ParameterSet options) throws CommandSpecException { if (!MAPPINGS.containsKey(commandName)) { throw new CommandSpecException("'" + commandName + "' is not a geogig command"); } WebAPICommand command = MAPPINGS.get(commandName).apply(options); return command; }
Source:
<code>private boolean upgradeThreeFour(SQLiteDatabase db) { db.beginTransaction(); try { db.execSQL("CREATE INDEX global_index_id ON " + CommCareApp.GLOBAL_STORAGE_TABLE_KEY + " ( " + Resource.META_INDEX_PARENT_GUID + " )"); db.execSQL("CREATE INDEX upgrade_index_id ON " + CommCareApp.UPGRADE_STORAGE_TABLE_KEY + " ( " + Resource.META_INDEX_PARENT_GUID + " )"); db.execSQL("CREATE INDEX recovery_index_id ON " + CommCareApp.RECOVERY_STORAGE_TABLE_KEY + <START> " ( " + Resource.META_INDEX_PARENT_GUID + " )"); <END> db.setTransactionSuccessful(); return true; } finally { db.endTransaction(); } }</code><technical_language>Yes, hard-code names migration. Hm, for other fields well, good catch</technical_language>

Target:
private boolean upgradeThreeFour(SQLiteDatabase db) { db.beginTransaction(); try { db.execSQL("CREATE INDEX global_index_id ON GLOBAL_RESOURCE_TABLE ( PGUID )"); db.execSQL("CREATE INDEX upgrade_index_id ON UPGRADE_RESOURCE_TABLE ( PGUID )"); db.execSQL("CREATE INDEX recovery_index_id ON RECOVERY_RESOURCE_TABLE ( PGUID )"); db.setTransactionSuccessful(); return true; } finally { db.endTransaction(); } }
Source:
<code>public void buildFormStructure_shouldCombineConfigSectionsIntoOne() throws Exception { ObjectMapper mapper = new ObjectMapper(); List<AppDescriptor> appDescriptors = mapper.readValue(getClass().getClassLoader().getResourceAsStream("registration_app.json"), new TypeReference<List<AppDescriptor>>() {}); AppDescriptor appDescriptor = appDescriptors.get(0); List<String> questionIds = new ArrayList<String>(); questionIds.add("personAddress"); questionIds.add("phoneNumber"); questionIds.add("fathersDetails"); questionIds.add("mothersDetails"); questionIds.add("insuranceDetails"); <START> questionIds.add("triageVitals"); <END> NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(appDescriptor, true); Map<String, Section> sections = formStructure.getSections(); assertEquals(1, sections.size()); Section combinedSection = sections.get(RegisterPatientFormBuilder.DEMOGRAPHICS_SECTION_ID); assertNotNull(combinedSection); for (Question question : combinedSection.getQuestions()) { assertTrue(questionIds.contains(question.getId())); } }</code><technical_language>get questions out of app descriptor</technical_language>

Target:
public void buildFormStructure_shouldCombineConfigSectionsIntoOne() throws Exception { ObjectMapper mapper = new ObjectMapper(); List<AppDescriptor> appDescriptors = mapper.readValue(getClass().getClassLoader().getResourceAsStream("registration_app.json"), new TypeReference<List<AppDescriptor>>() {}); AppDescriptor appDescriptor = appDescriptors.get(0); List<String> questionIds = new ArrayList<String>(); Iterator<JsonNode> sectionIt = appDescriptor.getConfig().get("sections").getElements(); while(sectionIt.hasNext()) { Iterator<JsonNode> questionIt = sectionIt.next().get("questions").getElements(); while(questionIt.hasNext()) { questionIds.add(questionIt.next().get("id").getTextValue()); } } NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(appDescriptor, true); Map<String, Section> sections = formStructure.getSections(); assertEquals(1, sections.size()); Section combinedSection = sections.get(RegisterPatientFormBuilder.DEMOGRAPHICS_SECTION_ID); assertNotNull(combinedSection); for (Question question : combinedSection.getQuestions()) { assertTrue(questionIds.contains(question.getId())); } }
Source:
<code>public void buildActionsShouldReturnTwoActionsForTwoConfigs() { List<ActionEventRequest> eventRequests = importFormActionBuilder.buildActions(); <START> assertEquals(2, eventRequests.size()); <END> }</code><technical_language>Expand this a little, verify event request fields</technical_language>

Target:
public void buildActionsShouldReturnTwoActionsForTwoConfigs() { List<ActionEventRequest> eventRequests = importFormActionBuilder.buildActions(); assertEquals(2, eventRequests.size()); String firstConfigName = configs.getConfigs().get(0).getName(); String secondConfigName = configs.getConfigs().get(1).getName(); String expectedDisplayNameForFirstConfig = "Import Forms [" + firstConfigName + "]"; String expectedSubjectForFirstConfig = EventSubjects.IMPORT_FORMS + "." + firstConfigName; String expectedDisplayNameForSecondConfig = "Import Forms [" + secondConfigName + "]"; String expectedSubjectForSecondConfig = EventSubjects.IMPORT_FORMS + "." + secondConfigName; ActionEventRequest eventRequestForFirsConfig = eventRequests.get(0); ActionEventRequest eventRequestForSecondConfig = eventRequests.get(1); assertEquals(expectedDisplayNameForFirstConfig, eventRequestForFirsConfig.getDisplayName()); assertEquals(expectedSubjectForFirstConfig, eventRequestForFirsConfig.getSubject()); assertEquals(expectedDisplayNameForSecondConfig, eventRequestForSecondConfig.getDisplayName()); assertEquals(expectedSubjectForSecondConfig, eventRequestForSecondConfig.getSubject()); }
Source:
<code>public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable( DirectedGraph<V, E> graph) { DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph; Map<Pair<V, V>, int[]> shortestDistances = new HashMap<>(); for (DefaultDirectedGraph.VertexInfo<V, E> arc : graph1.vertexMap.values()) { for (E edge : arc.outEdges) { final V source = graph1.source(edge); final V target = graph1.target(edge); shortestDistances.put(Pair.of(source, target), new int[] {1}); } } while (true) { final List<Pair<V, V>> previous = ImmutableList.copyOf(shortestDistances.keySet()); <START> boolean changeCount = false; <END> for (E edge : graph.edgeSet()) { for (Pair<V, V> edge2 : previous) { if (edge.target.equals(edge2.left)) { final Pair<V, V> key = Pair.of(graph1.source(edge), edge2.right); int[] bestDistance = shortestDistances.get(key); int[] arc2Distance = shortestDistances.get(edge2); if ((bestDistance == null) || (bestDistance[0] > (arc2Distance[0] + 1))) { shortestDistances.put(key, new int[] {arc2Distance[0] + 1}); changeCount = true; } } } } if (!changeCount) { break; } } return new FrozenGraph<>(graph1, shortestDistances); }</code><technical_language>minor thing: this variable is a boolean, renamed (changeCount -> change ?)</technical_language>

Target:
public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable( DirectedGraph<V, E> graph) { DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph; Map<Pair<V, V>, int[]> shortestDistances = new HashMap<>(); for (DefaultDirectedGraph.VertexInfo<V, E> arc : graph1.vertexMap.values()) { for (E edge : arc.outEdges) { final V source = graph1.source(edge); final V target = graph1.target(edge); shortestDistances.put(Pair.of(source, target), new int[] {1}); } } while (true) { final List<Pair<V, V>> previous = ImmutableList.copyOf(shortestDistances.keySet()); boolean changed = false; for (E edge : graph.edgeSet()) { for (Pair<V, V> edge2 : previous) { if (edge.target.equals(edge2.left)) { final Pair<V, V> key = Pair.of(graph1.source(edge), edge2.right); int[] bestDistance = shortestDistances.get(key); int[] arc2Distance = shortestDistances.get(edge2); if ((bestDistance == null) || (bestDistance[0] > (arc2Distance[0] + 1))) { shortestDistances.put(key, new int[] {arc2Distance[0] + 1}); changed = true; } } } } if (!changed) { break; } } return new FrozenGraph<>(graph1, shortestDistances); }