Parse and fix broken github api urls#82
Parse and fix broken github api urls#82chondent merged 2 commits intospotify:masterspotify/github-java-client:masterfrom chondent:fix-invalid-github-urlchondent/github-java-client:fix-invalid-github-urlCopy head branch name to clipboard
Conversation
Codecov Report
@@ Coverage Diff @@
## master #82 +/- ##
============================================
+ Coverage 68.83% 70.20% +1.37%
- Complexity 198 222 +24
============================================
Files 32 36 +4
Lines 770 866 +96
Branches 33 36 +3
============================================
+ Hits 530 608 +78
- Misses 217 233 +16
- Partials 23 25 +2
Continue to review full report at Codecov.
|
|
Just realised this won't handle branches with forward slashes in the name. Working on a fix. |
a2d7570 to
a4573e4
Compare
If a branch has a percent symbol in it, github will sometimes return a URI that java's URI object can't parse. This patch ensures that in such a case we url-escape the branch name.
a4573e4 to
22bce81
Compare
| Optional<URI> protectionUrl(); | ||
| } | ||
|
|
||
| class BranchDeserializer extends JsonDeserializer<ImmutableBranch> { |
There was a problem hiding this comment.
Could BranchDeserializer class be defined in a separate file (BranchDeserializer.java)?
I understand it compiles just fine and it is a matter of taste... The current code within BranchDeserializer does not look like a data structure definition for example, but rather a utility class.
The code might be cleaner if class is defined within its own java file and it would allow for reusability (if needed).
This is just a comment.
In #82 we added a custom deserializer for the `Branch` class. This deserializer didn't handle certain cases properly that the GH API would return. In particular the case where the `protected` field was set and no `protection_url` is present would lead to a NPE in the deserializer. To avoid this error and make the whole parser more resilient to different API results, let's reduce the scope of the custom deserializer to only parse the `protection_url` field instead of the whole `Branch` class. There should be no change in runtime behavior apart from fixing the error cases.
If a branch has a percent symbol in it, github will sometimes return a
URI that java's URI object can't parse. This patch ensures that in such
a case we url-escape the branch name.