Skip to content

JOHNZON-441 - implement currentEvent for RewindableJsonParser and JsonValueParserAdapter - #145

Open
jungm wants to merge 2 commits into
apache:masterfrom
jungm:issue/JOHNZON-441
Open

JOHNZON-441 - implement currentEvent for RewindableJsonParser and JsonValueParserAdapter#145
jungm wants to merge 2 commits into
apache:masterfrom
jungm:issue/JOHNZON-441

Conversation

@jungm

Copy link
Copy Markdown
Member

@jungm
jungm requested a review from rmannibucauAugust 25, 2026 18:51

@rmannibucaurmannibucau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the changes enable the ticket, looks like they break the contract to me, is it intended?
Also I think we can just drop this rewindablejsonparser now no? did you test?

private <T> Stream<T> trackStream(final Stream<T> stream) {
pendingRewind = false;
last = delegate.currentEvent();
final boolean parallel = stream.isParallel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if parallel nothing works I think

}
}
};
return StreamSupport.stream(tracking, parallel).onClose(stream::close);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why closing there, the caller must close it

return jsonValue;
}
}
/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rework so the diff is accurate? (content is ok once done)

}

@Override
public Event next() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this potentially changes the behavior so should be refined I think if desired (looks ok upfront but having a broken test for it can be sane on the long run)

return delegate.currentEvent();
}
last = delegate.next();
pendingRewind = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks wrong to impl it there and violates the contract, if I call it on a new parser it should return null, the method is literally getLast() only (our getLast was pre JSON-P 2.1 as a minimum target)

@jungm

Copy link
Copy Markdown
MemberAuthor

yeah you're right, this was all a huge hack because i thought currentEvent must point to the first real event (index 0 instead of -1), hence all of that advancing and masking it code. the tck even tests the other way around https://github.com/jakartaee/jsonp-api/blob/2.1.3-RELEASE/tck/tck-tests/src/main/java/ee/jakarta/tck/jsonp/api/jsonparsertests/ClientTests.java#L1862

So agree, we can probably just drop RewindableJsonParser entirely since its only delegating?

@rmannibucau

Copy link
Copy Markdown
Contributor

@jungm think it is worth giving a try now we have the required API and wiring was updated

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jungm@rmannibucau