Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-47

Attempt to modify FastHashMap while in fast mode through iterator.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 13472

    Description

      DESCRIPTION
      Validator attempts to modify FastHashMap while it
      is in fast mode & while using an iterator().
      Because of changes made to FastHashMap()
      back in Mid August this now throws a
      ConcurrentModificationException which is the correct behaviour.

      The offending code is:

      Class Field
      public void processMessageComponents(String key, String replaceValue) {
      String varKey = TOKEN_START + TOKEN_VAR;
      // Process Messages
      if (key != null && !key.startsWith(varKey)) {
      for (Iterator i = hMsgs.keySet().iterator(); i.hasNext(); )

      { String msgKey = (String)i.next(); String value = (String)hMsgs.get(msgKey); hMsgs.put(msgKey, ValidatorUtil.replace(value, key, replaceValue)); }

      }

      SOLUTION
      Turn off fast mode for hMsgs.

      This is the patch solution that worked for me,
      there may be a larger design issue that I don't
      understand.

      — Field.java Wed Oct 9 17:36:00 2002
      +++ .#Field.java.1.5 Wed Oct 9 17:35:36 2002
      @@ -439,7 +439,7 @@

      • to create the dependency <code>Map</code>.
        */
        public void process(Map globalConstants, Map constants) { - hMsgs.setFast(true); + hMsgs.setFast(false); hArg0.setFast(true); hArg1.setFast(true); hArg2.setFast(true); @@ -498,6 +498,7 @@ hDependencies.setFast(true); }

        + hMsgs.setFast(true);
        }

      /**

      HOW TO RECREATE
      Grab an nightly struts build and drop the
      struts-validator.war into tomcat.
      The error occurs when reading in the
      2nd validator.xml definition.
      This causes an update to happen.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rleland Rob Leland
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: