【fix sonar】XmlUtils文件
This commit is contained in:
+12
-17
@@ -1,19 +1,8 @@
|
||||
package com.jero.modules.cas.util;
|
||||
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
@@ -21,7 +10,13 @@ import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 解析cas,ST验证后的xml
|
||||
@@ -53,7 +48,7 @@ public final class XmlUtils {
|
||||
try {
|
||||
return factory.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("XML parsing error: " + e);
|
||||
throw new JeroBootException("XML parsing error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +65,7 @@ public final class XmlUtils {
|
||||
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
|
||||
return reader;
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("Unable to create XMLReader", e);
|
||||
throw new JeroBootException("Unable to create XMLReader", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +121,7 @@ public final class XmlUtils {
|
||||
reader.parse(new InputSource(new StringReader(xmlAsString)));
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return elements;
|
||||
|
||||
Reference in New Issue
Block a user