Closed stefanhahmann closed 1 year ago
@tinevez Since the order of implementations of the org.mastodon.feature.Feature#projections() method needs to be reproducible, do you think, it would be good to change the return value of the method from Set
to LinkedHashSet
or alternatively to List
? By this, errors like the one fixed with this PR could not happen again by people implementing this interface method who do not know that the order is relevant in some cases.
@stefanhahmann Actually the order in which projections are returned should not matter. I think there is a deeper problem, probably rooted in the Table headers
@stefanhahmann Actually the order in which projections are returned should not matter. I think there is a deeper problem, probably rooted in the Table headers
I agree. When fixing this bug, I was also assuming that there is something in table headers which does not appropriately handle the existing projections and thus relies on some order. However, I did not dig it down.
I think that the issue is related to the fact that everytime we call the projections()
method in this feature, it returns a new HashSet, with new instances of the feature projection classes.
But in the table, when building the header, the projections()
method is called twice, once for the header subtitle and once to store the projection values. I think it comes from that.
Your patch fix the issue because it imposes the order. But I will try to fix the table so that the header and values are built from the same instance of the projection, so that we don't depend on order.
But also, I think it is sometimes nicer to impose a column order, like you did :)
Resolves: https://github.com/mastodon-sc/mastodon/issues/217
Replace
HashSet
used as return value for the projections() method byLinkedHashSet
, since the order of entry needs to be stable in process using this method.