Class LostLoggerDueToWeakReference

All Implemented Interfaces:
Detector, Priorities, org.apache.bcel.classfile.Visitor

public class LostLoggerDueToWeakReference extends OpcodeStackDetector
We found a problem with the new OpenJDK that everyone is now using to compile and run java code. In particular, the java.util.logging.Logger behavior has changed. Instead of using strong references, it now uses weak references internally. That's a reasonable change, but unfortunately some code relies on the old behavior - when changing logger configuration, it simply drops the logger reference. That means that the garbage collector is free to reclaim that memory, which means that the logger configuration is lost.
  • Field Details

    • methods

      private static final List<MethodDescriptor> methods
    • bugAccumulator

      final BugAccumulator bugAccumulator
    • namesOfSetterMethods

      final HashSet<String> namesOfSetterMethods
    • sawGetLogger

      int sawGetLogger
    • loggerEscaped

      boolean loggerEscaped
    • loggerImported

      boolean loggerImported
  • Constructor Details

    • LostLoggerDueToWeakReference

      public LostLoggerDueToWeakReference(BugReporter bugReporter)
  • Method Details

    • visitClassContext

      public void visitClassContext(ClassContext classContext)
      Description copied from interface: Detector
      Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
      Specified by:
      visitClassContext in interface Detector
      Overrides:
      visitClassContext in class BytecodeScanningDetector
      Parameters:
      classContext - the ClassContext
    • visit

      public void visit(org.apache.bcel.classfile.Code code)
      Overrides:
      visit in class DismantleBytecode
    • sawOpcode

      public void sawOpcode(int seen)
      Description copied from class: OpcodeStackDetector

      By default, this method will not be called when stack is TOP. To change this behavior, override #beforeOpcode(int) and change to return true even if stack is TOP.

      see Using FindBugs for Research to learn lattice and what TOP means.

      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also:
    • checkForImport

      private void checkForImport()
    • checkForMethodExportImport

      private void checkForMethodExportImport()
    • checkForFieldEscape

      private void checkForFieldEscape()