You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/04/11 15:33:23 UTC
[groovy] 12/20: Trivial refactoring: Replace AIC with lambda and
method reference
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 4c1f66f822c8e3639e083f468f4709425a2023fa
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 11 21:31:22 2020 +0800
Trivial refactoring: Replace AIC with lambda and method reference
(cherry picked from commit 36abf696dce783190cfd39f417dad24971f6fc53)
---
.../groovy-xml/src/main/java/groovy/xml/FactorySupport.java | 12 ++----------
.../groovy-xml/src/main/java/groovy/xml/XmlSlurper.java | 6 +-----
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/FactorySupport.java b/subprojects/groovy-xml/src/main/java/groovy/xml/FactorySupport.java
index c2385c5..a6d57c7 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/FactorySupport.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/FactorySupport.java
@@ -45,18 +45,10 @@ public class FactorySupport {
}
public static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException {
- return (DocumentBuilderFactory) createFactory(new PrivilegedExceptionAction() {
- public Object run() throws ParserConfigurationException {
- return DocumentBuilderFactory.newInstance();
- }
- });
+ return (DocumentBuilderFactory) createFactory(DocumentBuilderFactory::newInstance);
}
public static SAXParserFactory createSaxParserFactory() throws ParserConfigurationException {
- return (SAXParserFactory) createFactory(new PrivilegedExceptionAction() {
- public Object run() throws ParserConfigurationException {
- return SAXParserFactory.newInstance();
- }
- });
+ return (SAXParserFactory) createFactory(SAXParserFactory::newInstance);
}
}
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlSlurper.java b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlSlurper.java
index 6463a95..5c3354a 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlSlurper.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlSlurper.java
@@ -339,11 +339,7 @@ public class XmlSlurper extends DefaultHandler {
* @param base The URL used to resolve relative URLs
*/
public void setEntityBaseUrl(final URL base) {
- reader.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(final String publicId, final String systemId) throws IOException {
- return new InputSource(new URL(base, systemId).openStream());
- }
- });
+ reader.setEntityResolver((publicId, systemId) -> new InputSource(new URL(base, systemId).openStream()));
}
/* (non-Javadoc)