File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,21 @@ open class BaseTestsModel(
127
127
128
128
val builder = DocumentBuilderFactory .newInstance().newDocumentBuilder()
129
129
return xmlFilePaths.mapNotNullTo(mutableSetOf ()) { path ->
130
- val doc = builder.parse(path.toFile())
131
-
132
- val hasBeanTagName = doc.documentElement.tagName == " beans"
133
- val hasAttribute = doc.documentElement.getAttribute(" xmlns" ) == " http://www.springframework.org/schema/beans"
134
- when {
135
- hasBeanTagName && hasAttribute -> path.toString()
136
- else -> null
130
+ try {
131
+ val doc = builder.parse(path.toFile())
132
+
133
+ val hasBeanTagName = doc.documentElement.tagName == " beans"
134
+ val hasAttribute = doc.documentElement.getAttribute(" xmlns" ) == " http://www.springframework.org/schema/beans"
135
+ when {
136
+ hasBeanTagName && hasAttribute -> path.toString()
137
+ else -> null
138
+ }
139
+ } catch (e: Exception ) {
140
+ // Sometimes xml parsing may fail, for example, when it references external DTD schemas.
141
+ // See https://stackoverflow.com/questions/343383/unable-to-parse-xml-file-using-documentbuilder.
142
+ null
137
143
}
144
+
138
145
}
139
146
}
140
147
You can’t perform that action at this time.
0 commit comments