List of usage examples for java.util Collections synchronizedList
public static <T> List<T> synchronizedList(List<T> list)
From source file:org.kuali.rice.krad.util.MessageMap.java
public MessageMap(MessageMap messageMap) { this.errorPath = messageMap.errorPath; this.errorMessages = messageMap.errorMessages; this.warningMessages = messageMap.warningMessages; this.infoMessages = messageMap.infoMessages; growlMessages = Collections.synchronizedList(new AutoPopulatingList<GrowlMessage>(GrowlMessage.class)); }
From source file:org.apache.roller.weblogger.business.HitCountQueue.java
/** * Reset the queued hits.//from ww w .j a va 2 s . c o m */ public synchronized void resetHits() { this.queue = Collections.synchronizedList(new ArrayList()); }
From source file:org.minig.imap.impl.ClientSupport.java
public ClientSupport(IoHandler handler) { this.lock = new Semaphore(1); this.handler = handler; this.tagsProducer = new TagProducer(); this.lastResponses = Collections.synchronizedList(new LinkedList<IMAPResponse>()); }
From source file:org.openbel.framework.core.df.cache.DefaultCacheableResourceService.java
public DefaultCacheableResourceService() { final List<File> fl = sizedArrayList(128); tempResources = Collections.synchronizedList(fl); Runtime.getRuntime().addShutdownHook(new ResourceCleanupThread()); }
From source file:com.googlecode.fascinator.indexer.RuleManager.java
private File createTempFile(String prefix, String postfix) throws IOException { File tempFile = File.createTempFile(prefix, postfix, workDir); tempFile.deleteOnExit();//from w ww . ja va2s . c om if (tempFiles == null) { tempFiles = Collections.synchronizedList(new ArrayList<File>()); } tempFiles.add(tempFile); return tempFile; }
From source file:org.wso2.security.tools.reposcanner.repository.GitHubRepoInfoGenerator.java
@Override public List<Repo> getRepoList(String consoleTag, List<String> users) { RepositoryService repositoryService = new RepositoryService(client); List<Repo> repoList = Collections.synchronizedList(new ArrayList()); //Get the list of git repositories for each GitHub user account users.parallelStream().forEach(user -> { log.info(consoleTag + "Fetching repositories for GitHub user account: " + user); try {//w w w. ja v a2s . c o m List<Repository> userRepositoryList = repositoryService.getRepositories(user); log.info(consoleTag + userRepositoryList.size() + " repositories found for user account: " + user); //Download master branches only if download-master flag is enabled if (AppConfig.isDownloadMaster()) { userRepositoryList.parallelStream().forEach(repository -> { if (AppConfig.getGithubRepos() == null || AppConfig.getGithubRepos().contains(repository.getName())) { try { log.info(consoleTag + "[DownloadMaster] Started downloading master branch of: " + repository.getName()); Repo tempRepo = new Repo(RepoType.GIT, repository.getOwner().getLogin(), repository.getName(), repository.getCloneUrl(), null, null, null); gitMasterDownloader.downloadRepo(tempRepo, masterDownloadFolder, false); log.info(consoleTag + "[DownloadMaster] Completed downloading master branch of: " + repository.getName()); } catch (Exception e) { log.error(consoleTag + "Error in downloading master branch ZIP for GitHub user account: " + user + " repository: " + repository.getName(), e); } } else { log.info(consoleTag + "[DownloadMaster][Skipping] Skipping since the repo is not in include list : " + repository.getName()); } }); } //Do this only if scan should be done (skip skip-flag is not set) or skip-flag is set but tag download should happen if (!AppConfig.isSkipScan() || AppConfig.isDownloadTags()) { //Get the list of tags for each repository userRepositoryList.parallelStream().forEach(repository -> { if (AppConfig.getGithubRepos() == null || AppConfig.getGithubRepos().contains(repository.getName())) { log.info(consoleTag + "Fetching tags for GitHub user account: " + user + " repository: " + repository.getName()); try { List<RepositoryTag> repositoryTagLists = repositoryService.getTags(repository); log.info(consoleTag + repositoryTagLists.size() + " tags found for user account: " + user + " repository:" + repository.getName()); //Create persistable Repo object with repository and tag information repositoryTagLists.parallelStream().forEach(repositoryTag -> { Repo repo = new Repo(RepoType.GIT, repository.getOwner().getLogin(), repository.getName(), repository.getCloneUrl(), repositoryTag.getName(), repositoryTag.getZipballUrl(), new Date()); repoList.add(repo); //Download tags only if download-tag flag is enabled if (AppConfig.isDownloadTags()) { try { log.info(consoleTag + "[DownloadTags] Started downloading tag: " + repo.getTagName() + " of: " + repository.getName()); gitTagDownloader.downloadRepo(repo, tagsDownloadFolder, false); log.info(consoleTag + "[DownloadTags] Completed downloading tag: " + repo.getTagName() + " of: " + repository.getName()); } catch (Exception e) { log.error(consoleTag + "Error in downloading master branch ZIP for GitHub user account: " + user + " repository: " + repository.getName(), e); } } }); } catch (Exception e) { log.error(consoleTag + "Error in fetching tags for GitHub user account: " + user + " repository: " + repository.getName(), e); } } else { log.info(consoleTag + "[Skipping] Skipping since the repo is not in include list : " + repository.getName()); } }); } else { log.warn(consoleTag + "[Skipping] SkipScan parameter is set and tag download is not enabled. Skipping tag information retrieval."); } } catch (Exception e) { log.error("Error in fetching repositories for GitHub user account: " + user, e); } }); return repoList; }
From source file:org.piwik.sdk.TestDispatcher.java
@Test public void testSessionStartRaceCondition() throws Exception { for (int i = 0; i < 10; i++) { Log.d("RaceConditionTest", (10 - i) + " race-condition tests to go."); getPiwik().setDryRun(true);/* w w w .j a va2 s . c o m*/ final Tracker tracker = createTracker(); tracker.setDispatchInterval(0); final int threadCount = 10; final int queryCount = 3; final List<String> createdEvents = Collections.synchronizedList(new ArrayList<String>()); launchTestThreads(tracker, threadCount, queryCount, createdEvents); Thread.sleep(500); checkForMIAs(threadCount * queryCount, createdEvents, tracker.getDispatcher().getDryRunOutput()); List<String> output = getFlattenedQueries(tracker.getDispatcher().getDryRunOutput()); for (String out : output) { if (output.indexOf(out) == 0) { assertTrue(out.contains("lang")); assertTrue(out.contains("_idts")); assertTrue(out.contains("new_visit")); } else { assertFalse(out.contains("lang")); assertFalse(out.contains("_idts")); assertFalse(out.contains("new_visit")); } } } }
From source file:org.xmatthew.spy2servers.jmx.AbstractComponentViewMBean.java
protected TabularData tabularDataWrapFromMessages(List<Message> messages) throws OpenDataException { if (CollectionUtils.isBlankCollection(messages)) { return null; }// w w w .ja v a2 s . co m messages = Collections.synchronizedList(messages); String[] itemNames = Message.getKeys().toArray(new String[Message.getKeys().size()]); String[] itemDescriptions = itemNames; OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING }; CompositeType compositeType = new CompositeType("MessageList", "list spyed messages", itemNames, itemDescriptions, itemTypes); TabularType tt = new TabularType("MessageList", "MessageList", compositeType, itemNames); TabularDataSupport rc = new TabularDataSupport(tt); for (Message message : messages) { try { rc.put(new CompositeDataSupport(compositeType, message.getFileds())); } catch (Exception e) { throw new OpenDataException(e.getMessage()); } } return rc; }
From source file:se.bitcraze.crazyflielib.bootloader.Bootloader.java
/** * Init the communication class by starting to communicate with the * link given. clink is the link address used after resetting to the * bootloader./*from w w w .jav a 2 s .c o m*/ * * The device is actually considered in firmware mode. */ public Bootloader(CrtpDriver driver) { this.mCload = new Cloader(driver); this.mBootloaderListeners = Collections.synchronizedList(new LinkedList<BootloaderListener>()); mMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); }