wojciech.kapcia@tigase.net opened 5 years ago
|
|
No, we should not allow private setters in this case. Those methods are called from a different class and may be called on the unknown thread so their implementation should be prepared for that - the same as it was a public member of a class. By allowing private setters, coders implementing setter method could expect that it is called only from the class and would omit proper protections in the implementation. |
|
I'm not sure I agree with that logic - following it we should mandate that all members annoted with This was an afterthought of fix for #helpdeskpr-174 (commit: |
|
To be honest, any extensive work in setters for I do not think that exposing setters is bad in this case, as with use of kernel, configuration and injection the same thing could be done with |
|
I completely agree on both points, wasn't arguing against that.
I don't see how that can be achieved with only configuration and injection. Yes, you can configure different class for injected member but that would (roughly) stay the same during the whole lifecycle, and if you inject a class with private member/setter, without reflection I don't see changing that private member. If we force public setter (in case when we want/have to do some light work on private member) then we expose it to programmatic change. It boils down to two things basically, in case we want to stick with public setter:
Figuring it out with debugger was kinda PITA… |
|
We could add information to the documentation and possibly warn developer at runtime with a warning. @bmalkow What do you think about that? |
|
Referenced from commit 1 year ago
|
Type |
Question
|
Priority |
Normal
|
Assignee | |
Subsystem |
Kernel
|
Not sure if this is a but per se, but I just stumbled against rather odd issue - it turned out that setters associated with private fields annoted wit
@Inject
requirepublic
access modifier. Is it intentional? Shouldn't we allow private setter methods in this case?