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

Synchronization on Boolean in HL7InQueueProcessor

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Labels:
    • Complexity:
      Low

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: