1414import java .io .IOException ;
1515import java .lang .reflect .Field ;
1616import java .lang .reflect .Type ;
17+ import java .util .function .Function ;
1718
1819public class Pager {
1920 private Request originalRequest ;
2021 private String _continue ;
2122 private String resourceVersion ;
22- private int limit ;
23+ private Integer limit ;
2324 private ApiClient client ;
2425 private Call call ;
2526 private Type listType ;
2627
27- public Pager (ApiClient client , Call call , int limit , Type listType ) {
28+ public Pager (ApiClient client , Call call , Integer limit , Type listType ) {
2829 this .client = client ;
2930 this .call = call ;
3031 this .limit = limit ;
@@ -51,12 +52,10 @@ public <T> T next()
5152 } else if (_continue == null && originalRequest != null ) {
5253 // list was exhausted at server
5354 V1ConfigMapList list =
54- client .getJSON ().deserialize ("{}" , new TypeToken <V1ConfigMapList >() {}.getType ());
55- } else {
56- // subsequent calls
55+ client .getJSON ().deserialize ("{}" , listType );
56+ }
5757 Request nextRequest = transFormRequest ();
5858 call = client .getHttpClient ().newCall (nextRequest );
59- }
6059 return executeRequest (client , call , listType );
6160 }
6261
@@ -66,9 +65,10 @@ private Request transFormRequest() {
6665 .httpUrl ()
6766 .newBuilder ()
6867 .setQueryParameter ("continue" , _continue )
69- .setQueryParameter ("limit" , String .valueOf (limit ))
68+ .setQueryParameter ("limit" , ( limit == null )? "-1" : String .valueOf (limit ))
7069 // .addQueryParameter("resourceversion", resourceVersion)
7170 .build ();
71+ System .out .println (url );
7272 Request request = new Request .Builder ().headers (originalRequest .headers ()).url (url ).build ();
7373 return request ;
7474 }
0 commit comments