Tapestry 5
  1. Tapestry 5
  2. TAP5-1765

PerThread scope is not honored when service is created using autobuild

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.3
    • Fix Version/s: 5.3.1, 5.4
    • Component/s: tapestry-ioc
    • Labels:
      None

      Description

      Bug is possible to reproduce by modifying IOC test class PerThreadModule:

      from:

      @Scope(ScopeConstants.PERTHREAD)
      public StringHolder buildStringHolder()

      { return new StringHolderImpl(); }

      to:

      @Scope(ScopeConstants.PERTHREAD)
      public StringHolder buildStringHolder(@Autobuild StringHolderImpl impl)

      { return impl; }

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        I was about to dismiss this out of hand, but I realized some optimizations in 5.3 could account for this; it may be that @Autobuild StringHolderImpl is created just once, and then passed to buildStringHolder() each time it is invoked from the per thread service lifecycle.

        Show
        Howard M. Lewis Ship added a comment - I was about to dismiss this out of hand, but I realized some optimizations in 5.3 could account for this; it may be that @Autobuild StringHolderImpl is created just once, and then passed to buildStringHolder() each time it is invoked from the per thread service lifecycle.
        Hide
        Howard M. Lewis Ship added a comment -

        The workaround is to inject the ObjectLocator and invoke autobuild() on it within your build method. I'm adding code to special case @Autobuild to be a new instance on each method invocation.

        Show
        Howard M. Lewis Ship added a comment - The workaround is to inject the ObjectLocator and invoke autobuild() on it within your build method. I'm adding code to special case @Autobuild to be a new instance on each method invocation.
        Hide
        Denis Stepanov added a comment -

        I'm more concerned about Upload's MultipartDecoder being broken because of that, I have fixed it in my code but everyone else could encounter critical problems.

        Show
        Denis Stepanov added a comment - I'm more concerned about Upload's MultipartDecoder being broken because of that, I have fixed it in my code but everyone else could encounter critical problems.
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #633 (See https://builds.apache.org/job/tapestry-trunk-freestyle/633/)
        TAP5-1765: PerThread scope is not honored when service is created using autobuild

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1209175
        Files :

        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ContributionDefImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConstructorInvoker.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/MethodInvoker.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #633 (See https://builds.apache.org/job/tapestry-trunk-freestyle/633/ ) TAP5-1765 : PerThread scope is not honored when service is created using autobuild hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1209175 Files : /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ContributionDefImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConstructorInvoker.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/MethodInvoker.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java
        Hide
        Michael Wyraz added a comment -

        In our productive appplications after a while of running, on every event-request an error about multipart decoding occurs. I revired the code and I'm very sure it's relatet to it. This breaks running appplications in a almost non reproducible way. So I'd consider this bug as bein critical. If possible please try to do a bugfix release.

        @Denis how could you fix it in your code?

        Show
        Michael Wyraz added a comment - In our productive appplications after a while of running, on every event-request an error about multipart decoding occurs. I revired the code and I'm very sure it's relatet to it. This breaks running appplications in a almost non reproducible way. So I'd consider this bug as bein critical. If possible please try to do a bugfix release. @Denis how could you fix it in your code?
        Hide
        Denis Stepanov added a comment -

        I'm overriding the MultipartDecoder:

        @Scope(ScopeConstants.PERTHREAD)
        public static MultipartDecoder buildNewMultipartDecoder(PerthreadManager perthreadManager,

        RegistryShutdownHub shutdownHub,

        ObjectLocator locator) {
        MultipartDecoderImpl multipartDecoder = locator.autobuild(MultipartDecoderImpl.class);

        perthreadManager.addThreadCleanupListener(multipartDecoder);

        shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener() {
        public void registryDidShutdown()

        { FileCleaner.exitWhenFinished(); }

        });

        return multipartDecoder;
        }

        public static void contributeServiceOverride(MappedConfiguration<Class, Object> configuration,
        @Local MultipartDecoder multipartDecoder)

        { configuration.add(MultipartDecoder.class, multipartDecoder); }
        Show
        Denis Stepanov added a comment - I'm overriding the MultipartDecoder: @Scope(ScopeConstants.PERTHREAD) public static MultipartDecoder buildNewMultipartDecoder(PerthreadManager perthreadManager, RegistryShutdownHub shutdownHub, ObjectLocator locator) { MultipartDecoderImpl multipartDecoder = locator.autobuild(MultipartDecoderImpl.class); perthreadManager.addThreadCleanupListener(multipartDecoder); shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener() { public void registryDidShutdown() { FileCleaner.exitWhenFinished(); } }); return multipartDecoder; } public static void contributeServiceOverride(MappedConfiguration<Class, Object> configuration, @Local MultipartDecoder multipartDecoder) { configuration.add(MultipartDecoder.class, multipartDecoder); }

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Denis Stepanov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development