Spring Security
  1. Spring Security
  2. SEC-1104

Server created by ApacheDSContainer is shutdown twice, causing a hang

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 3.0.0 M1
    • Component/s: LDAP
    • Labels:
      None

      Description

      I have a default ApacheDS server launched for testing via <ldap-server/> element in my spring config. This is inside a webapp, and the context is loaded through a servlet context listener (if that makes any difference).

      ApacheDSContainer implements both Lifecycle and DisposableBean. Both destroy methods get called, but neither checks the 'running' field before trying to shut down the ApacheDS server. The first shutdown works, but since the server is contacted over a socket, the second attempt hangs until the socket times out.

      The easy fix is to just check the 'running' field in the stop() method and don't do anything if the server isn't running.

        Activity

        Hide
        Brian Topping added a comment -

        On further inspection, this problem was coincidental to starting to use the ApacheDSContainer, not causal. I believe there is a problem calling the stop method twice, although after cleaning up the code, my issue remains. So this could be set to a low priority or closed, although I will attach the patch here regardless.

        Show
        Brian Topping added a comment - On further inspection, this problem was coincidental to starting to use the ApacheDSContainer, not causal. I believe there is a problem calling the stop method twice, although after cleaning up the code, my issue remains. So this could be set to a low priority or closed, although I will attach the patch here regardless.
        Hide
        Brian Topping added a comment -

        Patch for ApacheDSContainer.java to clean up lifecycle semantics

        Show
        Brian Topping added a comment - Patch for ApacheDSContainer.java to clean up lifecycle semantics
        Hide
        Luke Taylor added a comment -

        Thanks for the report. I've added a check of the "running" flag in the stop() method but I've retained the Lifecycle interface (unlike your patch). The same bean instance could potentially be started and stopped without necessarily being destroyed.

        Show
        Luke Taylor added a comment - Thanks for the report. I've added a check of the "running" flag in the stop() method but I've retained the Lifecycle interface (unlike your patch). The same bean instance could potentially be started and stopped without necessarily being destroyed.

          People

          • Assignee:
            Luke Taylor
            Reporter:
            Brian Topping
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: