-
Notifications
You must be signed in to change notification settings - Fork 566
Rework date parsing #176
Rework date parsing #176
Conversation
|
Hi @evpaassen, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution! TTYL, AZPRBOT; |
e8fce9c to
55f0f0c
Compare
|
I would suggest much more unit-tests when shortening the code like this. |
|
But the tests cover almost all the cases. I also made sure all cases from the original method are supported. The main thing is that we don't need to parse the timezone suffix manually as this is already supported by SimpleDateFormat. This code is actually close to the original, and doesn't refactor between methods. |
|
have to admit I like the shortened version most. @evpaassen for future PR I would appreciate if you add comments and thoughts to a given PR before we break down to competitions. |
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.
ExchangeServiceBaseDateParsingTest is missing license-header
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 license header has been added.
|
I leave it up to you how you handle this. Maybe another solution could be if @evpaassen creates a PR on your PR @ahaarrestad. |
|
@serious6 Let's have this clear. This is not about competition, or credits or anything. Sometimes it's just easier to explain a different concept with an example. I'm just trying to be helpful here. @ahaarrestad The tests are of course heavily inspired by your tests, as those were looking quite nice. I took one test from yours and adjusted it to verify every pattern supported by the old and new parsing code.
Doesn't it? It should be fixed by f7a7c52. |
55f0f0c to
6b23533
Compare
|
Your fix won't handle the actual problem that occurs if the recurring appointment contains different timezones in the string. Thus my change from the old parsing to the reworked one. Remember that this API might not be (or have been) the only input to the exchange database..... |
6b23533 to
30017e5
Compare
Removed methods from ExchangeServiceBase as they don't belong there. Also fix parsing of recurring dates with a timezone.
30017e5 to
d87e940
Compare
|
OK, I reworked it a little bit again. I guess I misunderstood the original issue a little bit. It should fix #169 now, though. It contains an additional fix for date-only parsing when the date string has no timezone. The library should then assume UTC instead of local timezone. This bug was fixed for date-time string already in #6. |
|
@evpaassen, @ahaarrestad hi I aprreciate both of your contributions and encourage on this topic. Thanks for that in advance. For solving this kind of problem we ran in yesterday maybe @ahaarrestad can provide a test which underlines the expected behavior for the recurring appointment problem, since he pointed out that this PR does not include the fix for this problem. After the integration is done or disproved maybe we can have a merge on @evpaassen PR because it contains the "easier"-implementation for the parsing methods. I dont think it is usefull to merge both of the PR. What do you think of this? |
d87e940 to
dcbb4b5
Compare
|
I'll close my pr with refs to this one. but can we try to get a merge as soon as possible? |
|
@evpaassen are you finished with this? Thanks for the refactoring. I think it´s even better now. |
|
Yes, I'm finished now. |
Fix #169 and rework date parsing by extracting and refactoring the parser
|
Thanks for the contribution @evpaassen , @ahaarrestad |
|
@ahaarrestad Thank you very much for your collaboration on fixing this issue. I really appreciate it. |
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.
Is there a reason for throwing a different kind of exception here? IllegalArgumentException vs. ParseException? I generally prefer to use illegal argument kind of exceptions to reflect programming errors where exceptions based on runtime data would use ParseException (or FormatException in .NET). Thoughts?
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 former method convertUniversalDateTimeStringToDate(...) already did so, so I kept this behaviour. Note that IllegalArgumentException is a runtime exception, where ParseException is a checked exception. I think that most important is that this behaviour is documented in the javadoc, like it is.
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.
Yep, I've just read about checked vs. runtime exceptions, I'm new to the concept of checked exceptions since it is unique to Java. However, I would have thought that parsing should be a checked exception to force the callers to handle the case where the string they are providing is not valid. This is not something that you want to bubble to the top of the stack. It is interesting however that SimpleDateFormat throws ParseException (checked) and long.ParseLong throws IllegalArgumentException (runtime). I would have thought there would be consistency there and both use checked, since I would expect parsing errors to be handled closest to where they are used.
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.
Do we want to expose this for consumers of the library? Should we make it package internal?
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 placed this class in a subpackage (yes, the first subpackage in this library), so we can't make it package private if we keep it there. This shouldn't be a problem though. All major libraries or frameworks expose internal utility classes like this. Otherwise package organisation wouldn't be possible.
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.
So if we change a utility method interface, we will consider this a contract change? Hence, prefer to mark them as deprecated unless we are working on a major version? Or should we have SomeNameSpace.Internal.* to reflect that these are internal packages that shouldn't be used by client apps?
|
@evpaassen and @ahaarrestad great to see us fixing issues as well as making the API and testability better. I was a bit late to the party, but I've added a couple of comments anyway that we can possibly address as a follow up. |
This addresses #169 and reworks date parsing.
Alternative implementation of #175.