Skip to content

Commit 3b0eca9

Browse files
committed
Refined exception messages
1 parent efe2539 commit 3b0eca9

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public static void enableIndenting(Transformer transformer) {
5454
* Enable indenting for the supplied {@link javax.xml.transform.Transformer}.
5555
* <p>If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount}
5656
* will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters.
57-
* @param transformer the target transformer
58-
* @param indentAmount the size of the indent (2 characters, 3 characters, etc.)
57+
* @param transformer the target transformer
58+
* @param indentAmount the size of the indent (2 characters, 3 characters, etc)
5959
* @see javax.xml.transform.Transformer#setOutputProperty(String, String)
6060
* @see javax.xml.transform.OutputKeys#INDENT
6161
*/
6262
public static void enableIndenting(Transformer transformer, int indentAmount) {
6363
Assert.notNull(transformer, "Transformer must not be null");
6464
if (indentAmount < 0) {
65-
throw new IllegalArgumentException("The indent amount cannot be less than zero : got " + indentAmount);
65+
throw new IllegalArgumentException("Invalid indent amount (must not be less than zero): " + indentAmount);
6666
}
6767
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
6868
try {

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,8 @@ private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IO
555555
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
556556
for (int i = 0; i < resources.length; i++) {
557557
Resource resource = resources[i];
558-
Assert.notNull(resource, "Resource is null");
559-
if (!resource.exists()) {
560-
throw new IllegalArgumentException("Resource " + resource + " does not exist");
558+
if (resource == null || !resource.exists()) {
559+
throw new IllegalArgumentException("Resource does not exist: " + resource);
561560
}
562561
InputSource inputSource = SaxResourceUtils.createInputSource(resource);
563562
schemaSources[i] = new SAXSource(xmlReader, inputSource);
@@ -572,8 +571,8 @@ private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IO
572571

573572
@Override
574573
public boolean supports(Class<?> clazz) {
575-
return ((this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) ||
576-
supportsInternal(clazz, this.checkForXmlRootElement));
574+
return (this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) ||
575+
supportsInternal(clazz, this.checkForXmlRootElement);
577576
}
578577

579578
@Override

0 commit comments

Comments
 (0)