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

command-line tool should shut down Spring context

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.8.0
    • Fix Version/s: 0.9.0
    • Component/s: Command Line
    • Labels:
      None

      Description

      I don't think the Spring context created by the command-line tool provided with the metadata aggregator correctly shuts down the Spring context on termination. This is probably mostly harmless, but the Spring documentation cautions that you should really register a shutdown hook in a non-web application to make sure that all destroy methods are called and resources are released:

      import org.springframework.context.support.AbstractApplicationContext;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
      
      public final class Boot {
      
          public static void main(final String[] args) throws Exception {
      
              AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
                      new String []{"beans.xml"});
      
              // add a shutdown hook for the above context...
              ctx.registerShutdownHook();
      
              // app runs here...
      
              // main method exits, hook is called prior to the app shutting down...
      
          }
      }
      

        Attachments

          Activity

            People

            Assignee:
            ian@iay.org.uk Ian Young
            Reporter:
            ian@iay.org.uk Ian Young
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 49 minutes
                49m