Skip to content

WARNING: A connection to https://gateway-a.watsonplatform.net/ was leaked #242

@dselman

Description

@dselman

I am seeing this WARNING when using the Alchemy sentiment service:

WARNING ] A connection to https://gateway-a.watsonplatform.net/ was leaked. Did you forget to close a response body?
(Which seems to be related to: square/okhttp#2158)

My code:

import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;
import com.ibm.watson.developer_cloud.alchemy.v1.model.DocumentSentiment;
AlchemyLanguage service = new AlchemyLanguage();
String apiKey = this.getSolutionProperty("WatsonSentimentAnalyzer_apiKey");

service.setApiKey(apiKey);

Map<String,Object> params = new HashMap<String, Object>();
params.put(AlchemyLanguage.TEXT, request.getText());
DocumentSentiment docSentiment =  service.getSentiment(params);
response.setSentiment(docSentiment.getSentiment().getScore());
long end = System.currentTimeMillis();

System.out.println( "*** Sentiment for " + request.getText() 
                    + " is: " + response.getSentiment() + " took: " + (end-start) + " ms." );

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions