Uploaded image for project: 'Google Code-in'
  1. Google Code-in
  2. GCI-247

Synchronization on Boolean in HL7InQueueProcessor

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Should
    • Resolution: Fixed

    Description

      Replace this line https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/hl7/HL7InQueueProcessor.java#L102

      with: synchronized (lock) {

      where lock is declared at the class level as:

      private static final Object lock = new Object();

       

      Background Information:

      Objects which are pooled and potentially reused should not be used for synchronization. If they are, it can cause unrelated threads to deadlock with unhelpful stacktraces. Specifically, String literals, and boxed primitives such as Integers should not be used as lock objects because they are pooled and reused. The story is even worse for Boolean objects, because there are only two instances of BooleanBoolean.TRUE and Boolean.FALSE and every class that uses a Boolean will be referring to one of the two.

      Gliffy Diagrams

        Attachments

          Activity

            People

              navareth Bartłomiej Rasztabiga
              dkayiwa Daniel Kayiwa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: