ICEfaces
  1. ICEfaces
  2. ICE-8345

NPE in DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.0.0.GA
    • Fix Version/s: 3.1, EE-3.0.0.GA_P01
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces
    • Assignee Priority:
      P1

      Description

      Suggestion bellow is a fix for a possible NPE issue in our code located in org.icefaces.impl.context.DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document), around lines 470-480:

      // if we cannot loop through optionElements, we must have
      // just a text node
      if (0 == optionElementsLength) {
      Node optionBodyNode = selectElement.getFirstChild();
      // QUICK BUGFIX oboede 2012-06-04: In case of f:ajax updates this node value
      // was sometimes <code>null</code>.
      if (optionBodyNode != null) { <--------- (1) to avoid NPE at (2)
      String optionBody = optionBodyNode.getNodeValue(); <--------------- (2)

      // Should be constant, but may vary with JSF implementation
      String SELECTED = "selected=\"true\"";
      Matcher tagMatcher = OPTION_TAG.matcher(optionBody);
      StringBuffer outBuffer = new StringBuffer();
      while (tagMatcher.find()) {
      String optionTag = tagMatcher.group(0);
      Matcher valueMatcher = OPTION_VALUE.matcher(optionTag);
      Matcher selectedMatcher = OPTION_SELECTED.matcher(optionTag);
      String valuePair = null;
      String value = null;
      String selected = null;
      if (valueMatcher.find()) {
      valuePair = valueMatcher.group(0);
      value = valueMatcher.group(1);
      }
      if (selectedMatcher.find()) {
      selected = selectedMatcher.group(1);
      SELECTED = selected;
      }

      if (values.contains(value)) {
      if (null == selected) {
      optionTag = optionTag.replace(valuePair, valuePair + " " + SELECTED);
      }
      } else {
      if (null != selected) {
      optionTag = optionTag.replace(" " + selected, "");
      }
      }
      tagMatcher.appendReplacement(outBuffer, optionTag);
      }
      tagMatcher.appendTail(outBuffer);
      optionBodyNode.setNodeValue(outBuffer.toString());
      }
      }

        Activity

        Evgheni Sadovoi created issue -
        Evgheni Sadovoi made changes -
        Field Original Value New Value
        Salesforce Case [5007000000NGNvf]
        Evgheni Sadovoi made changes -
        Assignee Ken Fyten [ ken.fyten ]
        Evgheni Sadovoi made changes -
        Description Suggestion bellow is a fix for a possible NPE issue in our code located in org.icefaces.impl.context.DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document), line 470:

        // if we cannot loop through optionElements, we must have
        // just a text node
        if (0 == optionElementsLength) {
        Node optionBodyNode = selectElement.getFirstChild();
        // QUICK BUGFIX oboede 2012-06-04: In case of f:ajax updates this node value
        // was sometimes <code>null</code>.
        if (optionBodyNode != null) { <--------- (1) to avoid NPE at (2)
        String optionBody = optionBodyNode.getNodeValue(); <--------------- (2)

        // Should be constant, but may vary with JSF implementation
        String SELECTED = "selected=\"true\"";
        Matcher tagMatcher = OPTION_TAG.matcher(optionBody);
        StringBuffer outBuffer = new StringBuffer();
        while (tagMatcher.find()) {
        String optionTag = tagMatcher.group(0);
        Matcher valueMatcher = OPTION_VALUE.matcher(optionTag);
        Matcher selectedMatcher = OPTION_SELECTED.matcher(optionTag);
        String valuePair = null;
        String value = null;
        String selected = null;
        if (valueMatcher.find()) {
        valuePair = valueMatcher.group(0);
        value = valueMatcher.group(1);
        }
        if (selectedMatcher.find()) {
        selected = selectedMatcher.group(1);
        SELECTED = selected;
        }

        if (values.contains(value)) {
        if (null == selected) {
        optionTag = optionTag.replace(valuePair, valuePair + " " + SELECTED);
        }
        } else {
        if (null != selected) {
        optionTag = optionTag.replace(" " + selected, "");
        }
        }
        tagMatcher.appendReplacement(outBuffer, optionTag);
        }
        tagMatcher.appendTail(outBuffer);
        optionBodyNode.setNodeValue(outBuffer.toString());
        }
        }
        Suggestion bellow is a fix for a possible NPE issue in our code located in org.icefaces.impl.context.DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document), around lines 470-480:

        // if we cannot loop through optionElements, we must have
        // just a text node
        if (0 == optionElementsLength) {
        Node optionBodyNode = selectElement.getFirstChild();
        // QUICK BUGFIX oboede 2012-06-04: In case of f:ajax updates this node value
        // was sometimes <code>null</code>.
        if (optionBodyNode != null) { <--------- (1) to avoid NPE at (2)
        String optionBody = optionBodyNode.getNodeValue(); <--------------- (2)

        // Should be constant, but may vary with JSF implementation
        String SELECTED = "selected=\"true\"";
        Matcher tagMatcher = OPTION_TAG.matcher(optionBody);
        StringBuffer outBuffer = new StringBuffer();
        while (tagMatcher.find()) {
        String optionTag = tagMatcher.group(0);
        Matcher valueMatcher = OPTION_VALUE.matcher(optionTag);
        Matcher selectedMatcher = OPTION_SELECTED.matcher(optionTag);
        String valuePair = null;
        String value = null;
        String selected = null;
        if (valueMatcher.find()) {
        valuePair = valueMatcher.group(0);
        value = valueMatcher.group(1);
        }
        if (selectedMatcher.find()) {
        selected = selectedMatcher.group(1);
        SELECTED = selected;
        }

        if (values.contains(value)) {
        if (null == selected) {
        optionTag = optionTag.replace(valuePair, valuePair + " " + SELECTED);
        }
        } else {
        if (null != selected) {
        optionTag = optionTag.replace(" " + selected, "");
        }
        }
        tagMatcher.appendReplacement(outBuffer, optionTag);
        }
        tagMatcher.appendTail(outBuffer);
        optionBodyNode.setNodeValue(outBuffer.toString());
        }
        }
        Ken Fyten made changes -
        Fix Version/s 3.1 [ 10312 ]
        Fix Version/s EE-3.0.0.GA_P01 [ 10327 ]
        Assignee Priority P1
        Assignee Ken Fyten [ ken.fyten ] Deryk Sinotte [ deryk.sinotte ]
        Deryk Sinotte made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Deryk Sinotte made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Deryk Sinotte
            Reporter:
            Evgheni Sadovoi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: