-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Deprecation info for joda-java migration #41956
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
Deprecation info for joda-java migration #41956
Conversation
|
Pinging @elastic/es-core-infra |
...precation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java
Outdated
Show resolved
Hide resolved
rjernst
left a comment
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.
A few comments
test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java
Outdated
Show resolved
Hide resolved
|
|
||
| static Map<String, String> JODA_PATTERNS_DEPRECATIONS = new LinkedHashMap<>(); | ||
| static { | ||
| JODA_PATTERNS_DEPRECATIONS.put("Y", "'Y' year-of-era becomes 'y'. 'Y' means week-based-year."); |
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.
We already have these deprecation messages in Joda, which are logged when the patterns are parsed. This seems to be doubling them? Additionally, I think some of these are too broad, like the check for y, which users wouldn't need to do anything about. Any deprecation messages should be actionable.
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 - that was just a draft, but next step is to have those messages in one place and use in both Joda & Deprecation API.
for y pattern check I think it would be fair to notify users about this as it changes to u (I missed this on previous commit). I suppose some users would just ignore this check specifically as a difference is very subtle, but we should at least let them know.
Some of the patterns are not actionable though - like C century is no longer present in java.time. Again users should be aware about this, as their pattern will probably no longer work. Action would be to change your business logic?
...in/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java
Outdated
Show resolved
Hide resolved
|
This approach seems reasonable to me, the warning it generates is a little verbose but otherwise should be fine (and it's not like we don't already have some very verbose warnings). As others have noted, there's a fair bit of commented out code, etc. left, but I assume that's why this PR is still marked as a draft/WIP. |
|
there are a lot of test failing as the deprecation now includes |
9152886 to
c94bbe7
Compare
| -------------------------------------------------- | ||
| // CONSOLE | ||
| // TESTSETUP | ||
| // TEST[setup:name] |
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.
I need to figure out how to fix Docs tests. At the moment they fail because of warnings
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.
Normally we would update the docs to not use deprecated functionality. Is that possible here?
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.
it would - actually it would be much easier if I just use a new pattern with 8 prefix. But should this be done across all the docs?
That change is to fix the DocsClientYamlTestSuiteIT. The options is to prefix with8, assert about warnings, disable warning checks alltogether?
gwbrown
left a comment
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.
Left a few comments, mostly minor.
You mentioned wanting to have more Javadoc and tests, which I agree with as well, plus the commented-out code and TODOs left which I didn't address as this is still marked WIP. Otherwise I still don't see any major problems, and it's already much improved from the last time I looked at this. Thanks for doing this!
| public class JavaJodaTimeDuellingTests extends ESTestCase { | ||
| @Override | ||
| protected boolean enableWarningsCheck() { | ||
| // disable warning checks as deprecated patterns are used to compare Joda vs Java results (y - year and Z zone offset) |
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.
I would update this note to say that these warnings as tested in JodaWarningTests already, so that's why we don't test them here.
Pretend I copy/pasted this onto every iteration of this comment, but I'm not going to because there's a lot of them.
| public class RootObjectMapperTests extends ESSingleNodeTestCase { | ||
| @Override | ||
| protected boolean enableWarningsCheck() { | ||
| // disable warning checks as deprecated patterns are used to compare Joda vs Java results (y - year and Z zone offset) |
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.
I get doing this for date-specific tests, but there's a lot of classes that have the warnings check disabled here, including some very broad ones. We should be careful about doing this so widely, although I could see an argument that this is okay if it would be a lot of work to use assertWarnings everywhere given these will only be going into 6.8, which should pretty much only be getting bugfixes at this point.
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.
where possible I used explicitly assertWarnings about these patterns, but often it was just not feasible and would require adding lot of them.
and agree, that is only going to be in 6.8 so hopefully would not reduce confidence in these tests
...in/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java
Show resolved
Hide resolved
...in/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java
Outdated
Show resolved
Hide resolved
| private static Map<String, String> JODA_PATTERNS_DEPRECATIONS = new LinkedHashMap<>(); | ||
|
|
||
| static { | ||
| JODA_PATTERNS_DEPRECATIONS.put("Y", "'Y' year-of-era becomes 'y'. Use 'Y' for week-based-year."); |
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.
I think we should make this a bit clearer as to what we're recommending be done. Something like this:
| JODA_PATTERNS_DEPRECATIONS.put("Y", "'Y' year-of-era becomes 'y'. Use 'Y' for week-based-year."); | |
| JODA_PATTERNS_DEPRECATIONS.put("Y", "'Y' year-of-era should be replaced with 'y'. Use 'Y' for week-based-year."); |
And similar for the rest of these.
| } | ||
| } | ||
| String combinedWarning = warnings.stream() | ||
| .collect(Collectors.joining(";")); |
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.
Since this is building a message for the end user it would be nice to put a space after the semi-colon.
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.
good point, this would be more readable with a space
| "https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_java_time_changes", | ||
| "This index has date fields with deprecated formats: ["+ | ||
| "[type: _doc, field: date_time_field_Y, format: dd-CC||MM-YYYY, " + | ||
| "suggestion: 'C' century of era is no longer supported.;"+ |
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.
The line break disguises the fact that there's no space after the semi-colon here. At the moment the message is ...supported.;'Y' year-of-era.... If you accept my other suggestion you'll need to add a space here.
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.
You are right, will add a space after a semi-colon. Should be more readable
|
This PR has grown significantly which is sad as I only expected this to be a quick fix. I have added some more tests to cover the message formatting and different scenarios of the pattern. @gwbrown @rjernst @droberts195 would you be able to re-review this again? |
gwbrown
left a comment
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.
The deprecation check LGTM, though I left a couple comments. Others may want to weigh in on the rest.
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java
Outdated
Show resolved
Hide resolved
...in/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java
Outdated
Show resolved
Hide resolved
…k/deprecation/IndexDeprecationChecks.java Co-Authored-By: Gordon Brown <[email protected]>
|
added support for deprecation info on pipelines with date and date_index_name processors |
gwbrown
left a comment
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.
Left a couple minor comments but otherwise LGTM. No need for another round of review after addressing these unless you make other substantial changes.
|
|
||
| //in joda 'Z' was able to parse 'Z' zulu but in java it fails. You have to use 'X' to do that. | ||
| //Caused by: java.time.format.DateTimeParseException: Text '2019-01-01T01:01:01.001Z' could not be parsed at index 23 | ||
| //assertSameMillis("2019-01-01T01:01:01.001Z","YYYY-MM-dd'T'HH:mm:ss.SSSZ","8yyyy-MM-dd'T'HH:mm:ss.SSSZ"); |
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.
I think these lines might be left over from something? Otherwise I'm not sure why they're here.
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.
This whole test case testIncompatiblePatterns was meant to use examples of patterns that are incompatible between joda-java and show how to fix them.
For 'Z' we should go for 'X' so I will just remove this comment.
.../deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java
Outdated
Show resolved
Hide resolved
…k/deprecation/ClusterDeprecationChecks.java Co-Authored-By: Gordon Brown <[email protected]>
|
FYI, this change is breaking some tests in BWC compatible branches. We'll need to update https://scans.gradle.com/s/z2xy2pasutgty/tests/z3ejz3hl3i73s-wptfavgv7zdvi |
Implement deprecation checks for joda incompatible patterns
relates #42010