using Eclipse Luna I am trying to run a java code which imports deprecated google-collections, which is throwing an exception when compiled with latest Guava version.
public static void run(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException
{
BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);
StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
endpoint.trackTerms(Lists.newArrayList("twitterapi", "#AAPSweep"));
Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);
Client client = new ClientBuilder()
.hosts(Constants.STREAM_HOST)
.endpoint(endpoint)
.authentication(auth)
.processor(new StringDelimitedProcessor(queue))
.build();
client.connect();
I have tried to remove com.google.guava_15.0.0.v201403281430 file from plugins and tried to paste Guava old version as told here in a comment but i am unable to install(point) towards old guava version. Also there could be another solution for this problem here but I am new to java and dont know how to replace that List with other one.
Please is there any one can run that code using other List method ? OR Tell me how to add older version of Guava in eclipse (I am not sure that would solve that problem just read it from a thread) OR Tell me other solution. Thank you
The Guava Lists.newArrayList
is just a short-hand to create a standard JDK ArrayList
and fill it with predefined values. You can do this in a little longer way without any third-party library using Arrays.asList
:
endpoint.trackTerms(new ArrayList<>(Arrays.asList("twitterapi", "#AAPSweep")));
Or even simpler if you don't need the structural changes in the created list:
endpoint.trackTerms(Arrays.asList("twitterapi", "#AAPSweep"));