Skip to content

Commit

Permalink
added override close method in httpProjectConfigManager to avoid memo…
Browse files Browse the repository at this point in the history
…ry leak (#530)

Co-authored-by: NomanShoaib <m.nomanshoaib09@gmail.com>
  • Loading branch information
mnoman09 and NomanShoaib authored Aug 7, 2023
1 parent 65b3f43 commit 9374090
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright 2019,2021, Optimizely
* Copyright 2019, 2021, 2023, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,18 +16,15 @@
*/
package com.optimizely.ab.config;

import com.optimizely.ab.HttpClientUtils;
import com.optimizely.ab.OptimizelyHttpClient;
import com.optimizely.ab.annotations.VisibleForTesting;
import com.optimizely.ab.config.parser.ConfigParseException;
import com.optimizely.ab.internal.PropertyUtils;
import com.optimizely.ab.notification.NotificationCenter;
import com.optimizely.ab.optimizelyconfig.OptimizelyConfig;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -148,6 +145,16 @@ protected ProjectConfig poll() {
return null;
}

@Override
public synchronized void close() {
super.close();
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}

@VisibleForTesting
HttpGet createHttpRequest() {
HttpGet httpGet = new HttpGet(uri);
Expand Down

0 comments on commit 9374090

Please sign in to comment.