Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3530

Invalid cache key in AnnotationActionValidationManager.buildValidatorKey when using visitor field validators

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2.1
    • 6.5.0
    • XML Validators
    • None

    Description

      Error scenerio:

      MyAction-validation.xml:
      <validators>
      <field name="myField"> <!-- MyClass -->
      <field-validator type="visitor">
      <param name="context">basic</param>
      <param name="appendPrefix">true</param>
      <message/>
      </field-validator>
      </field>
      <field name="myField">
      <field-validator type="visitor">
      <param name="context">additional</param>
      <param name="appendPrefix">true</param>
      <message/>
      </field-validator>
      </field>
      </validators>

      In this case, validators in MyClass-basic-validation.xml will be executed two times, but validators in MyClass-additional-validation.xml will just ignored.

      The problem is caused by AnnotationActionValidationManager.buildValidatorKey(Class) which returns the same cache key for the validator cache.

      The current cache key is created by:

      StringBuilder sb = new StringBuilder(clazz.getName());
      sb.append("/");
      sb.append(proxy.getConfig().getName());
      sb.append("|");
      sb.append(proxy.getMethod());

      The context is not a part of the cache key. Therefore, the two visitor validator will just get the same cache key.

      Attachments

        Activity

          People

            Unassigned Unassigned
            johnnycyyu Johnny Yu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: