Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #104 from twitter/stop-using-deprecated-guava-method
Browse files Browse the repository at this point in the history
Stop using deprecated guava method
  • Loading branch information
xsl committed Mar 19, 2014
2 parents 2a2c481 + 5c1c4dc commit 0732ac3
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BasicRateTracker implements RateTracker {
private final RateUpdater rateUpdater;

private ScheduledFuture<?> future;
private ScheduledExecutorService executor;
private final ScheduledExecutorService executor;

public BasicRateTracker(int granularityMillis, int numBuckets, boolean startPaused, ScheduledExecutorService executor) {
Preconditions.checkArgument(numBuckets > 0);
Expand Down
4 changes: 2 additions & 2 deletions hbc-core/src/main/java/com/twitter/hbc/ClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
*/
public class ClientBuilder {

private static AtomicInteger clientNum = new AtomicInteger(0);
private static final AtomicInteger clientNum = new AtomicInteger(0);
protected Authentication auth;
protected Hosts hosts;
protected HosebirdMessageProcessor processor;
protected StreamingEndpoint endpoint;
protected boolean enableGZip;
protected String name;
protected RateTracker rateTracker;
protected ExecutorService executorService;
protected final ExecutorService executorService;
protected BlockingQueue<Event> eventQueue;
protected ReconnectionManager reconnectionManager;
protected int socketTimeoutMillis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class SitestreamEndpoint extends UserstreamEndpoint {

public static String PATH = "/site.json";
public static final String PATH = "/site.json";

public SitestreamEndpoint() {
super(PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class UserstreamEndpoint extends DefaultStreamingEndpoint {

public static String PATH = "/user.json";
public static final String PATH = "/user.json";

public UserstreamEndpoint() {
this(PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@
import com.twitter.hbc.core.event.Event;
import com.twitter.hbc.core.processor.HosebirdMessageProcessor;
import com.twitter.hbc.httpclient.auth.Authentication;
import org.apache.http.HttpException;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Connection {
private HttpUriRequest request;
private InputStream stream;

private HosebirdMessageProcessor processor;
private final HosebirdMessageProcessor processor;

public Connection(HttpClient client, HosebirdMessageProcessor processor) {
this.client = Preconditions.checkNotNull(client);
Expand Down Expand Up @@ -60,6 +60,10 @@ public void close() {
// restart the entire client
((RestartableHttpClient) client).restart();
}
Closeables.closeQuietly(this.stream);
try {
Closeables.close(this.stream, true);
} catch (IOException e) {
throw new RuntimeException(e); // should never happen
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;

public class SitestreamControllerTest {
Expand All @@ -50,7 +49,6 @@ public class SitestreamControllerTest {
private HttpResponse mockResponse;
private StatusLine mockStatusLine;
private HttpEntity mockEntity;
private InputStream mockContent = mock(InputStream.class);

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.io.InputStream;

import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.*;

public class DelimitedStreamReaderTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class BasicClientTest {

private ClientConnectionManager mockConnectionManager;

private ExecutorService executorService;
private final ExecutorService executorService;

public BasicClientTest() {
ThreadFactory threadFactory = new ThreadFactoryBuilder()
Expand Down

0 comments on commit 0732ac3

Please sign in to comment.