Search in sources :

Example 11 with CanIgnoreReturnValue

use of com.google.errorprone.annotations.CanIgnoreReturnValue in project guava by google.

the class ConfigurableMutableNetwork method removeNode.

@Override
@CanIgnoreReturnValue
public boolean removeNode(Object node) {
    checkNotNull(node, "node");
    NetworkConnections<N, E> connections = nodeConnections.get(node);
    if (connections == null) {
        return false;
    }
    // Thus we avoid modifying the underlying view while iterating over it.
    for (E edge : ImmutableList.copyOf(connections.incidentEdges())) {
        removeEdge(edge);
    }
    nodeConnections.remove(node);
    return true;
}
Also used : REUSING_EDGE(com.google.common.graph.GraphConstants.REUSING_EDGE) CanIgnoreReturnValue(com.google.errorprone.annotations.CanIgnoreReturnValue)

Example 12 with CanIgnoreReturnValue

use of com.google.errorprone.annotations.CanIgnoreReturnValue in project guava by google.

the class ServiceManager method startAsync.

/**
   * Initiates service {@linkplain Service#startAsync startup} on all the services being managed. It
   * is only valid to call this method if all of the services are {@linkplain State#NEW new}.
   *
   * @return this
   * @throws IllegalStateException if any of the Services are not {@link State#NEW new} when the
   *     method is called.
   */
@CanIgnoreReturnValue
public ServiceManager startAsync() {
    for (Service service : services) {
        State state = service.state();
        checkState(state == NEW, "Service %s is %s, cannot start it.", service, state);
    }
    for (Service service : services) {
        try {
            state.tryStartTiming(service);
            service.startAsync();
        } catch (IllegalStateException e) {
            // This can happen if the service has already been started or stopped (e.g. by another
            // service or listener). Our contract says it is safe to call this method if
            // all services were NEW when it was called, and this has already been verified above, so we
            // don't propagate the exception.
            logger.log(Level.WARNING, "Unable to start Service " + service, e);
        }
    }
    return this;
}
Also used : Preconditions.checkState(com.google.common.base.Preconditions.checkState) State(com.google.common.util.concurrent.Service.State) CanIgnoreReturnValue(com.google.errorprone.annotations.CanIgnoreReturnValue)

Example 13 with CanIgnoreReturnValue

use of com.google.errorprone.annotations.CanIgnoreReturnValue in project grpc-java by grpc.

the class NettyHandlerTestBase method enqueue.

@CanIgnoreReturnValue
protected final ChannelFuture enqueue(WriteQueue.QueuedCommand command) {
    ChannelFuture future = writeQueue.enqueue(command, newPromise(), true);
    channel.runPendingTasks();
    return future;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) CanIgnoreReturnValue(com.google.errorprone.annotations.CanIgnoreReturnValue)

Example 14 with CanIgnoreReturnValue

use of com.google.errorprone.annotations.CanIgnoreReturnValue in project core-java by SpineEventEngine.

the class StandShould method doCheckReadingCustomersById.

@CanIgnoreReturnValue
Stand doCheckReadingCustomersById(int numberOfCustomers) {
    // Define the types and values used as a test data.
    final TypeUrl customerType = TypeUrl.of(Customer.class);
    final Map<CustomerId, Customer> sampleCustomers = fillSampleCustomers(numberOfCustomers);
    // Prepare the stand and its storage to act.
    final StandStorage standStorage = setupStandStorageWithCustomers(sampleCustomers, customerType);
    final Stand stand = prepareStandWithAggregateRepo(standStorage);
    triggerMultipleUpdates(sampleCustomers, stand);
    final Query readMultipleCustomers = requestFactory.query().byIds(Customer.class, sampleCustomers.keySet());
    final MemoizeQueryResponseObserver responseObserver = new MemoizeQueryResponseObserver();
    stand.execute(readMultipleCustomers, responseObserver);
    final List<Any> messageList = checkAndGetMessageList(responseObserver);
    assertEquals(sampleCustomers.size(), messageList.size());
    final Collection<Customer> allCustomers = sampleCustomers.values();
    for (Any singleRecord : messageList) {
        final Customer unpackedSingleResult = AnyPacker.unpack(singleRecord);
        assertTrue(allCustomers.contains(unpackedSingleResult));
    }
    return stand;
}
Also used : Query(io.spine.client.Query) Customer(io.spine.test.commandservice.customer.Customer) StandStorage(io.spine.server.stand.StandStorage) TypeUrl(io.spine.type.TypeUrl) CustomerId(io.spine.test.commandservice.customer.CustomerId) Any(com.google.protobuf.Any) CanIgnoreReturnValue(com.google.errorprone.annotations.CanIgnoreReturnValue)

Example 15 with CanIgnoreReturnValue

use of com.google.errorprone.annotations.CanIgnoreReturnValue in project core-java by SpineEventEngine.

the class StandShould method subscribeAndActivate.

@CanIgnoreReturnValue
protected static Subscription subscribeAndActivate(Stand stand, Topic topic, Stand.EntityUpdateCallback callback) {
    final MemoizingObserver<Subscription> observer = memoizingObserver();
    stand.subscribe(topic, observer);
    final Subscription subscription = observer.firstResponse();
    stand.activate(subscription, callback, StreamObservers.<Response>noOpObserver());
    assertNotNull(subscription);
    return subscription;
}
Also used : Subscription(io.spine.client.Subscription) CanIgnoreReturnValue(com.google.errorprone.annotations.CanIgnoreReturnValue)

Aggregations

CanIgnoreReturnValue (com.google.errorprone.annotations.CanIgnoreReturnValue)25 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 BufferedInputStream (java.io.BufferedInputStream)3 BufferedReader (java.io.BufferedReader)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 Reader (java.io.Reader)3 Beta (com.google.common.annotations.Beta)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 State (com.google.common.util.concurrent.Service.State)2 OutputStream (java.io.OutputStream)2 Writer (java.io.Writer)2 CharBuffer (java.nio.CharBuffer)2 CancellationException (java.util.concurrent.CancellationException)2 GwtIncompatible (com.google.common.annotations.GwtIncompatible)1 REUSING_EDGE (com.google.common.graph.GraphConstants.REUSING_EDGE)1 Any (com.google.protobuf.Any)1 ChannelFuture (io.netty.channel.ChannelFuture)1 Query (io.spine.client.Query)1 Subscription (io.spine.client.Subscription)1