hk2
  1. hk2
  2. HK2-107

ConfigBean with an @Attribute with a defaultValue that contains a comma is handled incorrectly

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.*
    • Fix Version/s: 2.1.*
    • Component/s: None
    • Labels:
      None

      Description

      A ConfigBean (@Configured) declared with an @Attribute with a defaultValue that contains a comma is handled incorrectly. The metadata for the injector looks like this:

      metadata = "target=org.glassfish.concurrent.config.ManagedThreadFactory,@thread-priority=optional,@thread-priority=default:5,@thread-priority=datatype:java.lang.Integer,@thread-priority=leaf,@context-info-enabled=optional,@context-info-enabled=default:true,@context-info-enabled=datatype:java.lang.Boolean,@context-info-enabled=leaf,@context-info=optional,@context-info=\"default:Classloader,JNDI,Security,WorkArea\",@context-info=datatype:java.lang.String,@context-info=leaf,@description=optional,@description=datatype:java.lang.String,@description=leaf,<property>=collection:org.jvnet.hk2.config.types.Property,@jndi-name=optional,@jndi-name=datatype:java.lang.String,@jndi-name=leaf,key=@jndi-name,keyed-as=com.sun.enterprise.config.serverbeans.BindableResource,@enabled=optional,@enabled=default:true,@enabled=datatype:java.lang.Boolean,@enabled=leaf,@object-type=optional,@object-type=default:user,@object-type=datatype:java.lang.String,@object-type=leaf,@deployment-order=optional,@deployment-order=default:100,@deployment-order=datatype:java.lang.Integer,@deployment-order=leaf"

      Here, "context-info" is the attribute with the default value. It is declared like this:

      @Attribute(defaultValue="Classloader,JNDI,Security,WorkArea")
      String getContextInfo();

      This translates to the following in the metadata string:

      @context-info=\"default:Classloader,JNDI,Security,WorkArea\"

      The ConfigModel constructor calls:

      String dv = getMetadataFieldKeyedAs(e.getValue(), "default:"); //default value

      But when getMetadataFieldKeyedAs looks through the string, it sees the quote at the front of the string, so the "default:" doesn't match, and the code thinks there is no default value.

      I haven't figured out where the metadata string from the injector is parsed. It appears that the quotes that are needed because of the comma aren't being stripped off.

        Activity

        Hide
        jwells added a comment -

        This has been fixed in hk2, it'll need a promotion to get picked up in GlassFish

        Show
        jwells added a comment - This has been fixed in hk2, it'll need a promotion to get picked up in GlassFish

          People

          • Assignee:
            jwells
            Reporter:
            Tom Mueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: