scala.xml.pull.XMLEventReader 跟不上流
我尝试使用 scala.xml.pull.XMLEventReader 大致如下:
private val in =
new XMLEventReader(Source.fromInputStream(
new BufferedInputStream(sock.getInputStream()), "utf-8")).buffered
然后我迭代 XML 流:
while (in.hasNext) {
in.next match { ... }
}
这里的问题是 xmleventreader 阻塞在“hasNext”上并且不提醒我知道的新 XML 标签已经到达(我使用 TCP Dump.. 监视流,并且可以在末尾看到
我在 scala 2.8.0、2.8.1 和 2.9.0 中尝试过,
也尝试过不使用“.buffered”且不使用 BufferedInputStream,但结果是相同的。
还有希望还是 XMLEventReader 已经坏了?
I'm trying to use the scala.xml.pull.XMLEventReader roughly like so:
private val in =
new XMLEventReader(Source.fromInputStream(
new BufferedInputStream(sock.getInputStream()), "utf-8")).buffered
Then I iterate over the XML stream with:
while (in.hasNext) {
in.next match { ... }
}
The problem here is that the xmleventreader is blocking on "hasNext" and not alerting to new XML tags that I know have arrived (I monitored the stream with TCP Dump.. and can see a <success xmlns="blah"/> tag at the end but still haven't even been notified the previous tag was closed).
I tried this in scala 2.8.0, 2.8.1 and 2.9.0
Is also tried without ".buffered" and without using BufferedInputStream but the results were the same.
Is there any hope or is the XMLEventReader just broken?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MarkupParser
已损坏。关闭标签时,它总是获取下一个字符。由于您正在从流中读取数据,因此会阻塞,直到提供这样的字符或关闭流。MarkupParser
is broken. When closing a tag, it always gets the next character. Since you are reading from a stream, that blocks until such a character is provided or the stream is closed.