Search in sources :

Example 66 with ConcurrentModificationException

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());
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) Bitmap(android.graphics.Bitmap) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 67 with ConcurrentModificationException

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);
}
Also used : ISSTableScanner(org.apache.cassandra.io.sstable.ISSTableScanner) ConcurrentModificationException(java.util.ConcurrentModificationException) ArrayList(java.util.ArrayList) GroupedSSTableContainer(org.apache.cassandra.db.compaction.AbstractStrategyHolder.GroupedSSTableContainer)

Example 68 with ConcurrentModificationException

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();
                }
            }
        }
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) ViewPairRequestBinding(org.kde.kdeconnect_tp.databinding.ViewPairRequestBinding) PluginListHeaderItem(org.kde.kdeconnect.UserInterface.List.PluginListHeaderItem) Intent(android.content.Intent) ViewPairErrorBinding(org.kde.kdeconnect_tp.databinding.ViewPairErrorBinding) Device(org.kde.kdeconnect.Device) FailedPluginListItem(org.kde.kdeconnect.UserInterface.List.FailedPluginListItem) R(org.kde.kdeconnect_tp.R) ArrayList(java.util.ArrayList) PluginItem(org.kde.kdeconnect.UserInterface.List.PluginItem) ActivityDeviceBinding(org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding) Menu(android.view.Menu) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Plugin(org.kde.kdeconnect.Plugins.Plugin) Log(android.util.Log) BatteryPlugin(org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin) DeviceBatteryInfo(org.kde.kdeconnect.Plugins.BatteryPlugin.DeviceBatteryInfo) LayoutInflater(android.view.LayoutInflater) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SslHelper(org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper) ViewGroup(android.view.ViewGroup) BackgroundService(org.kde.kdeconnect.BackgroundService) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) ListAdapter(org.kde.kdeconnect.UserInterface.List.ListAdapter) ConcurrentModificationException(java.util.ConcurrentModificationException) DialogFragment(androidx.fragment.app.DialogFragment) ConcurrentModificationException(java.util.ConcurrentModificationException) ArrayList(java.util.ArrayList) DialogFragment(androidx.fragment.app.DialogFragment) Collection(java.util.Collection) PluginItem(org.kde.kdeconnect.UserInterface.List.PluginItem) ListAdapter(org.kde.kdeconnect.UserInterface.List.ListAdapter) Plugin(org.kde.kdeconnect.Plugins.Plugin) BatteryPlugin(org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin)

Example 69 with ConcurrentModificationException

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;
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException)

Example 70 with ConcurrentModificationException

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;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException)

Aggregations

ConcurrentModificationException (java.util.ConcurrentModificationException)206 Iterator (java.util.Iterator)34 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)24 HashSet (java.util.HashSet)23 Map (java.util.Map)19 Set (java.util.Set)19 Test (org.junit.Test)19 ResultSet (java.sql.ResultSet)16 HashMap (java.util.HashMap)13 NoSuchElementException (java.util.NoSuchElementException)13 List (java.util.List)10 Collection (java.util.Collection)9 GameLocal (org.apache.openejb.test.entity.cmr.manytomany.GameLocal)8 PlatformLocal (org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 AbstractList (java.util.AbstractList)6 LinkedList (java.util.LinkedList)6 ArtistLocal (org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal)6 SongLocal (org.apache.openejb.test.entity.cmr.onetomany.SongLocal)6