Skip to content

Commit 5e99944

Browse files
committed
PLUGIN-1936 : Fix duplicate record issue
1 parent 80033a3 commit 5e99944

File tree

1 file changed

+3
-56
lines changed

1 file changed

+3
-56
lines changed

src/main/java/io/cdap/plugin/servicenow/source/ServiceNowRecordReader.java

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public boolean nextKeyValue() throws IOException {
102102
// At this point jsonReader is positioned inside the "result" array.
103103
JsonToken token = jsonReader.peek();
104104

105-
if (token == JsonToken.END_ARRAY) {
105+
/*if (token == JsonToken.END_ARRAY) {
106106
// Current page exhausted. Close current page and try to open the next page.
107107
closeCurrentPage();
108108
@@ -119,7 +119,7 @@ public boolean nextKeyValue() throws IOException {
119119
return false;
120120
}
121121
// continue loop to attempt to read from newly opened page
122-
}
122+
}*/
123123

124124
if (token == JsonToken.BEGIN_OBJECT) {
125125
LOG.info("Reading record object for table {} at position {}", tableName, pos);
@@ -129,61 +129,8 @@ public boolean nextKeyValue() throws IOException {
129129
pos++;
130130
return true;
131131
}
132+
closeCurrentPage();
132133
return false;
133-
134-
/*if (token == JsonToken.NULL) {
135-
// skip nulls if any and continue
136-
jsonReader.nextNull();
137-
continue;
138-
}*/
139-
140-
// Skip any unexpected or non-object token and loop
141-
//jsonReader.skipValue();
142-
143-
/*********************----------------**********************/
144-
/*// read the next record from the current page
145-
try {
146-
if (jsonreader.hasnext()) {
147-
// there is another record in the current page
148-
map<string, string> recordmap = new hashmap<>();
149-
jsonreader.beginobject();
150-
while (jsonreader.hasnext()) {
151-
string name = jsonreader.nextname();
152-
jsontoken token = jsonreader.peek();
153-
string value = null;
154-
if (token == jsontoken.null) {
155-
jsonreader.nextnull();
156-
} else {
157-
value = jsonreader.nextstring();
158-
}
159-
recordmap.put(name, value);
160-
}
161-
jsonreader.endobject();
162-
row = recordmap;
163-
pos++;
164-
return true;
165-
} else {
166-
// end of current page
167-
closecurrentpage();
168-
}
169-
} catch (ioexception e) {
170-
// cleanup on parse error
171-
closecurrentpage();
172-
log.error("error parsing json response from table " + tablename, e);
173-
throw e;
174-
}*/
175-
176-
/*try {
177-
InputStream inputStream = fetchData();
178-
do {
179-
row = restApi.parseResponseStreamToRecord(inputStream);
180-
pos++;
181-
return true;
182-
} while (inputStream.available() > 0);
183-
} catch (Exception e) {
184-
LOG.error("Error in nextKeyValue", e);
185-
throw new IOException("Exception in nextKeyValue", e);
186-
}*/
187134
}
188135

189136
@Override

0 commit comments

Comments
 (0)