File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
spring-batch-infrastructure/src
main/java/org/springframework/batch/item/xml
test/java/org/springframework/batch/item/xml Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 59
59
*
60
60
* @author Robert Kasanicky
61
61
* @author Mahmoud Ben Hassine
62
+ * @author Glenn Renfro
62
63
*/
63
64
public class StaxEventItemReader <T > extends AbstractItemCountingItemStreamItemReader <T >
64
65
implements ResourceAwareItemReaderItemStream <T >, InitializingBean {
@@ -225,14 +226,16 @@ protected void doOpen() throws Exception {
225
226
noInput = true ;
226
227
if (!resource .exists ()) {
227
228
if (strict ) {
228
- throw new IllegalStateException ("Input resource must exist (reader is in 'strict' mode)" );
229
+ throw new IllegalStateException (
230
+ "Input resource " + resource .getURL () + " must exist (reader is in 'strict' mode)" );
229
231
}
230
232
logger .warn ("Input resource does not exist " + resource .getDescription ());
231
233
return ;
232
234
}
233
235
if (!resource .isReadable ()) {
234
236
if (strict ) {
235
- throw new IllegalStateException ("Input resource must be readable (reader is in 'strict' mode)" );
237
+ throw new IllegalStateException (
238
+ "Input resource " + resource .getURL () + " must be readable (reader is in 'strict' mode)" );
236
239
}
237
240
logger .warn ("Input resource is not readable " + resource .getDescription ());
238
241
return ;
Original file line number Diff line number Diff line change 47
47
import java .io .File ;
48
48
import java .io .IOException ;
49
49
import java .io .InputStream ;
50
+ import java .net .URL ;
50
51
import java .nio .ByteBuffer ;
51
52
import java .nio .charset .Charset ;
52
53
import java .nio .charset .StandardCharsets ;
71
72
* @author Robert Kasanicky
72
73
* @author Michael Minella
73
74
* @author Mahmoud Ben Hassine
75
+ * @author Glenn Renfro
74
76
*/
75
77
class StaxEventItemReaderTests {
76
78
@@ -582,7 +584,9 @@ void testStrictness() throws Exception {
582
584
source .setStrict (true );
583
585
source .afterPropertiesSet ();
584
586
585
- assertThrows (ItemStreamException .class , () -> source .open (executionContext ));
587
+ ItemStreamException exception = assertThrows (ItemStreamException .class , () -> source .open (executionContext ));
588
+ assertEquals ("Input resource file:/non/existent/file must exist (reader is in 'strict' mode)" ,
589
+ exception .getCause ().getMessage ());
586
590
587
591
}
588
592
@@ -834,6 +838,11 @@ public InputStream getInputStream() throws IOException {
834
838
return null ;
835
839
}
836
840
841
+ @ Override
842
+ public URL getURL () throws IOException {
843
+ return new URL ("file:/non/existent/file" );
844
+ }
845
+
837
846
}
838
847
839
848
}
You can’t perform that action at this time.
0 commit comments