Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      in: org.apache.commons.jxpath.MapDynamicPropertyHandler

      If the following code:
      public String[] getPropertyNames(Object object) {
      Map map = (Map) object;
      String names[] = new String[map.size()];
      Iterator it = map.keySet().iterator();
      for (int i = 0; i < names.length; i++)

      { names[i] = String.valueOf(it.next()); }

      return names;
      }

      could be replaced by:
      public String[] getPropertyNames(Object object) {
      Set keys = ((Map) object).keySet();
      String names[] = new String[keys.size()];
      Iterator it = keys.iterator();
      for (int i = 0; i < names.length; i++)

      { names[i] = String.valueOf(it.next()); }

      return names;
      }

      This would permit to support very special cases where Map.keySet().size() !=
      Map.size() [which, I know, does not conform to the Map API].
      Anyway, in general, it is better to compute the size on the Set we are actually
      using and not on another one related to it...

      Thanks,

      Yann Duponchel.

        Activity

        Hide
        Dmitri Plotnikov added a comment -

        Applied the patch as suggested.

        Show
        Dmitri Plotnikov added a comment - Applied the patch as suggested.

          People

          • Assignee:
            Unassigned
            Reporter:
            Yann Duponchel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development