CORE-3198 Regression - prefer internal XSD usage
See original GitHub issueEnvironment
Liquibase Version: 4.0.0 -> current (I’m testing on 4.2.2)
Liquibase Integration & Version: Java
Liquibase Extension(s) & Version: None
Database Vendor & Version: ALL / not really relevant
Operating System Type & Version: ALL / not really relevant
Description
Regression of https://liquibase.jira.com/browse/CORE-3198, when merging 3.10 to 4.0 looks like this flag was accidentally wiped out.
Steps To Reproduce
List the steps to reproduce the behavior.
- Set property “liquibase.prefer.internal.xsd”
- Disconnect internet, or open WireShark or similar tool
- Run any XML changeset
Actual Behavior
Running the changeset fails with
Failed to read schema document 'http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.2.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>
Expected/Desired Behavior
It should use the XSD out of the jar
Additional Context
Broken: ee233bd4c082f7e58de7ce5f7a2e6910a67f9f59
To fix add this code to the constructor of XMLChangeLogSAXParser (as in previous versions, eg: https://github.com/liquibase/liquibase/blob/a8b11044a571a11a7b904dfc7dce364fd0d49f37/liquibase-core/src/main/java/liquibase/parser/core/xml/XMLChangeLogSAXParser.java )
if (PREFER_INTERNAL_XSD) { InputStream xsdInputStream = XMLChangeLogSAXParser.class.getResourceAsStream(XSD_FILE); if (xsdInputStream != null) { try { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(new StreamSource(xsdInputStream)); saxParserFactory.setSchema(schema); saxParserFactory.setValidating(false); } catch (SAXException e) { LogService.getLog(XMLChangeLogSAXParser.class).warning("Could not load " + XSD_FILE + ", enabling parser validator", e); } } }
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Brilliant, works great when I ran a schema upgrade. Also what I said above works for the current version as well.
Thanks!
Also while I’ve got your attention thanks for liquibase, it’s a nice product. 😃
I agree that is certainly a more robust fix, I was just being lazy with my suggested fix.
I can give your solution a test tomorrow morning / afternoon.