In js-cookie the attributes are specified using an Object Literal instance. In Java we can make a step forward and ensure that the passed attributes are not going to be changed by external code, creating a builder that builds an immutable instance of the Attributes object.
As it currently stands, the invariants of the Attributes object can be changed in a multi-thread environment even after it is passed to the set method and before the return, despite the set method being implicitly locked by the synchronized keyword or not.
In js-cookie the attributes are specified using an Object Literal instance. In Java we can make a step forward and ensure that the passed attributes are not going to be changed by external code, creating a builder that builds an immutable instance of the
Attributesobject.As it currently stands, the invariants of the
Attributesobject can be changed in a multi-thread environment even after it is passed to thesetmethod and before the return, despite thesetmethod being implicitly locked by thesynchronizedkeyword or not.