Uploaded image for project: 'JSword'
  1. JSword
  2. JS-177

Need a null check in GenBookBackend.getRawText

    Details

      Description

      A null check is required in the following code in GenBookBackend.getRawText because find can return a null meaning that node, when used on the next line could be null:

      DataPolice.setKey(key);
      TreeNode node = find(key);
      byte[] userData = node.getUserData();

      // Some entries may be empty.
      if (userData.length == 8) {

      Here is a suggested fix but I don't know if you should return a null or an empty string in this scenario:

      DataPolice.setKey(key);
      TreeNode node = find(key);

      // Is there an entry?
      if (node == null)

      { return ""; }

      byte[] userData = node.getUserData();

      Here is a simple test:
      Book book = getBook("Pilgrim");
      Key key = book.getGlobalKeyList();
      String rawText = book.getRawText(key);

        Attachments

          Activity

            People

            • Assignee:
              dmsmith DM Smith
              Reporter:
              mjdenham Martin Denham
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: