Uploaded image for project: 'Spring Batch'
  1. Spring Batch
  2. BATCH-734

ItemReaders and ItemWriters using Resource(s) should check for file during ItemStream#open

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.1.2, 2.0.0.M1
    • Component/s: Core
    • Labels:
      None

      Description

      During bean initialization MultiResourceItemReader checks [in afterPropertiesSet()] that it actually has resources to read. If not, it throws an exception. There are use cases where the resources might not be created at bean initialization time (see http://forum.springframework.org/showthread.php?t=57502 for details).

      Lucas Ward suggests that this check might better be made during ItemStream#open().

        Activity

        Hide
        robert.kasanicky Robert Kasanicky added a comment -

        Resources are checked for existance in afterPropertiesSet() in all ItemReaders reading from a Resource - I think we should be consistent and either change them all to do the check in open(..) or advocate using a resource proxy for MultiResourceItemReader.

        Show
        robert.kasanicky Robert Kasanicky added a comment - Resources are checked for existance in afterPropertiesSet() in all ItemReaders reading from a Resource - I think we should be consistent and either change them all to do the check in open(..) or advocate using a resource proxy for MultiResourceItemReader.
        Hide
        david_syer Dave Syer added a comment -

        Checking in open() makes sense in a lot of circumstances. I reckon we should do that by default (and maybe add a failFastIfResourceAbsent flag for the old behaviour).

        Show
        david_syer Dave Syer added a comment - Checking in open() makes sense in a lot of circumstances. I reckon we should do that by default (and maybe add a failFastIfResourceAbsent flag for the old behaviour).
        Hide
        robert.kasanicky Robert Kasanicky added a comment -

        generalized issue description

        Show
        robert.kasanicky Robert Kasanicky added a comment - generalized issue description
        Hide
        robert.kasanicky Robert Kasanicky added a comment -

        further generalized summary to include ItemWriters

        Show
        robert.kasanicky Robert Kasanicky added a comment - further generalized summary to include ItemWriters
        Hide
        robert.kasanicky Robert Kasanicky added a comment -

        moved the resource checks from afterPropertiesSet() to open(..) in both ItemReaders and ItemWriters

        Show
        robert.kasanicky Robert Kasanicky added a comment - moved the resource checks from afterPropertiesSet() to open(..) in both ItemReaders and ItemWriters
        Hide
        gregabell Greg Abell added a comment -

        Per forum post http://forum.springframework.org/showthread.php?t=58604, I'd really like to see this get into V1.1.2. I've done a work around – extended MultiResourceItemReader overriding afterPropertiesSet() to do nothing – but I won't be able to use V2.0 when available because I'm stuck on Java 1.4 until 2009 and my application deploys this year. Your fix to the trunk is much more comprehensive wrt ItemReader's and ItemWriter's.

        Show
        gregabell Greg Abell added a comment - Per forum post http://forum.springframework.org/showthread.php?t=58604 , I'd really like to see this get into V1.1.2. I've done a work around – extended MultiResourceItemReader overriding afterPropertiesSet() to do nothing – but I won't be able to use V2.0 when available because I'm stuck on Java 1.4 until 2009 and my application deploys this year. Your fix to the trunk is much more comprehensive wrt ItemReader's and ItemWriter's.
        Hide
        david_syer Dave Syer added a comment -

        Re-opened to merge fix into 1.1

        Show
        david_syer Dave Syer added a comment - Re-opened to merge fix into 1.1
        Hide
        lucas.l.ward Lucas Ward added a comment -

        Merged with 1.1 (reviewed by Dave), closing.

        Show
        lucas.l.ward Lucas Ward added a comment - Merged with 1.1 (reviewed by Dave), closing.

          People

          • Assignee:
            lucas.l.ward Lucas Ward
            Reporter:
            gregabell Greg Abell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25d Original Estimate - 0.25d
              0.25d
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 3h
              3h