Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Callreset on reusableSAXParser instance#742

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
lrytz wants to merge1 commit intoscala:main
base:main
Choose a base branch
Loading
fromlrytz:pr176-reset

Conversation

lrytz
Copy link
Member

Discussion:#176 (comment)

Copy link
Contributor

@dubinskydubinsky left a comment

Choose a reason for hiding this comment

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

It is not clear to me what is gained by this change...

def parser: SAXParser = parserInstance.get
def parser: SAXParser = {
val p = parserInstance.get
p.reset()
Copy link
Contributor

Choose a reason for hiding this comment

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

Auto-reset on get leads to surprising changes in behavior, e.g. non-persistence of the settings onXMLLoader.reader, as witnessed by the changes to the test above.
Better place for auto-reset seems to beFactoryAdapter.loadDocument(), but it will then apply to all readers, not just the default one...
Better still would be - in my opinion - not to reuse parsers, readers and factory adapters and not to use thread-locals.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

So revert#176?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not going to campaign for reverting it, but I am not a fan ;)

override def warning(e: SAXParseException): Unit = gotAnError = true
override def error(e: SAXParseException): Unit = gotAnError = true
override def fatalError(e: SAXParseException): Unit = gotAnError = true
})
try {
XML.loadString("<a>")
XML.adapter.loadDocument(Source.fromString("<a>"), reader)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to makeXMLLoader.adapter,NoBindingFactoryAdapter andFactoryAdapter private at some point (and remove some of them altogether), and addXMLLoader.loadDocument(inputSource: InputSource, reader: XMLReader)...

@lrytz
Copy link
MemberAuthor

It is not clear to me what is gained by this change...

It's really more of a guess... In a non-public codebase we have anUnsafeXML object that's similar toXML but before the safe defaults (#177). We recently applied the same ThreadLocal caching toUnsafeXML as was done in#176 and saw some SaxParserException. But I haven't followed through to understand what's going on exactly or ifreset actually fixes it, I'll do that.

Thanks for taking a look.

@lrytz
Copy link
MemberAuthor

I haven't followed through to understand what's going on exactly or ifreset actually fixes it, I'll do that.

Didn't manage to reproduce the failure we saw and suspect would be fixed by this PR.

So that leaves as justification that "it seems right" to call reset, according to the Javadocs.

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

@dubinskydubinskydubinsky left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@lrytz@dubinsky

[8]ページ先頭

©2009-2025 Movatter.jp