This description is not clear enough for users what to do.
In v8.0.5, I ran the following testcase A:
// Test Case A
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
/*
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
*/
DocumentBuilder parser = newBuilderInstance()
DocumentBuilder newBuilderInstance() {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance()
println "This DocumentBuilderFactory is an instance of " + dbFactory.getClass().getName()
dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD","")
dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalSchema","")
return dbFactory.newDocumentBuilder()
}
When I ran the Test Case A I got an exception:
This DocumentBuilderFactory is an instance of org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
...
2021-08-11 11:00:02.352 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/reproducingAccessExternalDTDproblem FAILED.
Reason:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
This is not good, obviously.
So I changed it slightly as your solution tells us to do. I got the following Test Case B.
// Test Case B
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
DocumentBuilder parser = newBuilderInstance()
DocumentBuilder newBuilderInstance() {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance()
println "This DocumentBuilderFactory is an instance of " + dbFactory.getClass().getName()
dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD","")
dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalSchema","")
return dbFactory.newDocumentBuilder()
}
Test Case B worked fine. No exception was thrown. In the console I saw:
This DocumentBuilderFactory is an instance of com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
@duylong,
Do you want us repeat writing our test cases so that they have the line of
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
in all Test Cases if we are going to process XML document as of v8.0.x? Do you mean it is “a satisfactory fix” done in v8.0.5?
To me, this looks not a “fix”. This is a workaround.
Still it is good to have a workaround for a known problem. If you want users to follow this workaround, then you should write a new page in the official document and explain what users should do clearly.