-
Notifications
You must be signed in to change notification settings - Fork 747
Migrate legacy date-time api to new date-time api #2074
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
Migrate legacy date-time api to new date-time api #2074
Conversation
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
Also a few things I want to mention:
|
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
You observations are all valid.
|
As for your code changes, thanks for the fast turnaround. The build failed because you introduced binary breaking changes. That is not a surprise. Other than that, it looks good. I know we're moving to 2.0, but I'd still like to minimize breaking charges. (Lengthy discussion here: #1938) So, I'd like to use depreciation annotations or bridge methods to address this. If we use depreciation , I'd say we name the new We previously handled these kind of API breaking changes using bridge methods. One advantage of using bridge methods over depreciation annotations is it forces people to switch to using the new API the next time they compile their library (not at some future point). The disadvantage is they make mocking tests fail in odd ways. Still, we just removed them, I was kind of hoping to avoid bringing them back. Sigh. I guess we can reenable producing an So, I'm leaning towards bridge methods. What are your thoughts? (FYI: I don't expect you to make these changes either way, but I'd appreciate your help if you have time.) |
yeah, I gathered that much. all the tests I was able to run locally all passed (a few were skipped, most likely bc they're windows or macos specific tests & I'm on linux)
wdym by "bridge methods"?
sure, I can do that.
looking at spotless, it seems that it has a check for the license header. so, if you wanted to enforce it you could use that.
sure, I can look into that in a bit.
sure, will do. <replaceRegex>
<name>Remove wildcard imports</name>
<searchRegex>import\s+(?:static\s+)?[^\*\s]+\*;(\r\n|\r|\n)</searchRegex>
<replacement>$1</replacement>
</replaceRegex> though, simply running this will cause the compile to fail because it doesn't replace the glob import with imports for the used classes/methods. |
also something else I just noticed, is that it seems in some places all local variables (which are not later modified) are declared as |
Yeah, there isn't really one right answer and it can be confusing for new or occasional contributors. See this example for pros/cons of different options: |
Bridge methods are binary method overloads for methods with the same arguments (or no arguments) and different return types. Look at https://github.com/jenkinsci/bridge-method-injector You can see examples of how we used them by looking at the |
I'm not talking about the fields/classes, I'm talking about, for example ( GHQueryBuilder<T> q(@Nonnull final String qualifier, @CheckForNull final String value) {
if (StringUtils.isEmpty(qualifier)) {
throw new IllegalArgumentException("qualifier cannot be null or empty");
}
if (StringUtils.isEmpty(value)) {
final String removeQualifier = qualifier + ":";
terms.removeIf(term -> term.startsWith(removeQualifier));
} else {
terms.add(qualifier + ":" + value);
}
return this;
} |
honestly, I feel like the breaking changes are rather small. if anyone is still heavily relying on the old date api, then they can either just wrap it in I guess the one complication of this would be jenkins plugins, as I believe that this api is used in several different locations, and many jenkins plugins are not exactly being maintained (eg. I have jenkinsci/discord-notifier-plugin#138 and jenkinsci/github-branch-source-plugin#790 which have just been sitting there for nearly a year lol, one of which has even forced me to use my own build of the plugin otherwise rendering jenkins entirely unusable) |
Oh, local variables. Yeah, I have no idea or opinion there. There are reasons to declare final, but method doesn't have them. File an issue and we can discuss there. And yes the binary compatibility requirement comes from Jenkins. It's a long discussion linked above but it comes down to we need to give them more lead time to handle changes. Maybe the right thing to do here is to have the primary artifact be unbridged (with no added descriptor) and have a secondary "-bridged" artifact? We definitely need to make all bridge methods log warnings to get people to move to the new methods. |
yeah, this might be the best option I feel like the majority of consumers of the library will have little to no use for the bridged methods and will just be able to migrate without significant issue. |
Actually, we created the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2074 +/- ##
============================================
+ Coverage 83.84% 84.42% +0.57%
- Complexity 2414 2455 +41
============================================
Files 236 237 +1
Lines 7330 7344 +14
Branches 389 388 -1
============================================
+ Hits 6146 6200 +54
+ Misses 952 915 -37
+ Partials 232 229 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1473203
to
28b12bf
Compare
28b12bf
to
8ffd6ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed you forgot to mark a few things as @Deprecated
unsure if this is intentional or not, so I'm not going to push a commit that changes it, but if it wasn't then that's why I'm commenting on it
b44f5b9
to
fd3fdb5
Compare
@solonovamax |
@solonovamax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know it is odd to be approving a change I worked on. Oh well.
Description
Migrates the legacy date-time api to newer date-time api introduced in JSR 310.
Fixes #2073
Did not introduce any new tests for this, as no new functionality was introduced, only updated the previous tests to use
Instant
instead ofDate
.Several methods with
date
in the name were renamed to instead haveinstant
in the name. All of these methods are package-private or only accessible to the tests.Before submitting a PR:
Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.These changes break binary backwards compatibility, however this is meant for new 2.x release.@link
JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
locally. If this command doesn't succeed, your change will not pass CI.main
. You will create your PR from that branch.When creating a PR: