[LANG-1339]: deprecate circuit breakers and replace java.beans.PropertyListener by a Consumer<State>
For discussion, regarding LANG-1339 (TL;DR: remove depedency on java.desktop from [lang], preparing for Java 9). Thought having some code to discuss would be helpful.
This pull request contains a possible solution, where java.beans.{PropertyChangeListener,PropertyChangeListener} are replaced by java.util.{Observer,Observable}.
Users would still have the same feature, but alas binary compatibility would not be kept. So perhaps this could be in a 4.x release. The other methods are deprecated in the next 3.x releases, and we remove the dependency to java.desktop on 4.x, and also offer a Java9 module with no dependency java.desktop.
Would this be a viable alternative?
Cheers Bruno
Removing the dependency in 4.x is the way to go. I don't see a way to get this into 3.x :-(
Yup @britter you are definitely correct. At least if we agree on the solution, we can think about marking some methods as deprecated in the current circuit breaker (though I prefer to mark as deprecated when there is an alternative), and/or add notes in the next release notes, alerting users about the change to come.
The PR is indeed backwards incompatible.
My suggestion would be to add two new classes with the fixed code (different class names), and deprecated the old classes. That way there is no need to have commons-lang v4.
My suggestion would be to add two new classes with the fixed code (different class names), and deprecated the old classes. That way there is no need to have commons-lang v4.
Thought a bit about that after seeing the vote for [lang] 3.7. In any way, the current implementation will be removed only in 4.x, and we will have to include the require static for Java 9 module.
So right now I am thinking about not marking the class or fields as deprecated, nor adding another class with a different name. Just keep this PR and the ticket open. Then mark the ticket as FixVersion 4.0, use the require static trick for the module-info.java for Java 9.
Does that sound like a good plan?
@jodastephen done. Kept the existing classes, but added new ones where the only modification is replacing java.beans by java.util equivalent classes.
Existing classes were annotated with @deprecated with a comment pointing to the new class.
WDTY? I'd like to sort it out as soon as possible to sort out the issue with dependencies & Java 9 in lang.
Thanks! Bruno
ps: old code was removed from commit line. Moved instead to a branch at https://github.com/kinow/commons-lang/tree/LANG-1339-old, just in case we need to compare it or someone wants to see what it was before
Coverage increased (+0.03%) to 95.128% when pulling ed8e89d1a9be3528a2049aab29f4d93a505feee8 on kinow:LANG-1339 into cfe457636a53d3a1927f3c3f130074bfa0c9d492 on apache:master.
Thanks @kinow , this seems like the right solution. Now the module-info can just use require static to avoid creating a full dependency on the awkward three classes and users have a practical alternative (either add the java.desktop dependency manually, or migrate to the replacement classes.
Posted to the mailing list and will wait to see if there is any further feedback. Otherwise I will merge it in the next days. Thank you @jodastephen !
+1
Back to WIP. Please avoid merging it for now. Gilles noted in the mailing list that the Observable/Observer classes have been deprecated in Java 9. So we will probably go with the deprecation/removal path instead.
Link to the discussion in the mailing list: https://markmail.org/message/efy52lul5pzbznut
Going to have another go at it in the next days. Just deprecate everything, create new classes with Java 8 Consumer that is called for every change of state in the event breaker, instead of PropertyListener or Observable.