Ok np, I will add a constructor, tks for the review.

Brian Stansberry <notifications@github.com> wrote:

> @@ -87,6 +89,19 @@ public InMemoryNamingStore(final NamingEventCoordinator eventCoordinator) {
>          this.eventCoordinator = eventCoordinator;
>      }
>  
> +    @Override
> +    public Name getBaseName() throws NamingException {
> +        return baseName;
> +    }
> +
> +    /**
> +     * Sets the jndi base name of the store.
> +     * @param baseName
> +     */
> +    public void setBaseName(Name baseName) {
> +        this.baseName = baseName;
> +    }

I'm not aware of any specific policy related to that kind of usage. Jason long ago asked that devs document the thread safety characteristics of a class in its class javadoc. Unfortunately, that has rarely been done. IMO for this kind of pojo-style usage that absolutely must be done, since it's so easy for someone to use the class in a way not originally intended. I think you're better off making the class thread safe instead of relying on future devs not misusing it. All it takes is someone publishing the object before calling the setter and a tricky bug will be born.

TBH, I don't like using setters to configure an object's initial state, unless its required that it can be done by reflection-based code. If the reason for using setters is otherwise the constructor takes too many params, use a builder pattern.

---
Reply to this email directly or view it on GitHub:
https://github.com/jbossas/jboss-as/pull/4241/files#r3524427