@@ -130,6 +130,7 @@ public List<SourceRecord> poll() throws InterruptedException {
130130 long autoOffset = 0 ;
131131 long autoDateIncrement = 0 ;
132132 long autoDateBackoff = 0 ;
133+ boolean pagingEnabled = nextPageOffsetField != null && !nextPageOffsetField .isEmpty () && hasNextPageField != null && !hasNextPageField .isEmpty ();
133134
134135 if ( autoDateInitialOffset != null && !autoDateInitialOffset .isEmpty ()) {
135136 try {
@@ -148,11 +149,15 @@ public List<SourceRecord> poll() throws InterruptedException {
148149
149150 offset .setValue (AUTOTIMESTAMP , autoOffset );
150151 }
151- offset .setValue (nextPageOffsetField , "" );
152- offset .setValue (hasNextPageField , "" );
152+
153153 String hasNextPageFlag = "true" ;
154154 String nextPageValue = "" ;
155155
156+ if (pagingEnabled ){
157+ offset .setValue (nextPageOffsetField , "" );
158+ offset .setValue (hasNextPageField , "" );
159+ }
160+
156161 while (hasNextPageFlag .matches ("true" )) {
157162 HttpRequest request = requestFactory .createRequest (offset );
158163
@@ -166,11 +171,9 @@ public List<SourceRecord> poll() throws InterruptedException {
166171
167172 if (!records .isEmpty ()) {
168173 allRecords .addAll (records );
169- nextPageValue = (String ) records .get (0 ).sourceOffset ().get (nextPageOffsetField );
170- hasNextPageFlag = (String ) records .get (0 ).sourceOffset ().get (hasNextPageField );
171-
172- if (hasNextPageFlag != null && hasNextPageFlag .matches ("true" ) && !nextPageValue .trim ().isEmpty ()) {
173- log .info ("Request for next page {}" , nextPageValue );
174+ if (pagingEnabled ){
175+ nextPageValue = (String ) records .get (0 ).sourceOffset ().get (nextPageOffsetField );
176+ hasNextPageFlag = (String ) records .get (0 ).sourceOffset ().get (hasNextPageField );
174177 offset .setValue (nextPageOffsetField , nextPageValue );
175178 offset .setValue (hasNextPageField , hasNextPageFlag );
176179 } else {
0 commit comments