Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix minor issues
  • Loading branch information
tonytanger committed Nov 13, 2019
commit 2a0c7838c4116604557b7cb5a09f9eb961548d44
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.google.auth.Credentials;
import com.google.auth.oauth2.ComputeEngineCredentials;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
Expand Down Expand Up @@ -519,10 +520,10 @@ public int getPoolSize() {
*/
public Builder setPoolSize(int poolSize) {
Preconditions.checkArgument(poolSize > 0, "Pool size must be positive");
if (poolSize > MAX_POOL_SIZE) {
poolSize = MAX_POOL_SIZE;
}
this.poolSize = poolSize;
if (this.poolSize > MAX_POOL_SIZE) {
this.poolSize = MAX_POOL_SIZE;
}
Comment thread
tonytanger marked this conversation as resolved.
Outdated
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.grpc.ManagedChannel;
import io.grpc.MethodDescriptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
Expand All @@ -63,20 +64,19 @@ public void testAuthority() throws IOException {

Mockito.when(sub1.authority()).thenReturn("myAuth");

ChannelPool pool =
new ChannelPool(2, new FakeChannelFactory(Lists.newArrayList(sub1, sub2)), null);
ChannelPool pool = new ChannelPool(2, new FakeChannelFactory(Arrays.asList(sub1, sub2)), null);
Truth.assertThat(pool.authority()).isEqualTo("myAuth");
}

@Test
public void testRoundRobin() throws IOException {
ManagedChannel sub1 = Mockito.mock(ManagedChannel.class);
ManagedChannel sub2 = Mockito.mock(ManagedChannel.class);
final List<ManagedChannel> channels = Lists.newArrayList(sub1, sub2);

Mockito.when(sub1.authority()).thenReturn("myAuth");

ChannelPool pool = new ChannelPool(2, new FakeChannelFactory(channels), null);
ArrayList<ManagedChannel> channels = Lists.newArrayList(sub1, sub2);
ChannelPool pool = new ChannelPool(2, new FakeChannelFactory(Arrays.asList(sub1, sub2)), null);

verifyTargetChannel(pool, channels, sub1);
verifyTargetChannel(pool, channels, sub2);
Expand Down