-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Improve versioning support documentation and validate version #2214
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,19 +240,15 @@ private boolean isValidVersion(Since since, Until until) { | |
private boolean isValidSince(Since annotation) { | ||
if (annotation != null) { | ||
double annotationVersion = annotation.value(); | ||
if (annotationVersion > version) { | ||
return false; | ||
} | ||
return version >= annotationVersion; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should behave equivalently (unless someone uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, the old code was surprising. |
||
} | ||
return true; | ||
} | ||
|
||
private boolean isValidUntil(Until annotation) { | ||
if (annotation != null) { | ||
double annotationVersion = annotation.value(); | ||
if (annotationVersion <= version) { | ||
return false; | ||
} | ||
return version < annotationVersion; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should behave equivalently (unless someone uses |
||
} | ||
return true; | ||
} | ||
|
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.
Have added this
< 0.0
check because negative version numbers are probably rather uncommon and this could cause collisions with the undocumented value-1.0
representing no version:gson/gson/src/main/java/com/google/gson/internal/Excluder.java
Line 51 in 2860908