-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Java 8's Consumer interface. #1870
Conversation
Thanks, but can't merge with the build failures. Is there an update mojo sniffer? And would need to make sure the API change is backwards compatible too. |
I didn't change anything else, so I'm not sure why the build is failing.
With existing calls to |
The build fails because we use the Mojo Animal Sniffer plugin to verify that all APIs used are in the appropriate Java and Android language levels. It doesn't believe that the Consumer interface is available on Android -- which is why I added that internal workaround. The error in the build is:
The check is defined in the POM: Lines 74 to 78 in 29be991
I don't see an update to that signature definition that supports the APIs brought in by new desugaring implementation. So we would need to find a different way to do those tests. Or allow-list the API explicitly, or something. |
9ee71c4
to
6e77a00
Compare
I added an ignore rule for the Mojo Animal Sniffer plugin. |
Cool - the next issue to resolve is the API backwards compat issue - the interface has changed:
I think we can deal with that by making the jsoup Consumer extend from the Java Consumer, and mark it deprecated for removal in the next release. You can run these tests locally with |
Yeah, I was thinking of adding overloaded methods for the separate consumer types, but your solution is much better. |
6b05fea
to
e1620ce
Compare
0732a60
to
15bf11a
Compare
I tried removing the |
In favour of java.util.function.Consumer
@deprecated Use {@link #forEachNode(Consumer)} instead. | ||
*/ | ||
public Node forEachNode(org.jsoup.helper.Consumer<? super Node> action) { | ||
Validate.notNull(action); |
Check notice
Code scanning / CodeQL
Confusing overloading of methods
OK, my commit has deprecated the old methods, and added a temporary deprecated overload for the old version. This ensures both source and binary compatibility in this version. The next version can remove these methods. |
Thanks again! Have merged. |
Consumer
interface introduced in Java 8, as it can be backported for older versions of Android via core library desugaring.