Uploaded image for project: 'Metadata Aggregator'
  1. Metadata Aggregator
  2. MDA-219

Reconsider use of Resource#exists in MDA stage initialisation



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.2
    • Fix Version/s: None
    • Component/s: DOM Metadata, Validation
    • Labels:


      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 (!domResource.exists()) {
          throw new ComponentInitializationException("Unable to initialize " + getId() + ", DOM resource "
                 + domResource.getDescription() + " does not exist");

      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.




            ian@iay.org.uk Ian Young
            ian@iay.org.uk Ian Young
            2 Start watching this issue