Several of the existing MDA stages accept a Spring Resource as input, and attempt to validate this by testing for "existence" as part of stage initialization. For example, in DOMResourceSourceStage:
If the Resource refers to, say, a local file, this provides rapid termination which is a good thing. For other resource types, such as Spring's UrlResource or our HTTPResource, it can be counter-productive:
- It replaces a run-time check as to whether the resource exists when the stage is executed with one which checks whether the resource exists when the stage is initialized.
- It provides no details about the nature of the failure (was the URL invalid? did it return a 404, a 500 or something else?)
- In the case of a large HTTP-based resource which doesn't respond to HEAD, causes the resource to be downloaded twice.
We should enumerate the places where Resource#exists() is used, and remove these checks from places where they are subtracting value rather than adding it. We also need to document the change in behaviour: for example, whether a resulting failure will still be reported at initialization time, or whether it will be deferred to (each) execution of the stage.