Uploaded image for project: 'JDO'
  1. JDO
  2. JDO-780

Potential NullPointerException in code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • JDO 3.2
    • JDO 3.2
    • tck

    Description

      In class org.apache.jdo.exectck.Utilities, the method `printClasspath()` could throw an unexpected NullPointerException.

      The related part of that method is shown as follows.

      ```java
      public void printClasspath()

      { ClassLoader loader = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) loader).getURLs(); }

      ```

      The invocation of `ClassLoader.getSystemClassLoader()` could return null in JDK 8, as is depicted in the Javadoc in its source code:

      @return The system <tt>ClassLoader</tt> for delegation, or
      <tt>null</tt> if none

      If that is the case, the invocation to `getURLs()` could cause a NullPointerException.
      Maybe we could check for null pointer here or mention the potential NullPointerException at the Javadoc?

      Attachments

        1. patch-for-780.patch
          6 kB
          XiangzheXu
        2. new-patch-for-jdo780.patch
          2 kB
          XiangzheXu

        Activity

          People

            mbo Michael Bouschen
            xz-x XiangzheXu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified