merlimat commented on code in PR #1174:
URL: https://github.com/apache/pulsar-client-go/pull/1174#discussion_r1541581408


##########
pulsar/table_view_impl.go:
##########
@@ -186,10 +203,23 @@ func (tv *TableViewImpl) Get(key string) interface{} {
 func (tv *TableViewImpl) Entries() map[string]interface{} {
        tv.dataMu.Lock()
        defer tv.dataMu.Unlock()
+
        data := make(map[string]interface{}, len(tv.data))
-       for k, v := range tv.data {
+       for k, msg := range tv.data {
+               v, err := tv.schemaValueFromMessage(msg)
+               if err != nil {
+                       tv.logger.Errorf("getting value for message, %w; msg is 
%v", len(tv.listeners), err, msg)
+                       continue
+               }
                data[k] = v
        }
+
+       return data
+}
+
+func (tv *TableViewImpl) Messages() map[string]Message {
+       tv.dataMu.Lock()
+       defer tv.dataMu.Unlock()

Review Comment:
   This is returning the same underlying map, allowing for race-conditions and 
modifications from the application. 
   
   Note: the existing code is also wrong because it was returning `tv.data` 
instead of `data`



-- 
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