ICEfaces
  1. ICEfaces
  2. ICE-10803

Emporium sample: Threads are not getting properly cleaned up

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0, EE-4.0.0.GA
    • Fix Version/s: None
    • Component/s: Sample Apps
    • Labels:
      None
    • Environment:
      Tomcat 7.0.59, Emporium

      Description

      The Threads created and used by the Emporium sample are not getting properly cleaned up.

        Activity

        Repository Revision Date User Message
        ICEsoft Public SVN Repository #46001 Tue Sep 22 12:42:53 MDT 2015 jack.van.ooststroom Fixed JIRA ICE-10803 : Emporium sample: Threads are not getting properly cleaned up
        Files Changed
        Commit graph ADD /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/robot/BidRobotMonitor.java
        Commit graph MODIFY /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/robot/BidRobot.java
        Commit graph MODIFY /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/util/ContextListener.java
        Jack Van Ooststroom created issue -
        Jack Van Ooststroom made changes -
        Field Original Value New Value
        Assignee Jack Van Ooststroom [ jack.van.ooststroom ]
        Hide
        Jack Van Ooststroom added a comment -

        Sending src/main/java/org/icefaces/demo/emporium/robot/BidRobot.java
        Adding src/main/java/org/icefaces/demo/emporium/robot/BidRobotMonitor.java
        Sending src/main/java/org/icefaces/demo/emporium/util/ContextListener.java
        Transmitting file data ...
        Committed revision 46001.

        Show
        Jack Van Ooststroom added a comment - Sending src/main/java/org/icefaces/demo/emporium/robot/BidRobot.java Adding src/main/java/org/icefaces/demo/emporium/robot/BidRobotMonitor.java Sending src/main/java/org/icefaces/demo/emporium/util/ContextListener.java Transmitting file data ... Committed revision 46001.
        Hide
        Jack Van Ooststroom added a comment -

        In order to achieve proper Thread clean-up the following has been done:

        • Introduced an @ApplicationScoped @ManagedBean BidRobotMonitor which serves as a singleton to which each BidRobot instance adds itself in its @PostConstruct and from which each BidRobot instance removes itself in its @PreDestroy.
        • Upon ServletContextListener's contextDestroyed(...) method invocation the BidRobotMonitor's cleanUp() method is invoked, which stops any remaining BidRobot instance it still contains in its Set<BidRobot> collection.
        • The BidRobot has 2 newly introduced methods, namely the sleep(...) and stop() methods. The sleep(...) method handles the Thread.sleep(...) invocation in 100 ms intervals to allow for a clean Thread stoppage. The stop() method is internally used as well by the BidRobotMonitor's cleanUp() method if needed.

        Marking this one as FIXED.

        Show
        Jack Van Ooststroom added a comment - In order to achieve proper Thread clean-up the following has been done: Introduced an @ApplicationScoped @ManagedBean BidRobotMonitor which serves as a singleton to which each BidRobot instance adds itself in its @PostConstruct and from which each BidRobot instance removes itself in its @PreDestroy . Upon ServletContextListener 's contextDestroyed(...) method invocation the BidRobotMonitor 's cleanUp() method is invoked, which stops any remaining BidRobot instance it still contains in its Set<BidRobot> collection. The BidRobot has 2 newly introduced methods, namely the sleep(...) and stop() methods. The sleep(...) method handles the Thread.sleep(...) invocation in 100 ms intervals to allow for a clean Thread stoppage. The stop() method is internally used as well by the BidRobotMonitor 's cleanUp() method if needed. Marking this one as FIXED.
        Jack Van Ooststroom made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #46006 Tue Sep 22 14:24:09 MDT 2015 carlo.guglielmin ICE-10803 - Code consistency to match source for public consumption
        Files Changed
        Commit graph MODIFY /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/robot/BidRobotMonitor.java
        Commit graph MODIFY /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/robot/BidRobot.java
        Commit graph MODIFY /icefaces4/trunk/icefaces/samples/ace/emporium/src/main/java/org/icefaces/demo/emporium/util/ContextListener.java
        Hide
        Liana Munroe added a comment -

        Tested with ICEfaces 4 trunk r46005. Tomcat 7 & 8, Chrome 45, FF 34, IE 11.
        I came across this server entry only once while shutting down Tomcat and was not able to reproduce it after several more attempts. The actions taken before shutdown were several bids, adding a new item, using chat, bidding again, then removing emporium.war from server.
        Server log:
        INFO: Stop requested for java.util.concurrent.Executors$DelegatedScheduledExecut
        orService@6fab0b9a.
        Sep 22, 2015 3:47:20 PM org.icefaces.demo.emporium.watcher.base.ThreadedWatcher
        stop
        INFO: Stop requested for java.util.concurrent.Executors$DelegatedScheduledExecut
        orService@421316d0.
        Sep 22, 2015 3:47:21 PM org.apache.catalina.loader.WebappClassLoader clearRefere
        ncesThreads
        SEVERE: The web application [/emporium] appears to have started a thread named [
        Emporium BidRobot (13 bids)] but has failed to stop it. This is very likely to c
        reate a memory leak.
        Sep 22, 2015 3:47:21 PM org.apache.catalina.loader.WebappClassLoader checkThread
        LocalMapForLeaks
        SEVERE: The web application [/emporium] created a ThreadLocal with key of type [
        com.sun.faces.application.ApplicationAssociate$1] (value [com.sun.faces.applicat
        ion.ApplicationAssociate$1@2cd77530]) and a value of type [com.sun.faces.applica
        tion.ApplicationAssociate] (value [com.sun.faces.application.ApplicationAssociat
        e@754eb94f]) but failed to remove it when the web application was stopped. Threa
        ds are going to be renewed over time to try and avoid a probable memory leak.

        Show
        Liana Munroe added a comment - Tested with ICEfaces 4 trunk r46005. Tomcat 7 & 8, Chrome 45, FF 34, IE 11. I came across this server entry only once while shutting down Tomcat and was not able to reproduce it after several more attempts. The actions taken before shutdown were several bids, adding a new item, using chat, bidding again, then removing emporium.war from server. Server log: INFO: Stop requested for java.util.concurrent.Executors$DelegatedScheduledExecut orService@6fab0b9a. Sep 22, 2015 3:47:20 PM org.icefaces.demo.emporium.watcher.base.ThreadedWatcher stop INFO: Stop requested for java.util.concurrent.Executors$DelegatedScheduledExecut orService@421316d0. Sep 22, 2015 3:47:21 PM org.apache.catalina.loader.WebappClassLoader clearRefere ncesThreads SEVERE: The web application [/emporium] appears to have started a thread named [ Emporium BidRobot (13 bids)] but has failed to stop it. This is very likely to c reate a memory leak. Sep 22, 2015 3:47:21 PM org.apache.catalina.loader.WebappClassLoader checkThread LocalMapForLeaks SEVERE: The web application [/emporium] created a ThreadLocal with key of type [ com.sun.faces.application.ApplicationAssociate$1] (value [com.sun.faces.applicat ion.ApplicationAssociate$1@2cd77530]) and a value of type [com.sun.faces.applica tion.ApplicationAssociate] (value [com.sun.faces.application.ApplicationAssociat e@754eb94f]) but failed to remove it when the web application was stopped. Threa ds are going to be renewed over time to try and avoid a probable memory leak.
        Hide
        Jack Van Ooststroom added a comment -

        I will have a look at this. I might have missed something.

        Show
        Jack Van Ooststroom added a comment - I will have a look at this. I might have missed something.
        Jack Van Ooststroom made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Hide
        Jack Van Ooststroom added a comment -

        Marking it as resolved again for now. Both Liana and I were unable to reproduce this again. When we encounter it again and we can reproduce it, we can reopen this issue and I'll have another closer look.

        Show
        Jack Van Ooststroom added a comment - Marking it as resolved again for now. Both Liana and I were unable to reproduce this again. When we encounter it again and we can reproduce it, we can reopen this issue and I'll have another closer look.
        Jack Van Ooststroom made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Jack Van Ooststroom
            Reporter:
            Jack Van Ooststroom
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: