Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark the loadXML call as blocking #28

Merged
merged 2 commits into from
Jun 12, 2022
Merged

Conversation

rossabaker
Copy link
Member

Fixes #27. Source compatible for everyone who uses it implicitly and has an Async.

The need for Sync was offensive enough in JSON that we made a capability trait. Note that we can relax it back to Concurrent in #25.

Comment on lines +81 to +82
collectBinary(msg).flatMap[DecodeFailure, Elem] { chunk =>
source.setByteStream(new ByteArrayInputStream(chunk.toArray))
Copy link
Member Author

Choose a reason for hiding this comment

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

We could avoid this strictness by converting the fs2 stream to an InputStream. I think we'd spend CPU to save memory with that approach.

Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

I assume this gets targeted to 0.23?

@@ -49,7 +52,8 @@ trait ElemInstances {
*
* @return an XML element
*/
implicit def xml[F[_]](implicit F: Concurrent[F]): EntityDecoder[F, Elem] = {
@deprecated("Blocks. Use xmlDecoder with an Async constraint.", "0.23.12")
def xml[F[_]](implicit F: Concurrent[F]): EntityDecoder[F, Elem] = {
Copy link
Member

Choose a reason for hiding this comment

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

If we care enough we can do a runtime check for Async to delegate to the new implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

That technique makes me squeamish, but we've adopted it enough other places and I've never seen an accident scene from it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. I merged before resolving this. If we want, it could still be a separate PR.

@rossabaker rossabaker changed the base branch from main to series/0.23 June 12, 2022 02:35
@rossabaker
Copy link
Member Author

I really hate introducing constraint churn, with what appears to be a better solution looming in 0.24 (I'm working on a bench). But what's here in 0.23 is just simply not safe.

@armanbilge armanbilge closed this Jun 12, 2022
@armanbilge armanbilge reopened this Jun 12, 2022
Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Re-triggered CI on 0.23.

@rossabaker rossabaker merged commit 510dbc4 into series/0.23 Jun 12, 2022
@armanbilge armanbilge deleted the load-xml-is-blocking branch June 12, 2022 04:39
rossabaker added a commit to http4s/http4s-fs2-data that referenced this pull request Jun 17, 2022
…-blocking

Mark the loadXML call as blocking
Sign up for free to 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.

Missing a blocking call
2 participants