glassfish
  1. glassfish
  2. GLASSFISH-19361

create-system-properties cannot handle the case where the property name already exists.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2, 3.1.2.2
    • Fix Version/s: 4.0_b64_EE7MS2
    • Component/s: configuration
    • Labels:
      None

      Description

      I found this issue when trying to look at another issue where using REST to modify system property of a config failed.
      When a user calls create-system-properties, but a property with that name already exists, it reports successful. Not sure if thats by design. However, any user application deployed to the server referencing that config will see that the property is gone, ie calling System.getProperties() will not return that property at all.

      Here is the steps to reproduce. I am using DAS, but the same behavior is observed for any instance.
      The war file EnumProperties is attached.

      %asadmin start-domain
      %asadmin deploy EnumProperties
      %asadmin create-system-properties --target server-config AAA=aaa:BBB=bbb
      launch the app by going to http://localhost:8080/EnumProperties, you can see the 2 properties.
      now do
      %asadmin create-system-properties --target server-config AAA=new-value
      The command returns saying executed successfully.
      domain.xml is updated with the new value, but run EnumProperties again, and you can see that only BBB is showing up.

      If create-system-properties is working as expected, ie, it means modifying a property value if the property already exists, then System.getProperties() should return this property.

      If create-system-properties is only for creating new property, then it should return error and not update domain.xml with this new value.

        Activity

        Hide
        Tom Mueller added a comment -

        The create-system-properties manual page says, "If any system properties were previously defined, they are updated with the new values."

        So the bug here is that System.getProperties is not returning the value after the update.

        Show
        Tom Mueller added a comment - The create-system-properties manual page says, "If any system properties were previously defined, they are updated with the new values." So the bug here is that System.getProperties is not returning the value after the update.
        Hide
        Tom Mueller added a comment -

        The root cause of this problem is that config bean change events are being delivered out of order to ConfigListener objects. When a system property is to be updated by create-system-properties, the command first removes the old property and then adds a new one. There is a comment in the code saying that SystemProperty.setValue doesn't work, so this is the reason for the delete and then add. However, the CombinedJavaConfigSystemPropertyListener class (the ConfigListener) receives the change events in the opposite order, i.e., the add is first followed by the delete. Thus, the result on the Java system properties is that the value is deleted.

        Show
        Tom Mueller added a comment - The root cause of this problem is that config bean change events are being delivered out of order to ConfigListener objects. When a system property is to be updated by create-system-properties, the command first removes the old property and then adds a new one. There is a comment in the code saying that SystemProperty.setValue doesn't work, so this is the reason for the delete and then add. However, the CombinedJavaConfigSystemPropertyListener class (the ConfigListener) receives the change events in the opposite order, i.e., the add is first followed by the delete. Thus, the result on the Java system properties is that the value is deleted.
        Hide
        Anissa Lam added a comment -

        The REST code has been fixed to delete only those property that user has removed instead of deleting all existing properties, before calling create-system-properties.
        It also goes through commands to do the delete so that replication works correctly.

        Show
        Anissa Lam added a comment - The REST code has been fixed to delete only those property that user has removed instead of deleting all existing properties, before calling create-system-properties. It also goes through commands to do the delete so that replication works correctly.
        Hide
        Tom Mueller added a comment -

        Fixed in revision 57081.

        This fixes the create-system-properties command so that it only updates an existing property rather than deleting it and then adding it. This produces the correct behavior for the Java system properties.

        Show
        Tom Mueller added a comment - Fixed in revision 57081. This fixes the create-system-properties command so that it only updates an existing property rather than deleting it and then adding it. This produces the correct behavior for the Java system properties.
        Hide
        Tom Mueller added a comment -

        Backported to 3.1.2-SUSTAINING branch (revision 8351).

        Show
        Tom Mueller added a comment - Backported to 3.1.2-SUSTAINING branch (revision 8351).

          People

          • Assignee:
            Tom Mueller
            Reporter:
            Anissa Lam
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: