Skip to content
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

fix duration parsing #714

Merged
merged 1 commit into from Mar 24, 2022
Merged

Conversation

mukundansundar
Copy link
Contributor

Description

Fix the Duration parsing. When reminder dueTime is stored in DB as "30m" or "10s" etc ... Java SDK fails to load the reminder with IndexOutOfBoundException.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #712

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@@ -65,8 +89,7 @@ public static String convertDurationToDaprFormat(Duration value) {

// return empty string for anything negative, it'll only happen for reminder "periods", not dueTimes. A
// negative "period" means fire once only.
if (value == Duration.ZERO
|| (value.compareTo(Duration.ZERO) == 1)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compareTo can produce any value greater than 1, by contract any positive value means the value is greater. This failed the test when only milliseconds were given ...

Signed-off-by: Mukundan Sundararajan <msundar.ms@outlook.com>
@codecov
Copy link

codecov bot commented Mar 24, 2022

Codecov Report

Merging #714 (b381f24) into master (b0b6c4c) will increase coverage by 0.21%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #714      +/-   ##
============================================
+ Coverage     77.98%   78.19%   +0.21%     
- Complexity     1105     1117      +12     
============================================
  Files            97       97              
  Lines          3407     3417      +10     
  Branches        394      399       +5     
============================================
+ Hits           2657     2672      +15     
+ Misses          550      547       -3     
+ Partials        200      198       -2     
Impacted Files Coverage Δ
sdk/src/main/java/io/dapr/utils/DurationUtils.java 98.21% <100.00%> (+2.56%) ⬆️
sdk/src/main/java/io/dapr/utils/Retry.java 75.00% <0.00%> (+25.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0b6c4c...b381f24. Read the comment docs.

@mukundansundar mukundansundar marked this pull request as ready for review March 24, 2022 05:03
@mukundansundar mukundansundar requested review from a team as code owners March 24, 2022 05:03
@artursouza artursouza merged commit c7cc94d into dapr:master Mar 24, 2022
@mukundansundar mukundansundar deleted the fix-parse-duration branch March 24, 2022 05:20
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
artursouza pushed a commit to pkedy/java-sdk that referenced this pull request Jun 22, 2022
Signed-off-by: Artur Souza <artursouza.ms@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actor DurationUtils parsing of duration throws an exception
2 participants