Plexus
  1. Plexus
  2. PLX-396

Requirements injected as Map are swallowing component creation exceptions

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1.0-beta-3.0.6
    • Component/s: Container
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      When a component has a Map<String, AComponent> requirement, it gets injected a lazy Map with component descriptors fine. But when getting it from the map, if the component creation fails, it will go unnoticed, and the map will simply return null, leaving no possibility to application to detect what went wrong.

      Or the fact the map returns null should be considered as "application error"?

        Activity

        Hide
        Dain Sundstrom added a comment -

        I'm not sure this applies anymore. Maps are not notification based, so when a new component descriptor is added an event is fired to the map. The map then attempts to get the component, which causes the component to be created. If the creation fails, a message is logged. Alternatively, the component descriptor could be unregistered when a listener throws an exception, but that will have it's own side effects.

        Show
        Dain Sundstrom added a comment - I'm not sure this applies anymore. Maps are not notification based, so when a new component descriptor is added an event is fired to the map. The map then attempts to get the component, which causes the component to be created. If the creation fails, a message is logged. Alternatively, the component descriptor could be unregistered when a listener throws an exception, but that will have it's own side effects.
        Hide
        John Casey added a comment - - edited

        I've just spent 10 hours debugging a plugin in Nexus 1.5.0, only to come across this as the root issue. The problem was a component that was using String.format() with an inappropriate syntax, which threw FormatException. Since this component was used by a Nexus resource, and Nexus resources are components that are mapped into the NexusApplication as described here, THIS EXCEPTION WAS SWALLOWED...which led to 8 hours of debugging, and 2 hours of tracing the swallowing action itself to a root cause in Plexus.

        So clearly, this is still happening. See:

        http://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.5.4/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java

        Look for the lookup() method, and notice what happens when a component lookup fails.

        There must be some better way to deal with this; perhaps a RuntimeException that percolates out from here. I can't see another way to make this work appropriately.

        NOTE: If you want to recreate my nightmare from yesterday:

        1. Create a new Nexus plugin
        2. Add a custom REST resource
        3. Make this REST resource depend on another custom component
        4. In the other custom component, make it Initializable
        5. In the initialize method, try something like: String.format( "%s:%s:%s", "foo", "bar" );
        6. Stand well back, light fuse. Watch it blow up.

        Show
        John Casey added a comment - - edited I've just spent 10 hours debugging a plugin in Nexus 1.5.0, only to come across this as the root issue. The problem was a component that was using String.format() with an inappropriate syntax, which threw FormatException. Since this component was used by a Nexus resource, and Nexus resources are components that are mapped into the NexusApplication as described here, THIS EXCEPTION WAS SWALLOWED...which led to 8 hours of debugging, and 2 hours of tracing the swallowing action itself to a root cause in Plexus. So clearly, this is still happening. See: http://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.5.4/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java Look for the lookup() method, and notice what happens when a component lookup fails. There must be some better way to deal with this; perhaps a RuntimeException that percolates out from here. I can't see another way to make this work appropriately. NOTE: If you want to recreate my nightmare from yesterday: 1. Create a new Nexus plugin 2. Add a custom REST resource 3. Make this REST resource depend on another custom component 4. In the other custom component, make it Initializable 5. In the initialize method, try something like: String.format( "%s:%s:%s", "foo", "bar" ); 6. Stand well back, light fuse. Watch it blow up.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tamás Cservenák
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: