Skip to content

Commit 4103d90

Browse files
committed
Review checkstyle rules of spring-xml
See gh-1479
1 parent ae5b460 commit 4103d90

16 files changed

+57
-45
lines changed

spring-xml/src/main/java/org/springframework/xml/DocumentBuilderFactoryUtils.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
import org.apache.commons.logging.LogFactory;
2525

2626
/**
27+
* General utilities for {@link DocumentBuilderFactory}.
28+
*
2729
* @author Greg Turnquist
2830
* @since 3.0.5
2931
*/
30-
public class DocumentBuilderFactoryUtils {
32+
public abstract class DocumentBuilderFactoryUtils {
3133

3234
private static final Log log = LogFactory.getLog(DocumentBuilderFactoryUtils.class);
3335

@@ -42,7 +44,7 @@ public static DocumentBuilderFactory newInstance() {
4244
try {
4345
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
4446
}
45-
catch (IllegalArgumentException e) {
47+
catch (IllegalArgumentException ex) {
4648
if (log.isWarnEnabled()) {
4749
log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by "
4850
+ factory.getClass().getCanonicalName());
@@ -52,7 +54,7 @@ public static DocumentBuilderFactory newInstance() {
5254
try {
5355
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
5456
}
55-
catch (IllegalArgumentException e) {
57+
catch (IllegalArgumentException ex) {
5658
if (log.isWarnEnabled()) {
5759
log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by "
5860
+ factory.getClass().getCanonicalName());
@@ -62,7 +64,7 @@ public static DocumentBuilderFactory newInstance() {
6264
try {
6365
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
6466
}
65-
catch (ParserConfigurationException e) {
67+
catch (ParserConfigurationException ex) {
6668
if (log.isWarnEnabled()) {
6769
log.warn("FEATURE 'http://apache.org/xml/features/disallow-doctype-decl' is probably not supported by "
6870
+ factory.getClass().getCanonicalName());
@@ -72,7 +74,7 @@ public static DocumentBuilderFactory newInstance() {
7274
try {
7375
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
7476
}
75-
catch (ParserConfigurationException e) {
77+
catch (ParserConfigurationException ex) {
7678
if (log.isWarnEnabled()) {
7779
log.warn("FEATURE 'http://xml.org/sax/features/external-general-entities' is probably not supported by "
7880
+ factory.getClass().getCanonicalName());
@@ -82,7 +84,7 @@ public static DocumentBuilderFactory newInstance() {
8284
try {
8385
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
8486
}
85-
catch (ParserConfigurationException e) {
87+
catch (ParserConfigurationException ex) {
8688
if (log.isWarnEnabled()) {
8789
log.warn(
8890
"FEATURE 'http://xml.org/sax/features/external-parameter-entities' is probably not supported by "
@@ -93,7 +95,7 @@ public static DocumentBuilderFactory newInstance() {
9395
try {
9496
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
9597
}
96-
catch (ParserConfigurationException e) {
98+
catch (ParserConfigurationException ex) {
9799
if (log.isWarnEnabled()) {
98100
log.warn(
99101
"FEATURE 'http://apache.org/xml/features/nonvalidating/load-external-dtd' is probably not supported by "
@@ -105,9 +107,9 @@ public static DocumentBuilderFactory newInstance() {
105107
factory.setXIncludeAware(false);
106108
factory.setExpandEntityReferences(false);
107109
}
108-
catch (Exception e) {
110+
catch (Exception ex) {
109111
if (log.isWarnEnabled()) {
110-
log.warn("Caught " + e.getMessage() + " attempting to configure your XML parser.");
112+
log.warn("Caught " + ex.getMessage() + " attempting to configure your XML parser.");
111113
}
112114
}
113115

spring-xml/src/main/java/org/springframework/xml/JaxpVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public abstract class JaxpVersion {
7474
ClassUtils.forName(JAXP_14_CLASS_NAME, classLoader);
7575
jaxpVersion = JAXP_14;
7676
}
77-
catch (ClassNotFoundException e) {
77+
catch (ClassNotFoundException ex2) {
7878
// leave 1.3 as default (it's either 1.3 or unknown)
7979
jaxpVersion = JAXP_13;
8080
}

spring-xml/src/main/java/org/springframework/xml/XMLInputFactoryUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import javax.xml.stream.XMLInputFactory;
2020

2121
/**
22+
* General utilities for {@link XMLInputFactory}.
23+
*
2224
* @author Greg Turnquist
2325
*/
24-
public class XMLInputFactoryUtils {
26+
public abstract class XMLInputFactoryUtils {
2527

2628
/**
2729
* Build an {@link XMLInputFactory} and set properties to prevent external entities

spring-xml/src/main/java/org/springframework/xml/namespace/QNameUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public abstract class QNameUtils {
4141
* @param localPart local part of the {@code QName}
4242
* @param prefix prefix of the {@code QName}. May be ignored.
4343
* @return the created {@code QName}
44-
* @see QName#QName(String,String,String)
4544
* @deprecated in favor of {@link QName#QName(String, String, String)}
45+
* @see QName#QName(String,String,String)
4646
*/
4747
@Deprecated
4848
public static QName createQName(String namespaceUri, String localPart, String prefix) {
@@ -56,16 +56,16 @@ public static QName createQName(String namespaceUri, String localPart, String pr
5656
* returned.
5757
* @param qName the {@code QName} to return the prefix from
5858
* @return the prefix, if available, or an empty string
59-
* @see javax.xml.namespace.QName#getPrefix()
6059
* @deprecated in favor of {@link QName#getPrefix()}
60+
* @see javax.xml.namespace.QName#getPrefix()
6161
*/
6262
@Deprecated
6363
public static String getPrefix(QName qName) {
6464
return qName.getPrefix();
6565
}
6666

6767
/**
68-
* Validates the given String as a QName
68+
* Validates the given String as a QName.
6969
* @param text the qualified name
7070
* @return {@code true} if valid, {@code false} otherwise
7171
*/

spring-xml/src/main/java/org/springframework/xml/transform/TransformerFactoryUtils.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
import org.apache.commons.logging.LogFactory;
2727

2828
/**
29+
* General utilities of {@link TransformerFactory}.
30+
*
2931
* @author Greg Turnquist
3032
* @since 3.0.5
3133
*/
32-
public class TransformerFactoryUtils {
34+
public abstract class TransformerFactoryUtils {
3335

3436
private static final Log log = LogFactory.getLog(TransformerFactoryUtils.class);
3537

@@ -48,8 +50,8 @@ public static TransformerFactory newInstance(Class<? extends TransformerFactory>
4850
try {
4951
return defaultSettings(transformerFactoryClass.getDeclaredConstructor().newInstance());
5052
}
51-
catch (InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException e) {
52-
throw new TransformerFactoryConfigurationError(e,
53+
catch (InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException ex) {
54+
throw new TransformerFactoryConfigurationError(ex,
5355
"Could not instantiate TransformerFactory [" + transformerFactoryClass + "]");
5456
}
5557
}
@@ -61,7 +63,7 @@ private static TransformerFactory defaultSettings(TransformerFactory factory) {
6163
try {
6264
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
6365
}
64-
catch (IllegalArgumentException e) {
66+
catch (IllegalArgumentException ex) {
6567
if (log.isWarnEnabled()) {
6668
log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by "
6769
+ factory.getClass().getCanonicalName());
@@ -71,7 +73,7 @@ private static TransformerFactory defaultSettings(TransformerFactory factory) {
7173
try {
7274
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
7375
}
74-
catch (IllegalArgumentException e) {
76+
catch (IllegalArgumentException ex) {
7577
if (log.isWarnEnabled()) {
7678
log.warn(XMLConstants.ACCESS_EXTERNAL_STYLESHEET + " property not supported by "
7779
+ factory.getClass().getCanonicalName());

spring-xml/src/main/java/org/springframework/xml/transform/TransformerHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public TransformerFactory getTransformerFactory() {
100100
synchronized (this) {
101101
result = this.transformerFactory;
102102
if (result == null) {
103-
this.transformerFactory = result = newTransformerFactory(this.transformerFactoryClass);
103+
result = newTransformerFactory(this.transformerFactoryClass);
104+
this.transformerFactory = result;
104105
}
105106
}
106107
}

spring-xml/src/main/java/org/springframework/xml/validation/Jaxp13ValidatorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private static final class Jaxp13Validator implements XmlValidator {
5252

5353
private Schema schema;
5454

55-
public Jaxp13Validator(Schema schema) {
55+
Jaxp13Validator(Schema schema) {
5656
this.schema = schema;
5757
}
5858

spring-xml/src/main/java/org/springframework/xml/validation/Jaxp15ValidatorFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static final class Jaxp15Validator implements XmlValidator {
6060

6161
private Schema schema;
6262

63-
public Jaxp15Validator(Schema schema) {
63+
Jaxp15Validator(Schema schema) {
6464
this.schema = schema;
6565
}
6666

@@ -79,7 +79,7 @@ public SAXParseException[] validate(Source source, ValidationErrorHandler errorH
7979
try {
8080
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
8181
}
82-
catch (SAXNotRecognizedException | SAXNotSupportedException e) {
82+
catch (SAXNotRecognizedException | SAXNotSupportedException ex) {
8383
if (log.isWarnEnabled()) {
8484
log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by "
8585
+ validator.getClass().getCanonicalName());
@@ -89,7 +89,7 @@ public SAXParseException[] validate(Source source, ValidationErrorHandler errorH
8989
try {
9090
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
9191
}
92-
catch (SAXNotRecognizedException | SAXNotSupportedException e) {
92+
catch (SAXNotRecognizedException | SAXNotSupportedException ex) {
9393
if (log.isWarnEnabled()) {
9494
log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by "
9595
+ validator.getClass().getCanonicalName());

spring-xml/src/main/java/org/springframework/xml/validation/SchemaFactoryUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
import org.springframework.util.ResourceUtils;
2828

2929
/**
30+
* General utilities for {@link SchemaFactory}.
31+
*
3032
* @author Greg Turnquist
3133
* @since 3.0.5
3234
*/
33-
public class SchemaFactoryUtils {
35+
public abstract class SchemaFactoryUtils {
3436

3537
private static final Log log = LogFactory.getLog(SchemaFactoryUtils.class);
3638

@@ -45,7 +47,7 @@ public static SchemaFactory newInstance(String schemaLanguage) {
4547
try {
4648
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
4749
}
48-
catch (SAXNotRecognizedException | SAXNotSupportedException e) {
50+
catch (SAXNotRecognizedException | SAXNotSupportedException ex) {
4951
if (log.isWarnEnabled()) {
5052
log.warn(XMLConstants.ACCESS_EXTERNAL_DTD + " property not supported by "
5153
+ schemaFactory.getClass().getCanonicalName());
@@ -57,7 +59,7 @@ public static SchemaFactory newInstance(String schemaLanguage) {
5759
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ResourceUtils.URL_PROTOCOL_FILE + ","
5860
+ "jar:file" + "," + "nested" + "," + ResourceUtils.URL_PROTOCOL_WSJAR);
5961
}
60-
catch (SAXNotRecognizedException | SAXNotSupportedException e) {
62+
catch (SAXNotRecognizedException | SAXNotSupportedException ex) {
6163
if (log.isWarnEnabled()) {
6264
log.warn(XMLConstants.ACCESS_EXTERNAL_SCHEMA + " property not supported by "
6365
+ schemaFactory.getClass().getCanonicalName());

spring-xml/src/main/java/org/springframework/xml/validation/SchemaLoaderUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static String getSystemId(Resource resource) {
8585
try {
8686
return resource.getURL().toString();
8787
}
88-
catch (IOException e) {
88+
catch (IOException ex) {
8989
return null;
9090
}
9191
}

0 commit comments

Comments
 (0)