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

Potential NullPointerException in code

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: JDO 3.2
    • Fix Version/s: JDO 3.2
    • Component/s: 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. new-patch-for-jdo780.patch
          2 kB
          XiangzheXu
        2. patch-for-780.patch
          6 kB
          XiangzheXu

          Activity

            People

            • Assignee:
              mbo Michael Bouschen
              Reporter:
              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