HewlettPackard / mds

Managed Data Structures
GNU General Public License v3.0
27 stars 5 forks source link

The contains() method of ManagedArray fails to confirm if an object is an element of this Array #48

Open EvanKirshenbaum opened 7 years ago

EvanKirshenbaum commented 7 years ago

[imported from HPE issue 341]

Assuming the following Schemas:

@RecordSchema
interface ItemSchema extends Comparable<Item> {
        ManagedString uuid();
        int count();
}

@RecordSchema
interface StockItemsSchema {
      ManagedArray<Item> items();
}

The contains() method of ManagedArray does fails to confirm if an object is an element of this Array when using asTask() or isolated() methods, like below:

Items it = Items.getFirstItem();
while ( it != null) {
      …
      asTask( () -> {
            for (StockItems s = StockItems.getFirstStockItems(); s != null;  s = s.getNextStockItems()) {
                  if (s.getItems().contains(it)) {
                        …
                  }
            }
      });
      …
      it = it.getNextItem();
}

I noticed "contains()" method is using operator "==" and I'm wondering if this should use "equals()" method instead of "==" operator.


You can use the same code from branch issue.340, directory issue.340 to validate it.