Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6408

Not-null ThreadLocal

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • None
    • 1.38.0
    • None
    • None

    Description

      Many points in the code need to wrap ThreadLocal.get() in requireNonNull or castNonNull to keep checkerFramework happy. This change removes those, by providing a sub-class of ThreadLocal whose values are known to be never null.

      In CALCITE-915 we added class TryThreadLocal to make it easier to remember to unset a thread-local value, and in commit f82028f4 we made its get method return a not-null value. But the only constructor was TryThreadLocal.of(T initialValue). In this change, we add TryThreadLocal.withSupplier(Supplier<T>), so that each thread can have its own value, and convert all uses of ThreadLocal where to use it.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: