stevedlawrence commented on code in PR #781:
URL: https://github.com/apache/daffodil/pull/781#discussion_r872538084


##########
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLAppender.scala:
##########
@@ -38,25 +38,32 @@ class TDMLAppender
     import TDMLAppender._
 
     override def append(event: LogEvent): Unit = {
-        diagnostics = new LogDiagnostic(event.getMessage.getFormattedMessage) 
+: diagnostics
+        checkForKey
+        diagnostics = diagnostics.updated(Thread.currentThread.getId, 
diagnostics(Thread.currentThread.getId) :+ new 
LogDiagnostic(event.getMessage.getFormattedMessage))
     }
 }
 
 object TDMLAppender{
-    var diagnostics: Seq[Diagnostic] = Nil
-    var diagnostics2: Seq[String] = Nil
+    var diagnostics: Map[Long, Seq[Diagnostic]] = Map()

Review Comment:
   Does it make sense to use a mutable map and make this a val?



##########
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLAppender.scala:
##########
@@ -38,25 +38,32 @@ class TDMLAppender
     import TDMLAppender._
 
     override def append(event: LogEvent): Unit = {
-        diagnostics = new LogDiagnostic(event.getMessage.getFormattedMessage) 
+: diagnostics
+        checkForKey
+        diagnostics = diagnostics.updated(Thread.currentThread.getId, 
diagnostics(Thread.currentThread.getId) :+ new 
LogDiagnostic(event.getMessage.getFormattedMessage))

Review Comment:
   I don't think this line is thread safe? If `append` is called by two 
different threads at the same time, is it possible that one of the updates will 
be lost? Can this function be synchronized like the other functions?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to