Skip to content

Fix failure for empty attribute match #250

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

Merged
merged 1 commit into from
Apr 4, 2019

Conversation

ashawley
Copy link
Member

Fixes #249.

@ashawley ashawley added this to the 1.1.1 milestone Aug 16, 2018
@ashawley ashawley force-pushed the fix-fail-empty-attrib branch 2 times, most recently from e3811d4 to 4d959d4 Compare August 22, 2018 20:26
@ashawley
Copy link
Member Author

ashawley commented Aug 22, 2018

The only concern is if someone has clunky code that happened to be doing an attribute search on a collection of nodes with the empty string. This change would suddenly raise an exception in that scenario, rather than silently returning the empty node list.

@ashawley ashawley force-pushed the fix-fail-empty-attrib branch 2 times, most recently from 994f1c4 to 6fce346 Compare August 28, 2018 15:54
@ashawley ashawley modified the milestones: 1.1.1, 1.2.0 Aug 30, 2018
@ashawley ashawley force-pushed the fix-fail-empty-attrib branch from 6fce346 to 0c7069f Compare April 4, 2019 16:48
Running the following invalid attribute search, properly throws an
IllegalArgumentException.

    scala> <x/> \ "@"
    java.lang.IllegalArgumentException: @

    scala> <x/> \@ ""
    java.lang.IllegalArgumentException: @

There's no such thing as an empty attribute.

However, when the improper matching value is used against more than
just one element, no error is thrown, just an empty NodeSeq is
returned:

    scala> <x><y/><z/></x>.child \ "@"
    res1: scala.xml.NodeSeq = NodeSeq()

It should be a failure.

Similarly, the attribute search method, is similarly affected.

    scala> <x><y/><z/></x>.child \@ ""
    res1: scala.xml.NodeSeq = NodeSeq()

This was identified while writing ScalaCheck property tests.
@ashawley ashawley force-pushed the fix-fail-empty-attrib branch from 0c7069f to 9a0db27 Compare April 4, 2019 16:55
@ashawley ashawley merged commit 54813f1 into scala:master Apr 4, 2019
@ashawley ashawley deleted the fix-fail-empty-attrib branch April 4, 2019 17:21
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.

1 participant