Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit 46df9ae

Browse files
committed
Properly end all iterators.
This fixes leftover code from the old iterator library. The internal method AsyncIterator#_end should not be called directly. Instead, #close should handle the end of an iterator. This fixes #21, in which incorrectly closing the federated client dropped results.
1 parent 0622409 commit 46df9ae

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/triple-pattern-fragments/federated/FederatedFragmentsClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function CompoundFragment(fragments, options) {
9090
delete fragments[index];
9191
// If no fragments are pending anymore, the iterator ends
9292
if (--fragmentsPending === 0)
93-
compoundFragment._end();
93+
compoundFragment.close();
9494
});
9595
fragment.once('end', fragmentDone);
9696

@@ -128,7 +128,7 @@ CompoundFragment.prototype._read = function (count, done) {
128128
CompoundFragment.prototype.empty = function () {
129129
if (!this.getProperty('metadata'))
130130
this.setProperty('metadata', { totalTriples: 0 });
131-
this._end();
131+
this.close();
132132
};
133133

134134
// Returns a textual representation of the fragment

lib/writers/SparqlJSONResultWriter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ SparqlJSONResultWriter.prototype._writeBindings = function (result) {
3838
};
3939

4040
SparqlJSONResultWriter.prototype._writeBoolean = function (result) {
41-
this._end = SparqlResultWriter.prototype._end; // prevent other characters from being written
4241
this._push('"boolean":' + result + '}\n');
42+
this._flush = SparqlResultWriter.prototype._flush; // do not write the bindings tail
4343
};
4444

4545
SparqlJSONResultWriter.prototype._flush = function (done) {

test/sparql/UnionIterator-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('UnionIterator', function () {
225225

226226
describe('after the first source has ended', function () {
227227
before(function () {
228-
sourceA._end();
228+
sourceA.close();
229229
});
230230

231231
it('should not have ended', function () {
@@ -255,7 +255,7 @@ describe('UnionIterator', function () {
255255
describe('after the second source has ended', function () {
256256
before(function (done) {
257257
iterator.on('end', done);
258-
sourceB._end();
258+
sourceB.close();
259259
});
260260

261261
it('should have ended', function () {

0 commit comments

Comments
 (0)