auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { if (!(entityLiving instanceof EntityPlayer)) return super.onItemUseFinish(stack, worldIn, entityLiving); EntityPlayer player = (EntityPlayer) entityLiving; if (!player.capabilities.isCreativeMode) stack.shrink(1); if (!worldIn.isRemote) { player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1)); if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2]; LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); if (armour != null) { <START> if (player.capabilities.isCreativeMode) { <END> if (armour.maxUpgradePoints < 10000) { armour.maxUpgradePoints = 10000; ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); ItemLivingArmour.setLivingArmour(chestStack, armour); } } if (armour.maxUpgradePoints < 200) { armour.maxUpgradePoints = 200; ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); ItemLivingArmour.setLivingArmour(chestStack, armour); } } } } return stack; }</code><technical_language>This disallows creative players creating a normal set of armor (eg: server admin recreating items a player lost). This block condensed changing is amount</technical_language>

Target:
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { if (!(entityLiving instanceof EntityPlayer)) return super.onItemUseFinish(stack, worldIn, entityLiving); EntityPlayer player = (EntityPlayer) entityLiving; boolean isCreative = player.capabilities.isCreativeMode; if (!isCreative) stack.shrink(1); if (!worldIn.isRemote) { if (!isCreative) { player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1)); } if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2]; LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); if (armour != null) { if (armour.maxUpgradePoints < 200) armour.maxUpgradePoints = 200; else if (isCreative && armour.maxUpgradePoints < 10000) armour.maxUpgradePoints = 10000; ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); ItemLivingArmour.setLivingArmour(chestStack, armour); } } } return stack; }
Source:
<code>private void configureSSLSocket(SSLSocket sslSocket) { SSLParameters sslParameters = sslSocket.getSSLParameters(); <START> sslParameters.setNeedClientAuth(true); <END> if (cipherSuites != null) { sslParameters.setCipherSuites(cipherSuites); } sslSocket.setSSLParameters(sslParameters); }</code><technical_language>curious, setNeedClientAuth apply client socket (as opposed server socket)</technical_language>

Target:
private void configureSSLSocket(SSLSocket sslSocket) { SSLParameters sslParameters = sslSocket.getSSLParameters(); LOG.debug("Setup cipher suites for client socket: {}", Arrays.toString(cipherSuites)); sslParameters.setCipherSuites(cipherSuites); sslSocket.setSSLParameters(sslParameters); }
Source:
<code>public void testTimeLine() throws IOException, InterruptedException { String pg = "pulse"; resetTimeRange(); SWTBotTimeGraph timegraph = fTimeGraph; assertEquals(0, timegraph.selection().columnCount()); SWTBotTimeGraphEntry entry = timegraph.getEntry(pg); entry.select(); <START> fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timegraph, 0, "pulse")); <END> entry = timegraph.getEntry(pg); Rectangle rect = entry.getBounds(); ImageHelper image = ImageHelper.grabImage(rect); ImmutableMultiset<RGB> ms = Multisets.copyHighestCountFirst(image.getHistogram()); int black = ms.count(new RGB(0,0,0)); RGB bgColor = ms.elementSet().iterator().next(); int bgCount = ms.count(bgColor); assertEquals(0.10f, ((float) black) / (bgCount), 0.2f); }</code><technical_language>I this is necessary, selection is guaranteed changed select(). call select() triggers a redraw() ie. 'marked needing redrawn'. for is guarantees a paint event done calling redraw(). this achieved ImageHelper.waitForNewImage()? all, changing selection a change in display (at minimum a change of background color for selected entry)</technical_language>

Target:
public void testTimeLine() { String lines = "pulse"; resetTimeRange(); SWTBotTimeGraph timegraph = fTimeGraph; assertEquals(0, timegraph.selection().columnCount()); ImageHelper currentImage = ImageHelper.grabImage(fBounds); SWTBotTimeGraphEntry entry = timegraph.getEntry(lines); entry = timegraph.getEntry(lines).select(); ImageHelper.waitForNewImage(fBounds, currentImage); Rectangle rect = entry.absoluteLocation(); ImageHelper image = ImageHelper.grabImage(rect); ImmutableMultiset<RGB> ms = Multisets.copyHighestCountFirst(image.getHistogram()); int black = ms.count(new RGB(0, 0, 0)); RGB bgColor = ms.elementSet().iterator().next(); int bgCount = ms.count(bgColor); float actual = ((float) black) / (bgCount); System.out.println(Integer.toString(black) + " " + bgCount + " " + actual * 100); assertEquals(0.113f, actual, 0.05f); }
Source:
<code>public ResultScanner<FlatRow> readFlatRows(ReadRowsRequest request) { ResponseQueueReader reader = new ResponseQueueReader(retryOptions.getStreamingBufferSize()); final ReadRowsRetryListener listener = createReadRowsRetryListener(request, reader); <START> return new ResumingStreamingResultScanner(reader, new ScanHandler() { <END> @Override public void handleTimeout(ScanTimeoutException rte) throws BigtableRetriesExhaustedException { listener.handleTimeout(rte); } @Override public void cancel() { listener.cancel(); } }); }</code><technical_language>cleaner listener implement ScanHandler. I in previous iteration, flip flop this</technical_language>

Target:
public ResultScanner<FlatRow> readFlatRows(ReadRowsRequest request) { ResponseQueueReader reader = new ResponseQueueReader(retryOptions.getStreamingBufferSize()); final ReadRowsRetryListener listener = createReadRowsRetryListener(request, reader); return new ResumingStreamingResultScanner(reader, listener); }
Source:
<code>private static <T> LobResponse _request(APIResource.RequestMethod method, String url, Map<String, Object> params, Class<T> clazz, APIResource.RequestType type, RequestOptions options) throws AuthenticationException, APIException, IOException { if (options == null) { options = RequestOptions.getDefault(); } String apiKey = options.getApiKey(); if (apiKey == null || apiKey.trim().length() == 0) { <START> throw new AuthenticationException("Missing API Key. (HINT: set your API key using 'Lob.init(<API_KEY>);')", null); <END> } LobResponse response; String lobURL = String.format("%s%s", Lob.API_BASE_URL, url); String query = createQuery(params); return makeURLConnectionRequest(method, clazz, lobURL, query, options); }</code><technical_language>nit: I feel word HINT. expect in a video game. like: Missing API Key. 'Lob.init(<API_KEY>)' is called a key Dashboard</technical_language>

Target:
private static <T> LobResponse _request(APIResource.RequestMethod method, String url, Map<String, Object> params, Class<T> clazz, APIResource.RequestType type, RequestOptions options) throws AuthenticationException, APIException, IOException { if (options == null) { options = RequestOptions.getDefault(); } String apiKey = options.getApiKey(); if (apiKey == null || apiKey.trim().length() == 0) { throw new AuthenticationException("Missing API Key. Make sure 'Lob.init(<API_KEY>)' is called with a key from your Dashboard.", null); } LobResponse response; String lobURL = String.format("%s%s", Lob.API_BASE_URL, url); String query = createQuery(params); return makeURLConnectionRequest(method, clazz, lobURL, query, options); }
Source:
<code>private List<VanityUrl> searchAndPopulate(final String luceneQuery, final User user) { final ImmutableList.Builder<VanityUrl> results = new ImmutableList.Builder(); final PriorityQueue<VanityUrl> vanityUrls; List<VanityUrl> vanityUrlsToReturn = Collections.emptyList(); try { final List<Contentlet> contentResults = contentletAPI.search(luceneQuery, 0, 0, StringPool.BLANK, user, false); if (null == contentResults || contentResults.isEmpty()) { return results.build(); } vanityUrls = new PriorityQueue<>(contentResults.size(), (vanity1, vanity2) -> vanity1.getOrder() - vanity2.getOrder()); contentResults.stream().forEach((Contentlet con) -> { VanityUrl vanityUrl = getVanityUrlFromContentlet(con); addToVanityURLCache(vanityUrl); vanityUrls.offer(vanityUrl); }); vanityUrlsToReturn = results.addAll(vanityUrls).build(); } catch (Exception e) { <START> if (e instanceof IndexMissingException || e.getCause() instanceof IndexMissingException) { <END> Logger.error(this, "Error when initializing Vanity URLs, no index found ", e); } else if (e instanceof DotDataException || e instanceof DotSecurityException) { Logger.error(this, "Error searching for active Vanity URLs [" + luceneQuery + "]", e); } else { throw new DotRuntimeException("Error searching and populating the Vanity URL Cache", e); } } return vanityUrlsToReturn; }</code><technical_language>I agree. I split this 3 catch blocks</technical_language>

Target:
private List<VanityUrl> searchAndPopulate(final String luceneQuery, final User user) { final ImmutableList.Builder<VanityUrl> results = new ImmutableList.Builder(); final PriorityQueue<VanityUrl> vanityUrls; List<VanityUrl> vanityUrlsToReturn = Collections.emptyList(); try { final List<Contentlet> contentResults = contentletAPI.search(luceneQuery, 0, 0, StringPool.BLANK, user, false); if (null == contentResults || contentResults.isEmpty()) { return results.build(); } vanityUrls = new PriorityQueue<>(contentResults.size(), (vanity1, vanity2) -> vanity1.getOrder() - vanity2.getOrder()); contentResults.stream().forEach((Contentlet con) -> { VanityUrl vanityUrl = getVanityUrlFromContentlet(con); addToVanityURLCache(vanityUrl); vanityUrls.offer(vanityUrl); }); vanityUrlsToReturn = results.addAll(vanityUrls).build(); } catch (IndexMissingException e){ Logger.error(this, "Error when initializing Vanity URLs, no index found ", e); } catch (DotDataException | DotSecurityException e ){ Logger.error(this, "Error searching for active Vanity URLs [" + luceneQuery + "]", e); } catch (Exception e){ if ( e.getCause() instanceof IndexMissingException){ Logger.error(this, "Error when initializing Vanity URLs, no index found ", e); }else{ throw new DotRuntimeException("Error searching and populating the Vanity URL Cache", e); } } return vanityUrlsToReturn; }
Source:
<code>public void testTxRollback() throws Exception { executeTestForAllCaches(new CI2Exc<Ignite, IgniteCache<Integer, Integer>>() { @Override public void applyx(Ignite ignite, final IgniteCache<Integer, Integer> cache) throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { final Transaction tx = ignite.transactions().txStart(transactionConcurrency(), isolation); cache.put(1, 1); cache.put(2, 2); tx.suspend(); assertNull("There is no transaction for current thread", ignite.transactions().tx()); assertEquals(SUSPENDED, tx.state()); GridTestUtils.runAsync(new Runnable() { @Override public void run() { tx.resume(); assertEquals(ACTIVE, tx.state()); cache.put(3, 3); tx.rollback(); } }).get(FUT_TIMEOUT); <START> assertTrue(GridTestUtils.waitForCondition(new PA() { <END> @Override public boolean apply() { return tx.state() == ROLLED_BACK; } }, getTestTimeout())); assertEquals(ROLLED_BACK, tx.state()); assertFalse(cache.containsKey(1)); assertFalse(cache.containsKey(2)); assertFalse(cache.containsKey(3)); cache.removeAll(); } } }); }</code><technical_language>replaced lambda</technical_language>

Target:
public void testTxRollback() throws Exception { executeTestForAllCaches(new CI2Exc<Ignite, IgniteCache<Integer, Integer>>() { @Override public void applyx(Ignite ignite, final IgniteCache<Integer, Integer> cache) throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { final Transaction tx = ignite.transactions().txStart(transactionConcurrency(), isolation); cache.put(1, 1); cache.put(2, 2); tx.suspend(); assertNull("There is no transaction for current thread", ignite.transactions().tx()); assertEquals(SUSPENDED, tx.state()); GridTestUtils.runAsync(() -> { tx.resume(); assertEquals(ACTIVE, tx.state()); cache.put(3, 3); tx.rollback(); }).get(FUT_TIMEOUT); assertTrue(GridTestUtils.waitForCondition(() -> tx.state() == ROLLED_BACK, getTestTimeout())); assertEquals(ROLLED_BACK, tx.state()); assertFalse(cache.containsKey(1)); assertFalse(cache.containsKey(2)); assertFalse(cache.containsKey(3)); cache.removeAll(); } } }); }
Source:
<code>protected void populateInitial(BasicBrooklynCatalog catalog) { if (disallowLocal) { if (!hasRunOfficial()) { log.debug("CLI initial catalog not being read with disallow-local mode set."); } return; } if (initialUri!=null) { populateInitialFromUri(catalog, initialUri, PopulateMode.AUTODETECT); return; } String catalogUrl = managementContext.getConfig().getConfig(BrooklynServerConfig.BROOKLYN_CATALOG_URL); if (Strings.isNonBlank(catalogUrl)) { populateInitialFromUri(catalog, catalogUrl, PopulateMode.AUTODETECT); return; } <START> catalogUrl = Urls.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.bom"); <END> if (new File(catalogUrl).exists()) { populateInitialFromUri(catalog, "file:"+catalogUrl, PopulateMode.YAML); return; } catalogUrl = Urls.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.xml"); if (new File(catalogUrl).exists()) { populateInitialFromUri(catalog, "file:"+catalogUrl, PopulateMode.XML); return; } catalogUrl = "classpath:/brooklyn/default.catalog.bom"; if (new ResourceUtils(this).doesUrlExist(catalogUrl)) { populateInitialFromUri(catalog, catalogUrl, PopulateMode.YAML); return; } log.info("No catalog found on classpath or specified; catalog will not be initialized."); return; }</code><technical_language>If getMgmtBaseDir returns a dir, clearer Os.mergePaths(). If returns a URL, do new File(catalogUrl).exists() below, I presume</technical_language>

Target:
protected void populateInitial(BasicBrooklynCatalog catalog) { if (disallowLocal) { if (!hasRunFinalInitialization()) { log.debug("CLI initial catalog not being read when local catalog load mode is disallowed."); } return; } if (initialUri!=null) { populateInitialFromUri(catalog, initialUri, PopulateMode.AUTODETECT); return; } String catalogUrl = managementContext.getConfig().getConfig(BrooklynServerConfig.BROOKLYN_CATALOG_URL); if (Strings.isNonBlank(catalogUrl)) { populateInitialFromUri(catalog, catalogUrl, PopulateMode.AUTODETECT); return; } catalogUrl = Os.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.bom"); if (new File(catalogUrl).exists()) { populateInitialFromUri(catalog, new File(catalogUrl).toURI().toString(), PopulateMode.YAML); return; } catalogUrl = Os.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.xml"); if (new File(catalogUrl).exists()) { populateInitialFromUri(catalog, new File(catalogUrl).toURI().toString(), PopulateMode.XML); return; } catalogUrl = "classpath:/brooklyn/default.catalog.bom"; if (new ResourceUtils(this).doesUrlExist(catalogUrl)) { populateInitialFromUri(catalog, catalogUrl, PopulateMode.YAML); return; } log.info("No catalog found on classpath or specified; catalog will not be initialized."); return; }
Source:
<code>private void SaveDataToDb() { if (_saveVdsDynamic) { _vdsManager.UpdateDynamicData(_vds.getDynamicData()); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.UpdateStatisticsData(stat); CheckVdsMemoryThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { DbFacade.getInstance().getInterfaceDAO().massUpdateStatisticsForVds(statistics); return null; } }); } } updateAllInTransaction(_vmDynamicToSave.values(), DbFacade.getInstance().getVmDynamicDAO()); updateAllInTransaction(_vmStatisticsToSave.values(), DbFacade.getInstance().getVmStatisticsDAO()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } updateAllInTransaction(allVmInterfaceStatistics, DbFacade.getInstance().getVmNetworkStatisticsDAO()); updateAllInTransaction(_vmDiskImageDynamicToSave.values(), DbFacade.getInstance().getDiskImageDynamicDAO()); <START> updateAllInTransaction(vmDeviceToSave.values(), DbFacade.getInstance().getVmDeviceDAO()); <END> DbFacade.getInstance().getVmDeviceDAO().removeAll(removedDeviceIds); DbFacade.getInstance().getVmDeviceDAO().saveAll(newVmDevices); }</code><technical_language>DB updates executed Required TransactionScope</technical_language>

Target:
private void SaveDataToDb() { if (_saveVdsDynamic) { _vdsManager.UpdateDynamicData(_vds.getDynamicData()); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.UpdateStatisticsData(stat); CheckVdsMemoryThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { DbFacade.getInstance().getInterfaceDAO().massUpdateStatisticsForVds(statistics); return null; } }); } } updateAllInTransaction(_vmDynamicToSave.values(), DbFacade.getInstance().getVmDynamicDAO()); updateAllInTransaction(_vmStatisticsToSave.values(), DbFacade.getInstance().getVmStatisticsDAO()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } updateAllInTransaction(allVmInterfaceStatistics, DbFacade.getInstance().getVmNetworkStatisticsDAO()); updateAllInTransaction(_vmDiskImageDynamicToSave.values(), DbFacade.getInstance().getDiskImageDynamicDAO()); saveVmDevicesToDb(); }
Source:
<code>public static <KEY1, VALUE> void putCollectionToNestedList(Map<KEY1, List<VALUE>> map, KEY1 k1, Collection<VALUE> list) { if (map.containsKey(k1)) { map.get(k1).addAll(list); } else { List inputList = new ArrayList<>(); <START> inputList.addAll(list); <END> map.put(k1, inputList); } }</code><technical_language>lines rewritten a single constructor call</technical_language>

Target:
public static <KEY1, VALUE> void putCollectionToNestedList(Map<KEY1, List<VALUE>> map, KEY1 k1, Collection<VALUE> list) { if (map.containsKey(k1)) { map.get(k1).addAll(list); } else { map.put(k1, new ArrayList<>(list)); } }
Source:
<code>private <T> Map<T, List<byte[]>> generateState(BiFunction<Integer, Integer, T> descriptorCreator) { return range(0, stateParLevel).boxed().flatMap( gateId -> range(0, stateParLevel).mapToObj( channelId -> <START> descriptorCreator.apply(gateId, channelId))).collect(toMap( <END> identity(), descUnused -> range(0, statePartsPerChannel).mapToObj(unused -> randomStateBytes()).collect(toList()) )); }</code><technical_language>please extract a function meaningful name of lowest level</technical_language>

Target:
private <T> Map<T, List<byte[]>> generateState(BiFunction<Integer, Integer, T> descriptorCreator) { return range(0, stateParLevel).boxed().flatMap( gateId -> range(0, stateParLevel).mapToObj( channelId -> descriptorCreator.apply(gateId, channelId)) ).collect(toMap(identity(), this::generateSingleChannelState)); }
Source:
<code>void writeTo(File dir, OutputStream os) throws IOException { final MessageDigest foot = Constants.newMessageDigest(); final DigestOutputStream dos = new DigestOutputStream(os, foot); boolean extended = false; for (int i = 0; i < entryCnt; i++) { if (sortedEntries[i].isExtended()) { extended = true; break; } } final byte[] tmp = new byte[128]; System.arraycopy(SIG_DIRC, 0, tmp, 0, SIG_DIRC.length); NB.encodeInt32(tmp, 4, extended ? 3 : 2); NB.encodeInt32(tmp, 8, entryCnt); dos.write(tmp, 0, 12); <START> final int smudge_s; final int smudge_ns; <END> if (myLock != null) { myLock.createCommitSnapshot(); snapshot = myLock.getCommitSnapshot(); smudge_s = (int) (snapshot.lastModifiedInstant().getEpochSecond()); smudge_ns = snapshot.lastModifiedInstant().getNano(); } else { smudge_ns = 0; smudge_s = 0; } final boolean writeTree = tree != null; if (repository != null && entryCnt > 0) updateSmudgedEntries(); for (int i = 0; i < entryCnt; i++) { final DirCacheEntry e = sortedEntries[i]; if (e.mightBeRacilyClean(Instant.ofEpochSecond(smudge_s, smudge_ns))) e.smudgeRacilyClean(); e.write(dos); } if (writeTree) { @SuppressWarnings("resource") TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb); bb.close(); NB.encodeInt32(tmp, 0, EXT_TREE); NB.encodeInt32(tmp, 4, (int) bb.length()); dos.write(tmp, 0, 8); bb.writeTo(dos, null); } finally { bb.destroy(); } } writeIndexChecksum = foot.digest(); os.write(writeIndexChecksum); os.close(); }</code><technical_language>Instant smudge;</technical_language>

Target:
void writeTo(File dir, OutputStream os) throws IOException { final MessageDigest foot = Constants.newMessageDigest(); final DigestOutputStream dos = new DigestOutputStream(os, foot); boolean extended = false; for (int i = 0; i < entryCnt; i++) { if (sortedEntries[i].isExtended()) { extended = true; break; } } final byte[] tmp = new byte[128]; System.arraycopy(SIG_DIRC, 0, tmp, 0, SIG_DIRC.length); NB.encodeInt32(tmp, 4, extended ? 3 : 2); NB.encodeInt32(tmp, 8, entryCnt); dos.write(tmp, 0, 12); Instant smudge; if (myLock != null) { myLock.createCommitSnapshot(); snapshot = myLock.getCommitSnapshot(); smudge = snapshot.lastModifiedInstant(); } else { smudge = Instant.EPOCH; } final boolean writeTree = tree != null; if (repository != null && entryCnt > 0) updateSmudgedEntries(); for (int i = 0; i < entryCnt; i++) { final DirCacheEntry e = sortedEntries[i]; if (e.mightBeRacilyClean(smudge)) { e.smudgeRacilyClean(); } e.write(dos); } if (writeTree) { @SuppressWarnings("resource") TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb); bb.close(); NB.encodeInt32(tmp, 0, EXT_TREE); NB.encodeInt32(tmp, 4, (int) bb.length()); dos.write(tmp, 0, 8); bb.writeTo(dos, null); } finally { bb.destroy(); } } writeIndexChecksum = foot.digest(); os.write(writeIndexChecksum); os.close(); }
Source:
<code><START> public static KeyStore buildKeystore(final String alias, final String cert, final String privateKey, final String storePassword) throws KeyStoreException, CertificateException, <END> NoSuchAlgorithmException, InvalidKeySpecException, IOException { final KeyStore ks = KeyStore.getInstance("JKS"); ks.load(null, storePassword != null ? storePassword.toCharArray() : null); final Certificate[] certs = new Certificate[1]; certs[0] = buildCertificate(cert); ks.setKeyEntry(alias, buildPrivateKey(privateKey), storePassword != null ? storePassword.toCharArray() : null, certs); return ks; }</code><technical_language>Please consider adding Precondition.checkArgument checks: * alias is blank * cert is blank * privateKey is blank</technical_language>

Target:
public static KeyStore buildKeystore(final String alias, final String cert, final String privateKey, final String storePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, InvalidKeySpecException, IOException { Preconditions.checkArgument(!Strings.isNullOrEmpty(alias), "Certificate alias cannot be blank"); Preconditions.checkArgument(!Strings.isNullOrEmpty(cert), "Certificate cannot be blank"); Preconditions.checkArgument(!Strings.isNullOrEmpty(privateKey), "Private key cannot be blank"); char password[] = null; if (storePassword != null) { password = storePassword.toCharArray(); } final KeyStore ks = KeyStore.getInstance("JKS"); ks.load(null, password); final Certificate[] certs = new Certificate[1]; certs[0] = buildCertificate(cert); ks.setKeyEntry(alias, buildPrivateKey(privateKey), password, certs); return ks; }
Source:
<code><START> public void getUserByActivationKey_shouldGetUserByActivationKey(){ <END> User u = new User(); u.setPerson(new Person()); u.addName(new PersonName("Benjamin", "A", "Wolfe")); u.setUsername("bwolfe"); u.getPerson().setGender("M"); User createdUser = userService.createUser(u, "Openmr5xy"); String key="h4ph0fpNzQCIPSw8plJI"; int validTime = 10*60*1000; Long tokenTime = System.currentTimeMillis() + validTime; LoginCredential credentials = dao.getLoginCredential(createdUser); credentials.setActivationKey("b071c88d6d877922e35af2e6a90dd57d37ac61143a03bb986c5f353566f3972a86ce9b2604c31a22dfa467922dcfd54fa7d18b0a7c7648d94ca3d97a88ea2fd0:"+tokenTime); dao.updateLoginCredential(credentials); User user = userService.getUserByActivationKey(key); assertEquals(createdUser, user); }</code><technical_language>is this test above</technical_language>

Target:
public void getUserByActivationKey_shouldGetUserByActivationKey(){ User u = new User(); u.setPerson(new Person()); u.addName(new PersonName("Benjamin", "A", "Wolfe")); u.setUsername("bwolfe"); u.getPerson().setGender("M"); User createdUser = userService.createUser(u, "Openmr5xy"); String key="h4ph0fpNzQCIPSw8plJI"; int validTime = 10*60*1000; Long tokenTime = System.currentTimeMillis() + validTime; LoginCredential credentials = dao.getLoginCredential(createdUser); credentials.setActivationKey("b071c88d6d877922e35af2e6a90dd57d37ac61143a03bb986c5f353566f3972a86ce9b2604c31a22dfa467922dcfd54fa7d18b0a7c7648d94ca3d97a88ea2fd0:"+tokenTime); dao.updateLoginCredential(credentials); assertEquals(createdUser, userService.getUserByActivationKey(key)); }
Source:
<code>public HttpConnectionFilterContext filterResponse(HttpConnectionFilterContext context) { HttpURLConnection connection = context.connection.getConnection(); if (context.connection.getResponseCode() == 401) { cookie = getCookie(connection.getURL()); if(cookie != null) { context.replayRequest = true; connection.setRequestProperty("Cookie", cookie); context = new HttpConnectionFilterContext(context); } else { context.replayRequest = false; } } return context; <START> } <END></code><technical_language>left indent this brace matches opening brace</technical_language>

Target:
public HttpConnectionFilterContext filterResponse(HttpConnectionFilterContext context) { HttpURLConnection connection = context.connection.getConnection(); try { if (context.connection.getConnection().getResponseCode() == 401) { cookie = getCookie(connection.getURL()); if(cookie != null) { context.replayRequest = true; } else { context.replayRequest = false; } } } catch (IOException e) { logger.log(Level.SEVERE, "Failed to get response code from request",e); } return context; }
Source:
<code>private void handleVmLease() { Guid importedLeaseStorageDomainId = getVmTemplate().getLeaseStorageDomainId(); if (importedLeaseStorageDomainId == null) { return; } if (!getVmTemplate().isAutoStartup() || !shouldAddLease(getVmTemplate())) { getVmTemplate().setLeaseStorageDomainId(null); return; } if (!FeatureSupported.isVmLeasesSupported(getEffectiveCompatibilityVersion())) { getVmTemplate().setLeaseStorageDomainId(null); auditLogDirector.log(this, AuditLogType.CANNOT_IMPORT_VM_WITH_LEASE_COMPAT_VERSION); return; } if (validateLeaseStorageDomain(importedLeaseStorageDomainId) && addVmLease(importedLeaseStorageDomainId, getVmTemplate().getId(), false)) { return; } getVmTemplate().setLeaseStorageDomainId(addVmLeaseToDefaultStorageDomain()); if (getVmTemplate().getLeaseStorageDomainId() == null) { auditLogDirector.log(this, <START> AuditLogType.CANNOT_IMPORT_VM_WITH_LEASE_STORAGE_DOMAIN); <END> } else { log.warn("Creating the lease for the VM Template '{}' on storage domain '{}', because storage domain '{}' is unavailable", getVmTemplate().getId(), getVmTemplate().getLeaseStorageDomainId(), importedLeaseStorageDomainId); } }</code><technical_language>present log message is relevant for a VM template</technical_language>

Target:
private void handleVmLease() { Guid importedLeaseStorageDomainId = getVmTemplate().getLeaseStorageDomainId(); if (importedLeaseStorageDomainId == null) { return; } if (!getVmTemplate().isAutoStartup() || !shouldAddLease(getVmTemplate())) { getVmTemplate().setLeaseStorageDomainId(null); return; } if (!FeatureSupported.isVmLeasesSupported(getEffectiveCompatibilityVersion())) { getVmTemplate().setLeaseStorageDomainId(null); auditLogDirector.log(this, AuditLogType.CANNOT_IMPORT_VM_TEMPLATE_WITH_LEASE_COMPAT_VERSION); return; } if (validateLeaseStorageDomain(importedLeaseStorageDomainId)) { return; } getVmTemplate().setLeaseStorageDomainId(setVmLeaseToDefaultStorageDomain()); if (getVmTemplate().getLeaseStorageDomainId() == null) { auditLogDirector.log(this, AuditLogType.CANNOT_IMPORT_VM_TEMPLATE_WITH_LEASE_STORAGE_DOMAIN); } else { log.warn("Setting the lease for the VM Template '{}' to the storage domain '{}', because the storage domain '{}' is unavailable", getVmTemplate().getId(), getVmTemplate().getLeaseStorageDomainId(), importedLeaseStorageDomainId); } }
Source:
<code>public ValidationResult validate(Object value) { assert value == null || value instanceof String : "This validation must be run on a String!"; String mask = (String) value; boolean isValidFormat = isPrefixSupported ? MaskValidator.getInstance().isMaskFormatValid(mask) : MaskValidator.getInstance() .isNetmaskFormatValid(mask); boolean isValidValue = isValidFormat ? (isPrefixSupported ? MaskValidator.getInstance().isMaskValid(mask) : MaskValidator.getInstance() .isNetmaskValid(mask)) : false; <START> if (!isValidFormat) { <END> return failWith(getSubnetBadFormatMessage()); } else if (!isValidValue) { return failWith(getInvalidMask()); } return new ValidationResult(); }</code><technical_language>This moved validation - validation is ill-defined if format valid</technical_language>

Target:
public ValidationResult validate(Object value) { assert value == null || value instanceof String : "This validation must be run on a String!"; String mask = (String) value; if (!MaskValidator.getInstance().isMaskFormatValid(mask, isPrefixSupported)) { return failWith(getSubnetBadFormatMessage()); } else if (!MaskValidator.getInstance().isMaskValid(mask, isPrefixSupported)) { return failWith(getInvalidMask()); } return new ValidationResult(); }
Source:
<code><START> private Criterion getHypervisorIdRestriction(Iterable<String> hypervisorIds) { <END> List<Criterion> ors = new LinkedList<Criterion>(); for (String hypervisorId : hypervisorIds) { ors.add(Restrictions.eq("hvsr.hypervisorId", hypervisorId.toLowerCase())); } return Restrictions.or(ors.toArray(new Criterion[0])); }</code><technical_language>I this code, this is painfully inefficient here. building a list of restrictions convert array (since in place optimal do so, *didn't* ArrayList), Disjunction object this functionality built in require shenanigans. Disjunction disjunction = Restrictions.disjunction(); for (String hid : hypervisorIds) { disjunction.add(Requestions.eq("hsvr.hypervisorId", hid.toLowerCase())); } return disjunction;</technical_language>

Target:
private Criterion getHypervisorIdRestriction(Iterable<String> hypervisorIds) { Disjunction disjunction = Restrictions.disjunction(); for (String hid : hypervisorIds) { disjunction.add(Restrictions.eq("hvsr.hypervisorId", hid.toLowerCase())); } return disjunction; }
Source:
<code>private Message constructMockMessage() { StreamManager.TupleMessage.Builder message = StreamManager.TupleMessage.newBuilder(); HeronTuples.HeronTupleSet.Builder heronTupleSet = HeronTuples.HeronTupleSet.newBuilder(); HeronTuples.HeronDataTupleSet.Builder dataTupleSet = HeronTuples.HeronDataTupleSet.newBuilder(); TopologyAPI.StreamId.Builder streamId = TopologyAPI.StreamId.newBuilder(); streamId.setComponentName("test-spout"); streamId.setId("default"); dataTupleSet.setStream(streamId); for (int i = 0; i < 10; i++) { HeronTuples.HeronDataTuple.Builder dataTuple = HeronTuples.HeronDataTuple.newBuilder(); dataTuple.setKey(19901017 + i); HeronTuples.RootId.Builder rootId = HeronTuples.RootId.newBuilder(); rootId.setKey(19901017 + i); rootId.setTaskid(0); dataTuple.addRoots(rootId); <START> String s; <END> if ((i & 1) == 0) { s = "A"; } else { s = "B"; } ByteString byteString = ByteString.copyFrom(s.getBytes()); dataTuple.addValues(byteString); dataTupleSet.addTuples(dataTuple); } heronTupleSet.setData(dataTupleSet); message.setSet(heronTupleSet); return message.build(); }</code><technical_language>a nitpick, replace this if..else String s = ((i&1) == 0) ? "A" : "B";</technical_language>

Target:
private Message constructMockMessage() { StreamManager.TupleMessage.Builder message = StreamManager.TupleMessage.newBuilder(); HeronTuples.HeronTupleSet.Builder heronTupleSet = HeronTuples.HeronTupleSet.newBuilder(); HeronTuples.HeronDataTupleSet.Builder dataTupleSet = HeronTuples.HeronDataTupleSet.newBuilder(); TopologyAPI.StreamId.Builder streamId = TopologyAPI.StreamId.newBuilder(); streamId.setComponentName("test-spout"); streamId.setId("default"); dataTupleSet.setStream(streamId); for (int i = 0; i < 10; i++) { HeronTuples.HeronDataTuple.Builder dataTuple = HeronTuples.HeronDataTuple.newBuilder(); dataTuple.setKey(19901017 + i); HeronTuples.RootId.Builder rootId = HeronTuples.RootId.newBuilder(); rootId.setKey(19901017 + i); rootId.setTaskid(0); dataTuple.addRoots(rootId); String tupleData = ((i & 1) == 0) ? "A" : "B"; dataTuple.addValues(ByteString.copyFrom(tupleData.getBytes())); dataTupleSet.addTuples(dataTuple); } heronTupleSet.setData(dataTupleSet); message.setSet(heronTupleSet); return message.build(); }
Source:
<code>private static int getFontSize() { if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) { return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1; } else { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); <START> if (ge.getMaximumWindowBounds().getWidth() > 4000) { <END> return 56; } else if (ge.getMaximumWindowBounds().getWidth() > 2000) { return 28; } else { return 14; } } }</code><technical_language>screen-resolutions MaximumWindowBounds, I 4000 is unfortunate value. a 4096 monitor font-sizes in lanterna apps based wide sidebar is. E.g.: 4096 a 96 pixel wide sidebar a smaller font even-slightly-more-than-96 pixel wide sidebar. If a convenient "the widest of monitors"(without subtracting insets) method, propose 3840 a "sweeter" value</technical_language>

Target:
private static int getFontSize() { if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) { return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1; } else { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (ge.getMaximumWindowBounds().getWidth() > 4096) { return 56; } else if (ge.getMaximumWindowBounds().getWidth() > 2048) { return 28; } else { return 14; } } }
Source:
<code>Object createNew0(Object delegate) throws Exception { Constructor<?> constructor = targetClass.getConstructor(Long.TYPE, Long.TYPE, Long.TYPE); <START> Object create = getFieldValueReflectively(delegate, "create"); <END> Object access = getFieldValueReflectively(delegate, "access"); Object update = getFieldValueReflectively(delegate, "update"); Object[] args = new Object[]{ getFieldValueReflectively(create, "durationAmount"), getFieldValueReflectively(access, "durationAmount"), getFieldValueReflectively(update, "durationAmount") }; return constructor.newInstance(args); }</code><technical_language>suggestion Duration create = getFieldValueReflectively(delegate, "create"); Duration access = getFieldValueReflectively(delegate, "access"); Duration update = getFieldValueReflectively(delegate, "update"); Object[] args = new Object[]{ create.getTimeUnit().toMillis(create.getDurationAmount()), access.getTimeUnit().toMillis(access.getDurationAmount()), update.getTimeUnit().toMillis(update.getDurationAmount()), }; Duration is a javax.cache API class loaded HazelcastAPIDelegatingClassLoader here. durationAmount part need account timeUnit part get accurate clone. Minimal test: HazelcastExpiryPolicy policy = new HazelcastExpiryPolicy(3L, 5L, 4L, TimeUnit.SECONDS); HazelcastExpiryPolicyConstructor constructor = new HazelcastExpiryPolicyConstructor(HazelcastExpiryPolicy.class); HazelcastExpiryPolicy cloned = (HazelcastExpiryPolicy) constructor.createNew(policy); assertEquals(policy, cloned);</technical_language>

Target:
Object createNew0(Object delegate) throws Exception { Constructor<?> constructor = targetClass.getConstructor(Long.TYPE, Long.TYPE, Long.TYPE); Duration create = getFieldValueReflectively(delegate, "create"); Duration access = getFieldValueReflectively(delegate, "access"); Duration update = getFieldValueReflectively(delegate, "update"); Object[] args = new Object[]{ create.getTimeUnit().toMillis(create.getDurationAmount()), access.getTimeUnit().toMillis(access.getDurationAmount()), update.getTimeUnit().toMillis(update.getDurationAmount()), }; return constructor.newInstance(args); }
Source:
<code>@Override public void toJson(JsonWriter writer, Object value) throws IOException { if (!baseTypeIsObject) { objectJsonAdapter.toJson(writer, toJsonMap(value)); return; } <START> if (reentrantFromObjectAdapter) { <END> objectJsonAdapter.toJson(writer, value); return; } reentrantFromObjectAdapter = true; try { objectJsonAdapter.toJson(writer, toJsonMap(value)); } finally { reentrantFromObjectAdapter = false; } }</code><technical_language>I this works for recursive structures trees</technical_language>

Target:
@Override public void toJson(JsonWriter writer, Object value) throws IOException { Class<?> type = value.getClass(); String label = typeToLabel.get(type); if (label == null) { throw new IllegalArgumentException("Expected one of " + typeToLabel.keySet() + " but found " + value + ", a " + value.getClass() + ". Register this subtype."); } JsonAdapter<Object> adapter = labelToAdapter.get(label); Map<String, Object> jsonValue = (Map<String, Object>) adapter.toJsonValue(value); Map<String, Object> valueWithLabel = new LinkedHashMap<>(1 + jsonValue.size()); valueWithLabel.put(labelKey, label); valueWithLabel.putAll(jsonValue); objectJsonAdapter.toJson(writer, valueWithLabel); }
Source:
<code><START> static short getCurrentVersion() { <END> return getResponseVersionToUse; }</code><technical_language>if variable is package private, this function serve purpose</technical_language>

Target:
static short getCurrentVersion() { return CURRENT_VERSION; }
Source:
<code>private static String trimLeadingPlusOfLongString(String metricValueString) { if (metricValueString.isEmpty()) { return metricValueString; } if (metricValueString.charAt(0) == '+') { <START> if (metricValueString.length() > 1) { <END> char secondChar = metricValueString.charAt(1); if (secondChar >= '0' && secondChar <= '9') { metricValueString = metricValueString.substring(1); } } } return metricValueString; }</code><technical_language>do if (metricValueString.length() > 1 && metricValueString.charAt(0) == '+') {.. eliminate other if condition checking for metricValueString.isEmpty()</technical_language>

Target:
private static String trimLeadingPlusOfLongString(String metricValueString) { if (metricValueString.length() > 1 && metricValueString.charAt(0) == '+') { char secondChar = metricValueString.charAt(1); if (secondChar >= '0' && secondChar <= '9') { metricValueString = metricValueString.substring(1); } } return metricValueString; }
Source:
<code>public void testSvgzImageLoad() { openRepresentation(localSession.getOpenedSession(), REPRESENTATION_DESCRIPTION_NAME, REPRESENTATION_NAME, DDiagram.class); openErrorLogView(); SWTBotView logViewBot = bot.viewByTitle("Error Log"); <START> assertTrue("There must be no errors during the load of svgz image.", checkNoErrorLogMessage(logViewBot)); <END> logViewBot.close(); }</code><technical_language>assertEquals() instead of assertTrue(), this allows result in case of test failure. check error logs is done in AbstractSiriusSwtBotGefTestCase.teardown(). Instead check image is correctly displayed</technical_language>

Target:
public void testSvgzImageLoad() { editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), REPRESENTATION_DESCRIPTION_NAME, REPRESENTATION_NAME, DDiagram.class); SWTBotGefEditPart editPartBot = editor.getEditPart("C1").parent(); EditPart editPart = editPartBot.part(); IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) editPart.getChildren().get(1); IFigure figure = (IFigure) graphicalEditPart.getFigure().getChildren().get(0); SVGWorkspaceImageFigure svgWorkspaceImageFigure = (SVGWorkspaceImageFigure) figure; String uri = svgWorkspaceImageFigure.getURI(); WorkspaceImage workspaceImage = getWorkspaceImage(editPartBot); String imageFile = FileProvider.getDefault().getFile(new Path(workspaceImage.getWorkspacePath())).toURI().toString(); assertEquals("The svg image doesn't corresponds to " + workspaceImage.getWorkspacePath(), imageFile, uri); }
Source:
<code>public <R> AcquireLockResponse<R> acquireLock(@Nonnull final LockOptions lockOptions, @Nonnull final Callable<R> onLockAcquiredCallback) { int maxHeartbeatCount = Integer.MAX_VALUE; if (lockOptions instanceof RefreshableLockOptions) { maxHeartbeatCount = ((RefreshableLockOptions) lockOptions).getMaxHeartbeatCount(); } lockOptions.validateInputs(); Lock lock = null; R workResult = null; LockStatus status = LockStatus.TAKEN; HeartbeatLockRequest heartbeatLockRequest = null; lockOptions.setVersion(clock.millis()); try { try { lock = tryCreateLock(lockOptions); } catch (IOException e) { throw new IllegalStateException("Failed to deserialize lock content", e); } if (!matchesLock(lockOptions, lock)) { log.info("Could not acquire already taken lock {}", lock); } else { <START> LongTaskTimer acquireDurationTimer = registry.longTaskTimer(String.format("redis.lock.acquireDuration.%s", lock.getName())); <END> status = LockStatus.ACQUIRED; log.info("Acquired Lock {}.", lock); long timer = acquireDurationTimer.start(); heartbeatLockRequest = new HeartbeatLockRequest(lock, new AtomicInteger(maxHeartbeatCount)); queueHeartbeat(heartbeatLockRequest); synchronized (heartbeatLockRequest.getLock()) { try { workResult = onLockAcquiredCallback.call(); } catch (Exception e) { log.error("Callback failed using lock {}", lock, e); throw new LockCallbackException(e); } finally { acquireDurationTimer.stop(timer); lock = heartbeatLockRequest.getLock(); } } } return new AcquireLockResponse<>(lock, workResult, status, null, tryLockReleaseQuietly(lock)); } catch (Exception e) { if (e instanceof LockCallbackException) { throw e; } log.error("Failed to acquire lock", e); status = LockStatus.ERROR; return new AcquireLockResponse<>(lock, workResult, status, e, tryLockReleaseQuietly(lock)); } finally { Optional.ofNullable(heartbeatLockRequest).ifPresent(r -> heartbeatQueue.remove(r)); registry.counter( acquireId .withTag("lockName", lockOptions.getLockName()) .withTag("status", status.toString()) ).increment(); } }</code><technical_language>Line long</technical_language>

Target:
public <R> AcquireLockResponse<R> acquireLock(@Nonnull final LockOptions lockOptions, @Nonnull final Callable<R> onLockAcquiredCallback) { return acquire(lockOptions, onLockAcquiredCallback); }
Source:
<code>public Lease_newBreakOption(Lease lease) { <START> super(Lease_newBreakOption.class); <END> this.lease = lease; }</code><technical_language>remove super(...) call</technical_language>

Target:
public Lease_newBreakOption(Lease lease) { this.lease = lease; }
Source:
<code>public void simpleTableTest1() throws Exception { String tableName = "testTable"; <START> Path path = new Path(); <END> AbstractGriffinTest.assertMemoryLeak(() -> { compiler.compile("create table " + tableName + " as (select" + " rnd_symbol(4,4,4,2) sym," + " rnd_double(2) d," + " timestamp_sequence(0, 1000000000) ts" + " from long_sequence(10000)) timestamp(ts)", sqlExecutionContext); }); TableBackupManager tableBackupManager = new TableBackupManager(configuration, engine, compiler); AbstractGriffinTest.assertMemoryLeak(() -> { tableBackupManager.backupTable(sqlExecutionContext.getCairoSecurityContext(), tableName, path); }); String sourceSelectAll = selectAll(tableName); setup(backupRoot, null); String backupSelectAll = selectAll(tableName); Assert.assertEquals(sourceSelectAll, backupSelectAll); }</code><technical_language>path is "Closeable", freeing leak memory in test</technical_language>

Target:
public void simpleTableTest1() throws Exception { assertMemoryLeak(() -> { String tableName = "testTable1"; mainCompiler.compile("create table " + tableName + " as (select" + " rnd_symbol(4,4,4,2) sym," + " rnd_double(2) d," + " timestamp_sequence(0, 1000000000) ts" + " from long_sequence(10000)) timestamp(ts)", mainSqlExecutionContext); mainCompiler.compile("backup table " + tableName, mainSqlExecutionContext); setFinalBackupPath(); String sourceSelectAll = selectAll(tableName, false); String backupSelectAll = selectAll(tableName, true); Assert.assertEquals(sourceSelectAll, backupSelectAll); }); }
Source:
<code>private void showUpdates(ChangeInfo newInfo) { JsArray<MessageInfo> om = changeInfo.messages(); JsArray<MessageInfo> nm = newInfo.messages(); if (om == null) { om = JsArray.createArray().cast(); } if (nm == null) { nm = JsArray.createArray().cast(); } if (availableUpdate == null) { availableUpdate = new UpdatedBar() { @Override void onShow() { reload.reload(); } void onIgnore(Timestamp newTime) { <START> lastDisplayedUpdate = newTime; <END> } }; availableUpdate.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { availableUpdate = null; } }); } availableUpdate.set( Natives.asList(nm).subList(om.length(), nm.length()), newInfo.updated()); if (!availableUpdate.isShowing()) { availableUpdate.popup(); } }</code><technical_language>i expect ignore prevent future notifications too</technical_language>

Target:
void showUpdates(ChangeInfo newInfo) { if (!isAttached() || newInfo.updated().equals(lastDisplayedUpdate)) { return; } JsArray<MessageInfo> om = changeInfo.messages(); JsArray<MessageInfo> nm = newInfo.messages(); if (om == null) { om = JsArray.createArray().cast(); } if (nm == null) { nm = JsArray.createArray().cast(); } if (updateAvailable == null) { updateAvailable = new UpdateAvailableBar() { @Override void onShow() { reload.reload(); } void onIgnore(Timestamp newTime) { lastDisplayedUpdate = newTime; } }; updateAvailable.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { updateAvailable = null; } }); } updateAvailable.set( Natives.asList(nm).subList(om.length(), nm.length()), newInfo.updated()); if (!updateAvailable.isShowing()) { updateAvailable.popup(); } }