<p>This has nothing to do with implementing the hashCode correctly.</p>
<p>This brings up one of the dangers of modifying elements while they are inside Hash containers. The hash bucket for an item is computed at insert time by calling item.hashCode().</p>
<p>But, if the item is later changed such that hashCode() returns a different value, the remove will look for the item in the bucket specified by the hashCode() return value at removal time. This explains why just moving them all to a map and deleting also worked. Also, why after restart it works.</p>
<p>The "fix" is to ensure the hashCode is stable before inserting it into the HashSet. The attached patch works, but I would recommend testing it more or auditing the other users that do something similar. For example, the code is almost duplicated in AltCoinAccountsDataModel.</p>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/8082291/68917075-8381f680-071d-11ea-921a-4f08348c522e.JPG"><img src="https://user-images.githubusercontent.com/8082291/68917075-8381f680-071d-11ea-921a-4f08348c522e.JPG" alt="revolut-add" style="max-width:100%;"></a><br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/8082291/68917079-85e45080-071d-11ea-996b-254c540857be.JPG"><img src="https://user-images.githubusercontent.com/8082291/68917079-85e45080-071d-11ea-996b-254c540857be.JPG" alt="revolut-remove" style="max-width:100%;"></a></p>
<pre><code>diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java
index 568b3d8c2..ed281def8 100644
--- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java
+++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java
@@ -106,7 +106,6 @@ class FiatAccountsDataModel extends ActivatableDataModel {
     ///////////////////////////////////////////////////////////////////////////////////////////
 
     public void onSaveNewAccount(PaymentAccount paymentAccount) {
-        user.addPaymentAccount(paymentAccount);
         TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
         List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
         if (singleTradeCurrency != null) {
@@ -128,6 +127,8 @@ class FiatAccountsDataModel extends ActivatableDataModel {
             });
         }
 
+        user.addPaymentAccount(paymentAccount);
+
         accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
     }
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/3572?email_source=notifications&email_token=AJFFTNRNFIQPBSTQHT65HKLQTYRR5A5CNFSM4JKDCHK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEEI33Q#issuecomment-554208750">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNQ55S2TKX54DQP4BA3QTYRR5ANCNFSM4JKDCHKQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNSEPCTTZ6FCWOMNKFDQTYRR5A5CNFSM4JKDCHK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEEI33Q.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/3572?email_source=notifications\u0026email_token=AJFFTNRNFIQPBSTQHT65HKLQTYRR5A5CNFSM4JKDCHK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEEI33Q#issuecomment-554208750",
"url": "https://github.com/bisq-network/bisq/pull/3572?email_source=notifications\u0026email_token=AJFFTNRNFIQPBSTQHT65HKLQTYRR5A5CNFSM4JKDCHK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEEI33Q#issuecomment-554208750",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>