private void checkForConcurrentModification() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } } };
public void run() { while (running) { try { handleIO(); } catch (IOException e) { if (log.isDebugEnabled()) log.debug(e.getMessage(), e); } catch (CancelledKeyException e) { if (log.isDebugEnabled()) log.debug(e.getMessage(), e); } catch (ClosedSelectorException e) { if (log.isDebugEnabled()) log.debug(e.getMessage(), e); } catch (IllegalStateException e) { if (log.isDebugEnabled()) log.debug(e.getMessage(), e); } catch (ConcurrentModificationException e) { if (log.isDebugEnabled()) log.debug(e.getMessage(), e); } catch (Throwable e) { log.error("SEVERE EVCACHE ISSUE.", e);// This ensures the thread // doesn't die } } if (log.isDebugEnabled()) log.debug(toString() + " : Shutdown"); }
@Override public void forEachRemaining(@Nonnull Consumer<? super Map.Entry<Double, Double>> action) { if (action == null) throw new java.lang.NullPointerException(); long[] tab = this.tab; int nextI = nextIndex; for (int i = nextI; i >= 0; i -= 2) { long key; if ((key = tab[i]) < FREE_BITS) { action.accept(new ImmutableEntry(key, tab[i + 1])); } } if (nextI != nextIndex) { throw new java.util.ConcurrentModificationException(); } nextIndex = -1; }
@Override public void forEachRemaining(Consumer<? super Double> action) { if (action == null) throw new java.lang.NullPointerException(); long[] tab = this.tab; int nextI = nextIndex; for (int i = nextI; i >= 0; i -= 2) { if (tab[i] < FREE_BITS) { action.accept(Double.longBitsToDouble(tab[i + 1])); } } if (nextI != nextIndex) { throw new java.util.ConcurrentModificationException(); } nextIndex = -1; }
@Override public void forEachForward(@Nonnull IntConsumer intConsumer) { int localNumElements = numElements; for (int i = index; i < localNumElements; ++i) { intConsumer.accept(backingArray[i]); } if(localNumElements != numElements) { throw new ConcurrentModificationException(); } else { this.index = numElements; } }
@Override public void setValue(int value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putInt(tab, LONG_BASE + INT_VALUE_OFFSET + (((long) (index)) << LONG_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(char value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putChar(tab, INT_BASE + CHAR_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(short value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putShort(tab, INT_BASE + SHORT_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(byte value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putByte(tab, CHAR_BASE + BYTE_VALUE_OFFSET + (((long) (index)) << CHAR_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
private static <E> E getNodeItem(Object node) { if (node == null) { throw new ConcurrentModificationException(); } return (E) U.getObject(node, NODE_ITEM_OFF); }
/** * http://code.google.com/p/jodd/issues/detail?id=4 */ @Test void testPutGetAndPrune() throws InterruptedException { LFUCache<String, String> lfuCache = new LFUCache<>(2, 0); lfuCache.put("1", "value"); assertFalse(lfuCache.isFull()); lfuCache.put("2", "value"); assertTrue(lfuCache.isFull()); lfuCache.get("2"); lfuCache.get("2"); assertEquals(2, lfuCache.size()); Semaphore semaphore = new Semaphore(2); Thread1 t1 = new Thread1(semaphore, lfuCache); Thread2 t2 = new Thread2(semaphore, lfuCache); t1.start(); t2.start(); semaphore.acquire(); if (t1.exception != null) { t1.exception.printStackTrace(); } assertNull(t1.exception); if (t2.exception != null) { t2.exception.printStackTrace(); } assertNull(t2.exception); }
@Override public void forEachRemaining(@Nonnull Consumer<? super Map.Entry<Double, Double>> action) { if (action == null) throw new java.lang.NullPointerException(); long[] tab = this.tab; int nextI = nextIndex; for (int i = nextI; i >= 0; i -= 2) { long key; if ((key = tab[i]) < FREE_BITS) { action.accept(new ImmutableEntry(key, tab[i + 1])); } } if (nextI != nextIndex) { throw new java.util.ConcurrentModificationException(); } nextIndex = -1; }
@Override public void forEachRemaining(Consumer<? super Double> action) { if (action == null) throw new java.lang.NullPointerException(); long[] tab = this.tab; int nextI = nextIndex; for (int i = nextI; i >= 0; i -= 2) { if (tab[i] < FREE_BITS) { action.accept(Double.longBitsToDouble(tab[i + 1])); } } if (nextI != nextIndex) { throw new java.util.ConcurrentModificationException(); } nextIndex = -1; }
@Override public void forEachRemaining(@Nonnull IntConsumer intConsumer) { int localNumElements = numElements; for (int i = index + 1; i < localNumElements - 1; ++i) { intConsumer.accept(backingArray[i]); } if (localNumElements != numElements) { throw new ConcurrentModificationException(); } else { index = numElements - 1; } }
@Override public void setValue(float value) { if (curKey != FREE_BITS) { if (expectedModCount == modCount()) { U.putInt(tab, LONG_BASE + FLOAT_VALUE_OFFSET + (((long) (index)) << LONG_SCALE_SHIFT), Float.floatToIntBits(value)); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(char value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putChar(tab, INT_BASE + CHAR_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(short value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putShort(tab, INT_BASE + SHORT_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
@Override public void setValue(byte value) { if (curKey != free) { if (expectedModCount == modCount()) { U.putByte(tab, CHAR_BASE + BYTE_VALUE_OFFSET + (((long) (index)) << CHAR_SCALE_SHIFT), value); } else { throw new java.util.ConcurrentModificationException(); } } else { throw new java.lang.IllegalStateException(); } }
private static Object getNextNode(Object node) { if (node == null) { throw new ConcurrentModificationException(); } return U.getObject(node, NODE_NEXT_OFF); }
public void traceErrors() { try { for (ErrorRecord er : errors) { System.out.println("Error: " + er); } } catch (ConcurrentModificationException e) { e.printStackTrace(); } }