public R get(final T input) { return delegate.get(input); } }
@Override public void apply(final V v) { operation.get(secondaryAttachmentStore); } }
public R apply(final T from) { return delegate.get(from); }; }
public T get() { return function.get(input); } };
public R runOperation(final K key, final Callable<R> operation) throws ExecutionException { CallerRunsFuture<R> future = map.get(key); while (future == null) { map.putIfAbsent(key, futureFactory.get(operation)); future = map.get(key); } try { return future.get(); } finally { map.remove(key, future); } }
@Override public <A> Promise<A> getAttachment(final AttachmentKey attachmentKey, final Function<InputStream, A> inputStreamProcessor) { //This was previously calling provided stream processor with null, changed it to provide empty stream to avoid NPE return Promises.promise(inputStreamProcessor.get(new ByteArrayInputStream(new byte[0]))); }
@Override public A get(final AttachmentGetData attachmentGetData) { return inputStreamProcessor.get(attachmentGetData.getInputStream()); } });
public ManagedLock.ReadWrite get(final T input) { return locks.get(stripeFunction.get(input)); }; };
@Override public <V> Promise<V> perform(final Function<StreamAttachmentStore, Promise<V>> operation) { return operation.get(primaryAttachmentStore).done( new Effect<V>() { @Override public void apply(final V v) { operation.get(secondaryAttachmentStore); } } ); } }
@SuppressWarnings("unchecked") protected <K, V> ManagedCache createComputingCache(@Nonnull final String name, @Nonnull final CacheSettings settings, final CacheLoader<K, V> loader) { return cacheCreationLocks.get(name).withLock(new com.atlassian.util.concurrent.Supplier<ManagedCache>() { @Override public ManagedCache get() { Ehcache spCache = getLoadingCache(name, settings, new ValueProcessorAtlassianCacheLoaderDecorator(loader, valueProcessor)); DelegatingCache<K,V> cache = DelegatingCache.create(spCache, settings, valueProcessor); caches.put(name, new WeakSupplier<ManagedCache>(cache)); return cache; } }); }
@Override public <A> Promise<A> getAttachmentData(final AttachmentKey attachmentKey, final Function<AttachmentGetData, A> attachmentGetDataProcessor) { final AttachmentGetData attachmentGetData = new AttachmentStreamGetData(new ByteArrayInputStream(new byte[0]), 0); return Promises.promise(attachmentGetDataProcessor.get(attachmentGetData)); }
@Nonnull @Override public <V> CachedReference<V> getCachedReference(@Nonnull final String name, @Nonnull final Supplier<V> supplier, @Nonnull final CacheSettings settings) { checkSettingsAreCompatible(name, settings); return cacheCreationLocks.get(name).withLock(new com.atlassian.util.concurrent.Supplier<CachedReference<V>>() { @Override public CachedReference<V> get() { caches.put(name, new WeakSupplier<ManagedCache>((ManagedCache) doCreateCachedReference(name, supplier, settings))); //noinspection unchecked return (CachedReference<V>) caches.get(name).get(); } }); }
private List<UserHistoryItem> removeAnonymousSession(final VelocityRequestSession session, final UserHistoryItem.Type type) { final String sessionKey = getSessionKeyForType(type); return lockManager.get(session).withLock(new Supplier<List<UserHistoryItem>>() { public List<UserHistoryItem> get() { @SuppressWarnings("unchecked") final List<UserHistoryItem> sessionHistory = (List<UserHistoryItem>) session.getAttribute(sessionKey); if (sessionHistory != null && !sessionHistory.isEmpty()) { session.removeAttribute(sessionKey); } return sessionHistory; } }); }
public void addHistoryItem(final ApplicationUser user, @Nonnull final UserHistoryItem historyItem) { notNull("user", user); notNull("historyItem", historyItem); final AddHistoryResult result = lockManager.get(user).withLock(new Supplier<AddHistoryResult>() { public AddHistoryResult get() { return addCachedHistoryItem(user, historyItem); } }); // JRADEV-15768 // Don't call the delegatingStore while the lock is held! Was causing deadlock between DB and JIRA. executor.get().submit(new UserHistoryWriter(result, user, historyItem)); }
private List<UserHistoryItem> getAnonymousSessionHistory(final VelocityRequestSession session, UserHistoryItem.Type type) { final String sessionKey = getSessionKeyForType(type); return lockManager.get(session).withLock(new Supplier<List<UserHistoryItem>>() { public List<UserHistoryItem> get() { @SuppressWarnings("unchecked") final List<UserHistoryItem> sessionHistory = (List<UserHistoryItem>) session.getAttribute(sessionKey); if (sessionHistory == null) { return Collections.emptyList(); } // Don't allow our not-thread-safe, mutable list to escape! return ImmutableList.copyOf(sessionHistory); } }); }
@Override public A call() { final AttachmentFileGetData attachmentGetData = new AttachmentFileGetData(attachmentFile); try { return attachmentGetDataProcessor.get(attachmentGetData); } catch (final RuntimeException e) { throw new AttachmentReadException(e); } finally { attachmentGetData.close(); } } });