Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-1419

Simplify session management handling (IllegalStateException when integ tests complete).

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.12.1
    • Fix Version/s: 1.13.0
    • Component/s: Core
    • Labels:
      None

      Description

      This exception is the result of stricter exception handling introduced during
      ISIS-1414:

      } else {
                              T service = serviceByThread.get();
                              if(service == null) {
                                  // shouldn't happen...
                                  throw new IllegalStateException("No service of type " + cls + " is available on this ");
                              }
                              final Object proxiedReturn = proxyMethod.invoke(service, args);
                              return proxiedReturn;
      

      resulting in the following exception when integ tests complete:

      11:03:24,485  [IsisContext          Thread-1   INFO ]  Shutting down thread: main
      java.lang.IllegalStateException: No service of type class org.apache.isis.applib.services.command.CommandContext is available on this 
      	at org.apache.isis.core.runtime.services.ServiceInstantiator$2.invoke(ServiceInstantiator.java:217)
      	at org.apache.isis.applib.services.command.CommandContext_$$_jvst3a6_2.getCommand(CommandContext_$$_jvst3a6_2.java)
      	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.completeCommandFromInteractionAndClearDomainEvents(PersistenceSession.java:489)
      	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.close(PersistenceSession.java:424)
      	at org.apache.isis.core.runtime.system.session.IsisSession.close(IsisSession.java:95)
      	at org.apache.isis.core.runtime.system.session.IsisSession.closeAll(IsisSession.java:111)
      	at org.apache.isis.core.runtime.system.context.IsisContext.shutdownAllThreads(IsisContext.java:601)
      	at org.apache.isis.core.runtime.system.context.IsisContext.closeAllSessionsInstance(IsisContext.java:274)
      	at org.apache.isis.core.runtime.system.context.IsisContext.closeAllSessions(IsisContext.java:363)
      	at org.apache.isis.core.runtime.system.IsisSystem.shutdown(IsisSystem.java:344)
      	at org.apache.isis.core.integtestsupport.IsisSystemForTest.shutdown(IsisSystemForTest.java:490)
      	at org.apache.isis.core.integtestsupport.IsisSystemForTest.access$100(IsisSystemForTest.java:76)
      	at org.apache.isis.core.integtestsupport.IsisSystemForTest$Builder$1.run(IsisSystemForTest.java:302)
      

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit a5876219839bc5d5c366d4b1e8fd1dae1eef0a18 in isis's branch refs/heads/master from Dan Haywood
        [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=a587621 ]

        ISIS-1419: calling bounceSystem (misnamed, just means close and re-open a session) at the end of each test.

        Show
        jira-bot ASF subversion and git services added a comment - Commit a5876219839bc5d5c366d4b1e8fd1dae1eef0a18 in isis's branch refs/heads/master from Dan Haywood [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=a587621 ] ISIS-1419 : calling bounceSystem (misnamed, just means close and re-open a session) at the end of each test.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e38eaf7b90841314ae37c5cc4610d838f513492b in isis's branch refs/heads/master from Dan Haywood
        [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=e38eaf7 ]

        ISIS-1419: simplified Session management.

        The exception resulting, I believe, from lack of symmetry in the integ tests: they set up a single session for all tests, but in the shutdown (called by a Runtime hook), create a different session again to perform the @PreDestroy stuff. In this commit, I've decided to get rid of this shutdown stuff, basically orphaning that initial session (it is never closed down, but then the JVM quits anyway, and this is for an inmemory databases so no real harm).

        A subsequent commit will take look to close the session in the teardown of each test.

        In detail:

        • in IsisContext, change the Map<Thread,IsisSession> into a simple ThreadLocal. remove the logic to save every IsisSession in this map, and remove the closeAllSessionsInstance(). In IsisSession, remove the id() and sessionOpenTime properties (now unused), and remove closeAll() - was now just the same as close();
        • in PersistenceSession, split out calling of _isis_startRequest/isis_postConstruct and then __isis_preDestroy/_isis_endRequest into two loops, just so easier to move around if need be. (Currently, calling one after the other, so no functional change here).

        Also:

        • no longer allow the ProgrammingModel to be overridden (in IsisComponentProviderDefault, IsisComponentProviderDefault2, IsisSystemForTest, IsisMojoAbstract)
        • reformatted IsisSystemForTest (comments), also WebRequestCycleForIsis
        • ServiceInitializer, introduced constructor for state (rather than pass into validate(...)); updated IsisSystem correspondingly
        • removed unused method in DeploymentType
        Show
        jira-bot ASF subversion and git services added a comment - Commit e38eaf7b90841314ae37c5cc4610d838f513492b in isis's branch refs/heads/master from Dan Haywood [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=e38eaf7 ] ISIS-1419 : simplified Session management. The exception resulting, I believe, from lack of symmetry in the integ tests: they set up a single session for all tests, but in the shutdown (called by a Runtime hook), create a different session again to perform the @PreDestroy stuff. In this commit, I've decided to get rid of this shutdown stuff, basically orphaning that initial session (it is never closed down, but then the JVM quits anyway, and this is for an inmemory databases so no real harm). A subsequent commit will take look to close the session in the teardown of each test. In detail: in IsisContext, change the Map<Thread,IsisSession> into a simple ThreadLocal. remove the logic to save every IsisSession in this map, and remove the closeAllSessionsInstance(). In IsisSession, remove the id() and sessionOpenTime properties (now unused), and remove closeAll() - was now just the same as close(); in PersistenceSession, split out calling of _ isis_startRequest/ isis_postConstruct and then __isis_preDestroy/ _isis_endRequest into two loops, just so easier to move around if need be. (Currently, calling one after the other, so no functional change here). Also: no longer allow the ProgrammingModel to be overridden (in IsisComponentProviderDefault, IsisComponentProviderDefault2, IsisSystemForTest, IsisMojoAbstract) reformatted IsisSystemForTest (comments), also WebRequestCycleForIsis ServiceInitializer, introduced constructor for state (rather than pass into validate(...)); updated IsisSystem correspondingly removed unused method in DeploymentType

          People

          • Assignee:
            danhaywood Dan Haywood
            Reporter:
            danhaywood Dan Haywood
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development