Uploaded image for project: 'Flume'
  1. Flume
  2. FLUME-1018

Context can cause NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.0.0
    • 1.1.0
    • Configuration
    • None

    Description

      The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object.

      For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

      Attachments

        1. FLUME-1018-0.patch
          2 kB
          Brock Noland

        Activity

          People

            brocknoland Brock Noland
            hshreedharan Hari Shreedharan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: