lburgazzoli commented on code in PR #5230:
URL: https://github.com/apache/camel-k/pull/5230#discussion_r1517247695


##########
pkg/trait/builder.go:
##########
@@ -56,9 +57,18 @@ func (t *builderTrait) InfluencesKit() bool {
        return true
 }
 
-// InfluencesBuild overrides base class method.
-func (t *builderTrait) InfluencesBuild(this, prev map[string]interface{}) bool 
{
-       return true
+func (t *builderTrait) Matches(trait Trait) bool {
+       otherTrait, ok := trait.(*builderTrait)
+       if !ok {
+               return false
+       }
+       if t.BaseImage != otherTrait.BaseImage || len(t.Properties) != 
len(otherTrait.Properties) {
+               return false
+       }
+       // More sofisticated check if len is the same. Sort and compare via 
slices equal func.
+       slices.Sort(t.Properties)
+       slices.Sort(otherTrait.Properties)

Review Comment:
   The structure backing the two object is definitively different, my point was 
more on the fact if `Matches` is or will be used concurrently, then it may 
result in an undefined behavior.
   
   Given the current PR I don't think it can happens but since the method is a 
public method part of some of the traits, then it may be used also outside the 
current scope and I did want to raise it to avoid falling in the same trap as  
https://github.com/apache/camel-k/pull/5188#discussion_r1512280139



-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to