Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-1216

makeList(List list) with a null value in list

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 1.0 RC3, 1.0 RC4
    • {Unused} Core
    • None
    • Oracle10g database
    • makeList, null
    • Low

    Description

      In the following class and method.... core/src/main/java/com.xpn.xwiki.objects.classes.DBListClass.makeList(List list)

      if list contains a null result for what ever reason, it throws a NullPointer if a result variable is null, then the list it's trying to make no longer contains all of the other non-null values. An example of when this happended was when using the Blog piece and adding categories with no name. When the makeList(List) method is called, it blows up. The following is a work around.... ---> indicates an added line....

          public List makeList(List list) {
              List list2 = new ArrayList();
              for (int i=0;i<list.size();i++) {
                  Object result = list.get(i);
      --->        if(result != null){
                      if (result instanceof String) {
                          list2.add(new ListItem((String) result));
                      } else {
                          Object[] res = (Object[]) result;
                          if (res.length==1)
                           list2.add(new ListItem(res[0].toString()));
                          else if (res.length==2)
                           list2.add(new ListItem(res[0].toString(), res[1].toString()));
                          else
                           list2.add(new ListItem(res[0].toString(), res[1].toString(), res[2].toString()));
                      }
      --->        }
              }
              return list2;
          }
      

      Attachments

        Issue Links

          Activity

            People

              sdumitriu Sergiu Dumitriu
              kylesands Kyle Sands
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: