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

xml config whitespace xs:string vs xs:normalizedString #14919

Closed
Danny-Hazelcast opened this issue Apr 22, 2019 · 2 comments · Fixed by #14944
Closed

xml config whitespace xs:string vs xs:normalizedString #14919

Danny-Hazelcast opened this issue Apr 22, 2019 · 2 comments · Fixed by #14944

Comments

@Danny-Hazelcast
Copy link
Member

@Danny-Hazelcast Danny-Hazelcast commented Apr 22, 2019

using xml config

<quorum enabled="true" name="3NodeWrite" >
        <quorum-size>3</quorum-size>
        <quorum-type>WRITE </quorum-type>
        <quorum-listeners>
            <quorum-listener>hzcmd.quorum.Listner</quorum-listener>
        </quorum-listeners>
    </quorum>

gives

fail HzMember3HZBB com.hazelcast.config.InvalidConfigurationException: cvc-enumeration-valid: Value 'WRITE ' is not facet-valid with respect to enumeration '[READ, WRITE, READ_WRITE]'. It must be a value from the enumeration.

so the space counts,

<quorum-type>WRITE </quorum-type> 'WRITE ' is not (edited)

is it a user friendly issue ?
we could trim the strings ?

com.hazelcast.config.InvalidConfigurationException: cvc-enumeration-valid: Value 'WRITE ' is not facet-valid with respect to enumeration '[READ, WRITE, READ_WRITE]'. It must be a value from the enumeration.
	at com.hazelcast.config.AbstractXmlConfigHelper.schemaValidation(AbstractXmlConfigHelper.java:116)
	at com.hazelcast.config.XmlConfigBuilder.parseAndBuildConfig(XmlConfigBuilder.java:164)
	at com.hazelcast.config.XmlConfigBuilder.build(XmlConfigBuilder.java:146)
	at com.hazelcast.config.XmlConfigBuilder.build(XmlConfigBuilder.java:139)
	at vendor.hz.java.HzControler.init(HzControler.java:30)
	at remote.main.Controler.startEmbeddedObject(Controler.java:53)
	at remote.command.StartEmbeddedObjectCmd.exicute(StartEmbeddedObjectCmd.java:18)
	at remote.main.Controler.run(Controler.java:203)
	at vendor.hz.java.HzMember.main(HzMember.java:9)
Caused by: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 42; cvc-enumeration-valid: Value 'WRITE ' is not facet-valid with respect to enumeration '[READ, WRITE, READ_WRITE]'. It must be a value from the enumeration.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:453)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3231)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3146)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3056)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2135)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:854)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:582)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.validate(ValidatorHandlerImpl.java:726)
	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:102)
	at javax.xml.validation.Validator.validate(Validator.java:124)
	at com.hazelcast.config.AbstractXmlConfigHelper.schemaValidation(AbstractXmlConfigHelper.java:114)
	... 8 more
@Danny-Hazelcast

This comment has been minimized.

Copy link
Member Author

@Danny-Hazelcast Danny-Hazelcast commented Apr 22, 2019

@vojtechtoman says

This error message comes from the XML Schema processor. The quorum-type extends from xs:string which is why the processor does not trim it and treats WRITE and WRITE as separate values. A workaround might be to change quorum-type to extend xs:normalizedString. That should fix the validation problems. However, as far as I know, we perform validation as a separate step after actually traversing and reading the config document, so we still would have to trim the value that we read.

@vojtechtoman vojtechtoman self-assigned this Apr 24, 2019
vojtechtoman added a commit to vojtechtoman/hazelcast that referenced this issue Apr 26, 2019
Changed the 'non-space-string' XSD type to collapse all
whitespace, and made sure that all enumerated types
extend from this type (some were extending xs:string).

Fixes hazelcast#14919
@vojtechtoman

This comment has been minimized.

Copy link
Contributor

@vojtechtoman vojtechtoman commented Apr 26, 2019

My initial assessment was wrong: first, validation is performed before we traverse the document tree which is good (the nodes are already subject to XML schema processing/augmentation like whitespace normalization etc.) Second, the idea with xs:normalizedString does not work. However, there is an equally simple fix by adding <xs:whiteSpace value='collapse'/> to the non-space-string type (and making sure that all enumerated types extend this type).

vojtechtoman added a commit that referenced this issue Apr 29, 2019
* Config format: better support for whitespace in enumerations

Changed the 'non-space-string' XSD type to collapse all
whitespace, and made sure that all enumerated types
extend from this type (some were extending xs:string).

Also removed the 'wan-ack-type' type from the core
and the client schemas because it was not used (ACK
type passed as properties).

Fixes #14919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.