PicoContainer
  1. PicoContainer
  2. PICO-118

ConstantParameter can cause TooManySatisfiableConstructorsException

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-5
    • Fix Version/s: 1.0-beta-5
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      3

      Description

      A ConstantParameter instanciates a InstanceComponentAdapter with
      the value itself as key and registers it in the pico. This is
      critical if the value of the parameter equals a key of a component.
      Verifying the container throws then a TooManySatisfiableConstructorsException.

      In worst case scenario, the value could have been configured by an
      admin breaking the application by chance.

      To solve the problem create unique keys for adapters holding
      constant parameters, allow a null value as key or remove the key at
      all as proposed in PICO-105, since it is not used anyway in this
      context.

      1. ConstantParameter.java.diff
        1 kB
        Jörg Schaible
      2. ParameterTestCase.java.diff
        1 kB
        Jörg Schaible
      3. ParameterTestCase.java.diff
        0.9 kB
        Jörg Schaible

        Activity

        Hide
        Jörg Schaible added a comment -

        src\test\org\picocontainer\defaults\ParameterTestCase.java.diff

        Patch to add a fixture for paarmeter test case, that demonstrates the bug.

        Show
        Jörg Schaible added a comment - src\test\org\picocontainer\defaults\ParameterTestCase.java.diff Patch to add a fixture for paarmeter test case, that demonstrates the bug.
        Jörg Schaible made changes -
        Field Original Value New Value
        Attachment ParameterTestCase.java.diff [ 11330 ]
        Hide
        Aslak Hellesøy added a comment -

        Closing this since the attached test does no longer throw any exceptions.

        Show
        Aslak Hellesøy added a comment - Closing this since the attached test does no longer throw any exceptions.
        Aslak Hellesøy made changes -
        Fix Version/s 1.0-beta-5 [ 10145 ]
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Assignee Aslak Hellesoy [ rinkrank ]
        Hide
        Aslak Hellesøy added a comment -

        Reopened upon Jorg's request. If you create new attachments, please mention which ones (1, 2, etc) are obsolete.

        Show
        Aslak Hellesøy added a comment - Reopened upon Jorg's request. If you create new attachments, please mention which ones (1, 2, etc) are obsolete.
        Aslak Hellesøy made changes -
        Status Closed [ 6 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Hide
        Jörg Schaible added a comment -

        ParameterTestCase.java.diff: Modified test case.

        Well, it is difficult to knew the number of the attachment before submitting them (I've seen JIRA renumber them anyway). Safest procedure is to open the link to the "attachment management" and use the newer one.

        Show
        Jörg Schaible added a comment - ParameterTestCase.java.diff: Modified test case. Well, it is difficult to knew the number of the attachment before submitting them (I've seen JIRA renumber them anyway). Safest procedure is to open the link to the "attachment management" and use the newer one.
        Jörg Schaible made changes -
        Attachment ParameterTestCase.java.diff [ 11454 ]
        Hide
        Jörg Schaible added a comment -

        PicoContainer\java\picocontainer\ConstantParameter.java.diff: Patch to solve the problem by creating "unique" names.

        But the original question still applies: Why have the ConstantParameters to be registered, since their key is never requested ...

        Show
        Jörg Schaible added a comment - PicoContainer\java\picocontainer\ConstantParameter.java.diff: Patch to solve the problem by creating "unique" names. But the original question still applies: Why have the ConstantParameters to be registered, since their key is never requested ...
        Jörg Schaible made changes -
        Attachment ConstantParameter.java.diff [ 11455 ]
        Hide
        Aslak Hellesøy added a comment -

        Applied, with minor modification. (Using the hash code as key.)

        Show
        Aslak Hellesøy added a comment - Applied, with minor modification. (Using the hash code as key.)
        Aslak Hellesøy made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Aslak Hellesøy
            Reporter:
            Jörg Schaible
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: