use of java.util.ConcurrentModificationException in project fresco by facebook.
the class KitKatPurgeableDecoderTest method testPinBitmapFailure.
@Test(expected = ConcurrentModificationException.class)
public void testPinBitmapFailure() {
KitKatPurgeableDecoder decoder = spy(mKitKatPurgeableDecoder);
doThrow(new ConcurrentModificationException()).when(decoder).pinBitmap((Bitmap) anyObject());
decoder.pinBitmap(any(Bitmap.class));
try {
decoder.decodeFromEncodedImage(mEncodedImage, DEFAULT_BITMAP_CONFIG, null);
} finally {
verify(mBitmap).recycle();
assertEquals(0, mBitmapCounter.getCount());
assertEquals(0, mBitmapCounter.getSize());
}
}
use of java.util.ConcurrentModificationException in project cassandra by apache.
the class CompactionStrategyManager method maybeGetScanners.
/**
* Create ISSTableScanners from the given sstables
*
* Delegates the call to the compaction strategies to allow LCS to create a scanner
* @param sstables
* @param ranges
* @return
*/
@SuppressWarnings("resource")
public AbstractCompactionStrategy.ScannerList maybeGetScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges) {
maybeReloadDiskBoundaries();
List<ISSTableScanner> scanners = new ArrayList<>(sstables.size());
readLock.lock();
try {
List<GroupedSSTableContainer> sstableGroups = groupSSTables(sstables);
for (int i = 0; i < holders.size(); i++) {
AbstractStrategyHolder holder = holders.get(i);
GroupedSSTableContainer group = sstableGroups.get(i);
scanners.addAll(holder.getScanners(group, ranges));
}
} catch (PendingRepairManager.IllegalSSTableArgumentException e) {
ISSTableScanner.closeAllAndPropagate(scanners, new ConcurrentModificationException(e));
} finally {
readLock.unlock();
}
return new AbstractCompactionStrategy.ScannerList(scanners);
}
use of java.util.ConcurrentModificationException in project kdeconnect-android by KDE.
the class DeviceFragment method refreshUI.
private void refreshUI() {
if (device == null || binding == null) {
return;
}
// Once in-app, there is no point in keep displaying the notification if any
device.hidePairingNotification();
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (device.isPairRequestedByPeer()) {
binding.pairMessage.setText(R.string.pair_requested);
binding.pairVerification.setVisibility(View.VISIBLE);
binding.pairVerification.setText(SslHelper.getVerificationKey(SslHelper.certificate, device.certificate));
binding.pairingButtons.setVisibility(View.VISIBLE);
binding.pairProgress.setVisibility(View.GONE);
binding.pairButton.setVisibility(View.GONE);
binding.pairRequestButtons.setVisibility(View.VISIBLE);
} else {
boolean paired = device.isPaired();
boolean reachable = device.isReachable();
binding.pairingButtons.setVisibility(paired ? View.GONE : View.VISIBLE);
errorBinding.errorMessageContainer.setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
errorBinding.notReachableMessage.setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
deviceBinding.viewStatusContainer.setVisibility((paired && reachable) ? View.VISIBLE : View.GONE);
try {
pluginListItems = new ArrayList<>();
if (paired && reachable) {
// Plugins button list
final Collection<Plugin> plugins = device.getLoadedPlugins().values();
for (final Plugin p : plugins) {
if (!p.hasMainActivity())
continue;
if (p.displayInContextMenu())
continue;
pluginListItems.add(new PluginItem(p, v -> p.startMainActivity(mActivity)));
}
DeviceFragment.this.createPluginsList(device.getPluginsWithoutPermissions(), R.string.plugins_need_permission, (plugin) -> {
DialogFragment dialog = plugin.getPermissionExplanationDialog();
if (dialog != null) {
dialog.show(getChildFragmentManager(), null);
}
});
DeviceFragment.this.createPluginsList(device.getPluginsWithoutOptionalPermissions(), R.string.plugins_need_optional_permission, (plugin) -> {
DialogFragment dialog = plugin.getOptionalPermissionExplanationDialog();
if (dialog != null) {
dialog.show(getChildFragmentManager(), null);
}
});
DeviceFragment.this.displayBatteryInfoIfPossible();
}
ListAdapter adapter = new ListAdapter(mActivity, pluginListItems);
deviceBinding.buttonsList.setAdapter(adapter);
mActivity.invalidateOptionsMenu();
} catch (IllegalStateException e) {
// Ignore: The activity was closed while we were trying to update it
} catch (ConcurrentModificationException e) {
Log.e(TAG, "ConcurrentModificationException");
// Try again
this.run();
}
}
}
});
}
use of java.util.ConcurrentModificationException in project ThinkAndroid by white-cat.
the class ArrayDeque method delete.
/**
* Removes the element at the specified position in the elements array,
* adjusting head and tail as necessary. This can result in motion of
* elements backwards or forwards in the array.
*
* <p>
* This method is called delete rather than remove to emphasize that its
* semantics differ from those of {@link List#remove(int)}.
*
* @return true if elements moved backwards
*/
private boolean delete(int i) {
checkInvariants();
final E[] elements = this.elements;
final int mask = elements.length - 1;
final int h = head;
final int t = tail;
final int front = (i - h) & mask;
final int back = (t - i) & mask;
// Invariant: head <= i < tail mod circularity
if (front >= ((t - h) & mask))
throw new ConcurrentModificationException();
// Optimize for least element motion
if (front < back) {
if (h <= i) {
System.arraycopy(elements, h, elements, h + 1, front);
} else {
// Wrap around
System.arraycopy(elements, 0, elements, 1, i);
elements[0] = elements[mask];
System.arraycopy(elements, h, elements, h + 1, mask - h);
}
elements[h] = null;
head = (h + 1) & mask;
return false;
} else {
if (i < t) {
// Copy the null tail as well
System.arraycopy(elements, i + 1, elements, i, back);
tail = t - 1;
} else {
// Wrap around
System.arraycopy(elements, i + 1, elements, i, mask - i);
elements[mask] = elements[0];
System.arraycopy(elements, 1, elements, 0, t);
tail = (t - 1) & mask;
}
return true;
}
}
use of java.util.ConcurrentModificationException in project zuul by Netflix.
the class CountingCurrentPassport method lock.
private Unlocker lock() {
boolean locked = false;
if ((historyLock.isLocked() && !historyLock.isHeldByCurrentThread()) || !(locked = historyLock.tryLock())) {
Thread owner = historyLock.getOwner();
String ownerStack = String.valueOf(owner != null ? Arrays.asList(owner.getStackTrace()) : historyLock);
logger.warn("CurrentPassport already locked!, other={}, self={}", ownerStack, Thread.currentThread(), new ConcurrentModificationException());
}
if (!locked) {
historyLock.lock();
}
return unlocker;
}
Aggregations