/**
   * Checks entry for empty value.
   *
   * @param entry Entry to check.
   * @return {@code True} if entry is empty.
   */
  private boolean empty(GridCacheEntry<K, V> entry) {
    try {
      return entry.peek(F.asList(GLOBAL)) == null;
    } catch (GridException e) {
      U.error(null, e.getMessage(), e);

      assert false : "Should never happen: " + e;

      return false;
    }
  }
  /**
   * Reconstructs object on demarshalling.
   *
   * @return Reconstructed object.
   * @throws ObjectStreamException Thrown in case of demarshalling error.
   */
  @SuppressWarnings("unchecked")
  private Object readResolve() throws ObjectStreamException {
    try {
      GridBiTuple<GridCacheContext, String> t = stash.get();

      return t.get1().dataStructures().atomicReference(t.get2(), null, false);
    } catch (GridException e) {
      throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
      stash.remove();
    }
  }
Пример #3
0
  /**
   * Checks that the given grid configuration will lead to {@link GridException} upon grid startup.
   *
   * @param cfg Grid configuration to check.
   * @param excMsgSnippet Root cause (assertion) exception message snippet.
   * @param testLoc {@code True} if checking is done for "testLocal" tests.
   */
  private void checkGridStartFails(
      GridConfiguration cfg, CharSequence excMsgSnippet, boolean testLoc) {
    assertNotNull(cfg);
    assertNotNull(excMsgSnippet);

    try {
      G.start(cfg);

      fail("No exception has been thrown.");
    } catch (GridException e) {
      if (testLoc) {
        if ("Failed to start processor: GridProcessorAdapter []".equals(e.getMessage())
            && e.getCause().getMessage().contains(excMsgSnippet)) return; // Expected exception.
      } else if (e.getMessage().contains(excMsgSnippet)) return; // Expected exception.

      error("Caught unexpected exception.", e);

      fail();
    }
  }