commons-lang icon indicating copy to clipboard operation
commons-lang copied to clipboard

[LANG-1339]: deprecate circuit breakers and replace java.beans.PropertyListener by a Consumer<State>

Open kinow opened this issue 8 years ago • 11 comments

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

kinow avatar Jul 09 '17 10:07 kinow

Removing the dependency in 4.x is the way to go. I don't see a way to get this into 3.x :-(

britter avatar Oct 23 '17 06:10 britter

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.

kinow avatar Oct 23 '17 07:10 kinow

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.

jodastephen avatar Oct 23 '17 15:10 jodastephen

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?

kinow avatar Nov 05 '17 02:11 kinow

@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

kinow avatar Jun 09 '18 10:06 kinow

Coverage Status

Coverage increased (+0.03%) to 95.128% when pulling ed8e89d1a9be3528a2049aab29f4d93a505feee8 on kinow:LANG-1339 into cfe457636a53d3a1927f3c3f130074bfa0c9d492 on apache:master.

coveralls avatar Jun 09 '18 11:06 coveralls

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.

jodastephen avatar Jun 09 '18 20:06 jodastephen

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 !

kinow avatar Jun 09 '18 22:06 kinow

+1

PascalSchumacher avatar Jun 10 '18 08:06 PascalSchumacher

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

kinow avatar Jul 16 '18 11:07 kinow

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.

kinow avatar Apr 16 '20 09:04 kinow