question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CORE-3198 Regression - prefer internal XSD usage

See original GitHub issue

Environment

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.

  1. Set property “liquibase.prefer.internal.xsd”
  2. Disconnect internet, or open WireShark or similar tool
  3. 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:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dm-ioncommented, Jan 7, 2021

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. 😃

1reaction
dm-ioncommented, Jan 6, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[CORE-3198] Configuration option to prefer internal XSD usage
In this case, a liquibase update for a changelog xml which includes all other changelogs on the classpath will send a http request...
Read more >
Is it possible to use XML Schemas internally, just like DTDs?
It seems like XSDs always need to be defined in a separate file and the be referenced by the XML. Is this true...
Read more >
https://raw.githubusercontent.com/liquibase/liquib...
GH Issue#1523 - Fix xsd, remove surplus space after validateForeignKey ... tarball - [CORE-3198] - Configuration option to prefer internal XSD usage Changes ......
Read more >
Internal spec schema basics - IBM
The internal schema is an XSD document that is used at runtime to validate spec values, which are provided as an XML document...
Read more >
W3C XML Schema Definition Language (XSD) 1.1 Part 1
Historical reasons, rather than connotation, determine the use of the term "·validation·" instead of "·assessment·" in terms like "·post-schema- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found