Skip to content

Commit c5c67f6

Browse files
committed
[Temp]: Add OkHTTP Caching to gitlab P1/2
1 parent df9409f commit c5c67f6

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.gitlab4j</groupId>
66
<artifactId>gitlab4j-api-cortex</artifactId>
77
<packaging>jar</packaging>
8-
<version>4.20.2</version>
8+
<version>4.20.4-SNAPSHOT</version>
99
<name>GitLab4J-API - GitLab API Java Client</name>
1010
<description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description>
1111
<url>https://github.com/gitlab4j/gitlab4j-api</url>

src/main/java/org/gitlab4j/api/GitLabApi.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.logging.Level;
1010
import java.util.logging.Logger;
1111

12+
import javax.ws.rs.client.Client;
1213
import javax.ws.rs.core.MediaType;
1314
import javax.ws.rs.core.Response;
1415

@@ -641,6 +642,10 @@ public void enableRequestResponseLogging(Logger logger, Level level, int maxEnti
641642
apiClient.enableRequestResponseLogging(logger, level, maxEntitySize, maskedHeaderNames);
642643
}
643644

645+
public void setApiClient(Client apiClient) {
646+
this.apiClient.setApiClient(apiClient);
647+
}
648+
644649
/**
645650
* Sets up all future calls to the GitLab API to be done as another user specified by sudoAsUsername.
646651
* To revert back to normal non-sudo operation you must call unsudo(), or pass null as the username.

src/main/java/org/gitlab4j/api/GitLabApiClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,10 @@ protected Client createApiClient() {
790790
return (apiClient);
791791
}
792792

793+
public void setApiClient(Client apiClient) {
794+
this.apiClient = apiClient;
795+
}
796+
793797
protected Invocation.Builder invocation(URL url, MultivaluedMap<String, String> queryParams, String accept) {
794798

795799
if (apiClient == null) {

src/main/java/org/gitlab4j/api/Pager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import java.util.Iterator;
77
import java.util.List;
88
import java.util.NoSuchElementException;
9+
import java.util.logging.Logger;
910
import java.util.stream.Stream;
1011
import java.util.stream.StreamSupport;
1112

13+
import javax.ws.rs.core.GenericType;
1214
import javax.ws.rs.core.MultivaluedMap;
1315
import javax.ws.rs.core.Response;
1416

@@ -40,6 +42,7 @@
4042
* @param <T> the GitLab4J type contained in the List.
4143
*/
4244
public class Pager<T> implements Iterator<List<T>>, Constants {
45+
private final static Logger LOGGER = Logger.getLogger(Pager.class.getName());
4346

4447
private int itemsPerPage;
4548
private int totalPages;
@@ -92,7 +95,7 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
9295
Response response = api.get(Response.Status.OK, queryParams, pathArgs);
9396

9497
try {
95-
currentItems = mapper.readValue((InputStream) response.getEntity(), javaType);
98+
currentItems = mapper.convertValue(response.readEntity(new GenericType<List<T>>() {}), javaType);
9699
} catch (Exception e) {
97100
throw new GitLabApiException(e);
98101
}

0 commit comments

Comments
 (0)