Skip to content

Commit df11174

Browse files
committed
Fix: Make OkHttpClient singleton
1 parent ba59ac2 commit df11174

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

common/src/main/java/com/xinecraft/minetrax/common/MinetraxCommon.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import lombok.Getter;
1717
import lombok.Setter;
1818
import net.skinsrestorer.api.SkinsRestorer;
19+
import okhttp3.OkHttpClient;
1920

2021
@Setter
2122
@Getter
@@ -32,6 +33,7 @@ public class MinetraxCommon {
3233
private BanWardenPluginType banWardenPluginType;
3334
private BanWarden banWarden;
3435
public static String PLUGIN_MESSAGE_CHANNEL = "minetrax:main";
36+
public OkHttpClient httpClient = new OkHttpClient();
3537

3638
public MinetraxCommon() {
3739
instance = this;

common/src/main/java/com/xinecraft/minetrax/common/utils/HttpUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class HttpUtil {
1212
public static final MinetraxCommon common = MinetraxCommon.getInstance();
1313

1414
public static HttpResponse get(String url, Map<String, String> params, Map<String, String> headers) throws IOException {
15-
OkHttpClient client = new OkHttpClient();
15+
OkHttpClient client = common.getHttpClient();
1616

1717
// Build the URL with parameters
1818
HttpUrl.Builder httpBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder();
@@ -56,7 +56,7 @@ public static HttpResponse get(String url, Map<String, String> params, Map<Strin
5656
}
5757

5858
public static HttpResponse post(String url, String json, Map<String, String> headers) throws IOException {
59-
OkHttpClient client = new OkHttpClient();
59+
OkHttpClient client = common.getHttpClient();
6060

6161
// Build the request with headers
6262
Request.Builder requestBuilder = new Request.Builder()

0 commit comments

Comments
 (0)