Skip to content

Commit d0ed02d

Browse files
committed
Merge remote-tracking branch 'origin/development'
2 parents c815ce7 + 341efd4 commit d0ed02d

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Add the following dependency to the dependencies section of your project's `pom.
1818
<dependency>
1919
<groupId>io.github.sornerol</groupId>
2020
<artifactId>chesscom-pubapi-wrapper</artifactId>
21-
<version>1.5.0</version>
21+
<version>1.6.0</version>
2222
</dependency>
2323
</dependencies
2424
```
@@ -27,7 +27,7 @@ Add the following dependency to the dependencies section of your project's `buil
2727
```
2828
dependencies {
2929
// other project dependencies...
30-
implementation 'io.github.sornerol:chesscom-pubapi-wrapper:1.5.0'
30+
implementation 'io.github.sornerol:chesscom-pubapi-wrapper:1.6.0'
3131
}
3232
```
3333

pom.xml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.sornerol</groupId>
88
<artifactId>chesscom-pubapi-wrapper</artifactId>
9-
<version>1.5.0</version>
9+
<version>1.6.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
@@ -65,15 +65,20 @@
6565
<version>${jackson.version}</version>
6666
</dependency>
6767
<dependency>
68-
<groupId>org.apache.httpcomponents</groupId>
69-
<artifactId>httpclient</artifactId>
70-
<version>4.5.14</version>
68+
<groupId>org.apache.httpcomponents.client5</groupId>
69+
<artifactId>httpclient5</artifactId>
70+
<version>5.3.1</version>
7171
</dependency>
7272
<dependency>
7373
<groupId>commons-io</groupId>
7474
<artifactId>commons-io</artifactId>
7575
<version>2.15.1</version>
7676
</dependency>
77+
<dependency>
78+
<groupId>org.slf4j</groupId>
79+
<artifactId>slf4j-api</artifactId>
80+
<version>2.0.11</version>
81+
</dependency>
7782
<dependency>
7883
<groupId>org.spockframework</groupId>
7984
<artifactId>spock-core</artifactId>
@@ -84,6 +89,12 @@
8489
<artifactId>spock-junit4</artifactId>
8590
<scope>test</scope>
8691
</dependency>
92+
<dependency>
93+
<groupId>org.slf4j</groupId>
94+
<artifactId>slf4j-simple</artifactId>
95+
<version>2.0.11</version>
96+
<scope>test</scope>
97+
</dependency>
8798
</dependencies>
8899

89100
<profiles>
@@ -167,7 +178,7 @@
167178
<plugin>
168179
<groupId>org.codehaus.gmavenplus</groupId>
169180
<artifactId>gmavenplus-plugin</artifactId>
170-
<version>1.9.0</version>
181+
<version>3.0.2</version>
171182
<executions>
172183
<execution>
173184
<goals>
@@ -248,7 +259,7 @@
248259
<plugin>
249260
<groupId>org.codehaus.gmavenplus</groupId>
250261
<artifactId>gmavenplus-plugin</artifactId>
251-
<version>1.9.0</version>
262+
<version>3.0.2</version>
252263
<executions>
253264
<execution>
254265
<goals>

src/main/java/io/github/sornerol/chess/pubapi/client/PubApiClientBase.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import io.github.sornerol.chess.pubapi.exception.ChessComPubApiException;
88
import lombok.Getter;
99
import lombok.Setter;
10+
import lombok.extern.slf4j.Slf4j;
1011
import org.apache.commons.io.IOUtils;
11-
import org.apache.http.client.methods.CloseableHttpResponse;
12-
import org.apache.http.client.methods.HttpGet;
13-
import org.apache.http.impl.client.CloseableHttpClient;
14-
import org.apache.http.impl.client.HttpClients;
15-
import org.apache.http.message.BasicHeader;
12+
import org.apache.hc.client5.http.classic.methods.HttpGet;
13+
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
14+
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
15+
import org.apache.hc.client5.http.impl.classic.HttpClients;
16+
import org.apache.hc.core5.http.message.BasicHeader;
1617

1718
import java.io.IOException;
1819
import java.io.InputStream;
@@ -21,6 +22,7 @@
2122
/**
2223
* The base class of all the PubAPI client classes.
2324
*/
25+
@Slf4j
2426
abstract class PubApiClientBase {
2527

2628
/**
@@ -127,6 +129,10 @@ protected String getRequest(String endpoint) throws IOException, ChessComPubApiE
127129
HttpGet request = new HttpGet(endpoint);
128130
if (userAgent != null) {
129131
request.addHeader(new BasicHeader("User-Agent", userAgent));
132+
} else {
133+
log.warn("No User-Agent provided. Your request may not work. See " +
134+
"https://www.chess.com/announcements/view/breaking-change-user-agent-contact-info-required for" +
135+
"additional details");
130136
}
131137

132138
String responseBody;
@@ -135,7 +141,7 @@ protected String getRequest(String endpoint) throws IOException, ChessComPubApiE
135141
boolean keepTrying = false;
136142
do {
137143
try (CloseableHttpResponse response = httpClient.execute(request)) {
138-
int statusCode = response.getStatusLine().getStatusCode();
144+
int statusCode = response.getCode();
139145
if (statusCode == ResponseCode.RATE_LIMIT_EXCEEDED.getValue() && shouldTryRequestAgain(attempts)) {
140146
keepTrying = true;
141147
attempts++;

0 commit comments

Comments
 (0)