Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4803

XMPSchema#getUnqualifiedArrayList throws a different exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.16, 2.0.19, 3.0.0 PDFBox
    • Fix Version/s: 3.0.0 PDFBox
    • Component/s: XmpBox
    • Labels:
      None

      Description

      When a property is illegal, most methods of pdfbox throw IllegalArgumentException:

      org.apache.xmpbox.schema.XMPSchema#getUnqualifiedTextProperty

      org.apache.xmpbox.schema.XMPSchema#getDateProperty

      org.apache.xmpbox.schema.XMPSchema#getBooleanProperty

      org.apache.xmpbox.schema.XMPSchema#getIntegerPropertyValue

       

      However, the following method throws a different exception:

      org.apache.xmpbox.schema.XMPSchema#getUnqualifiedArrayList:

        public List<AbstractField> getUnqualifiedArrayList(String name) throws BadFieldValueException
          {
              ArrayProperty array = null;
              for (AbstractField child : getAllProperties())
              {
                  if (child.getPropertyName().equals(name))
                  {
                      if (child instanceof ArrayProperty)
                      {
                          array = (ArrayProperty) child;
                          break;
                      }
                      throw new BadFieldValueException("Property asked is not an array");
                  }
              }
              if (array != null)
              {
                  return new ArrayList<>(array.getContainer().getAllProperties());
              }
              return null;
          }
      

      As a result, my code fails to catch its exception. Shall the methods throw the same exception for the same reason? For me, BadFieldValueException is even more informative than IllegalArgumentException.

        Attachments

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              haozhong Hao Zhong
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: