Uploaded image for project: 'Commons JCS'
  1. Commons JCS
  2. JCS-77

NullPointerException thrown by IndexedDiskCache if IndexedDisk calls fail to initialize

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • jcs-1.3, jcs-2.0-beta-1
    • jcs-2.0-beta-1
    • Indexed Disk Cache
    • None

    Description

      In the constructor for IndexedDiskCache.java, if an exception is thrown while creating dataFile or keyFile, the keyHash member variable is never initialized, the if check after the catch block will throw an NPE when keyHash.size() is called.

      I am experiencing this in 1.3, and it looks like it would still occur in 1.4.

      One solution for 1.3 might be to move the doOptimizeRealTime() check inside the catch block:

      IndexedDiskCache.java
      206a207,213
      >
      > // TODO: Should we improve detection of whether or not the file should be optimized.
      > if ( isRealTimeOptimizationEnabled && keyHash.size() > 0 )
      >

      { > // Kick off a real time optimization, in case we didn't do a final optimization. > doOptimizeRealTime(); > }

      214,219d220
      < // TODO: Should we improve detection of whether or not the file should be optimized.
      < if ( isRealTimeOptimizationEnabled && keyHash.size() > 0 )
      <

      { < // Kick off a real time optimization, in case we didn't do a final optimization. < doOptimizeRealTime(); < }

      Attachments

        Activity

          People

            tv Thomas Vandahl
            mmorrisson Matt Morrisson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: