dev@fi.java.net

Re: setFeature Bug?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 03 Jan 2006 14:23:56 +0100

Hi Alan,

Yes, this is a bug, thanks for finding this.

I have just fixed this (and included some simple unit tests). An
automated build should be pushed to java.net soon, hopefully by the time
you read this.

Paul.

Alan Hudson wrote:
> I'm running from a bit older CVS, but I think this code is still the same.
>
> public void setFeature(String name, boolean value)
> throws SAXNotRecognizedException, SAXNotSupportedException {
> if (name.equals(Features.NAMESPACES_FEATURE)
> && value == false) {
> throw new SAXNotSupportedException(name + ":" + value);
> } else if (name.equals(Features.NAMESPACE_PREFIXES_FEATURE)) {
> _namespacePrefixesFeature = value;
> } else if (name.equals(Features.STRING_INTERNING_FEATURE) ||
> name.equals(FastInfosetReader.STRING_INTERNING_PROPERTY)) {
> setStringInterning(value);
> } else {
> throw new SAXNotRecognizedException(
> "Feature not supported: " + name);
> }
> }
>
> If someone calls setFeature(Features.NAMESPACES_FEATURE, with a true
> value, they will get a SAXNotRecognizedException.
>
> I think the logic is wrong, as its specifically looking for someone
> turning it off.
> I'd suggest changing it to:
>
> public void setFeature(String name, boolean value)
> throws SAXNotRecognizedException, SAXNotSupportedException {
> if (name.equals(Features.NAMESPACES_FEATURE)
> && value == true) {
> // ignore as default
> } else if (name.equals(Features.NAMESPACE_PREFIXES_FEATURE)) {
> _namespacePrefixesFeature = value;
> } else if (name.equals(Features.STRING_INTERNING_FEATURE) ||
> name.equals(FastInfosetReader.STRING_INTERNING_PROPERTY)) {
> setStringInterning(value);
> } else {
> throw new SAXNotRecognizedException(
> "Feature not supported: " + name);
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_fi.dev.java.net
> For additional commands, e-mail: dev-help_at_fi.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109