Tidy up SignatureAlgorithm Singleton and Usage
See issues discussed on https://github.com/hyperledger/besu/pull/8590
I would like to be assigned to this issue
I was removing the use of Memoize when getting the signature algorithm, so, right now, we get the SignatureAlgorithm singleton instance, but 3 tests are failing in the OperatorSubCommandTest class because the SignatureAlgorithm instance is loaded at construction time in all classes, and when we try to load the one from the json file that has to be used in the test, it doesn't load because the final SIGNATURE_ALGORITHM property already has a value. I'm afraid that this same behavior could happen across the application: classes containing the SignatureAlgorithm property will load the default signature algorithm type at construction time, from SignatureAlgorithmFactory.getInstance(), before the genesis file is loaded, which I guess it was the main reason for using Memoize.
I would like to hear what you think about this.
Hi, @siladu. Maybe I'm wrong and what I though I had to do regarding this issue was not what it was supposed to do? I removed the use of Memoize when getting the signature algorithm instance changing this:
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
By this
private static final SignatureAlgorithm SIGNATURE_ALGORITHM =
SignatureAlgorithmFactory.getInstance();
So lazy loading, that was allowed by Memoize, was lost, and maybe this was not the goal of the issue.