google / google/jsontoken

UrlBasedVerifierProvider does not work with recent version of gson

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
21
Forks
16
Avg merge
2d 2h
Merged PRs (30d)
2

Description

```
What steps will reproduce the problem?
1.
In pom.xml switch to a recent version of gson, 2.2.4 for example
2.
Use UrlBasedVerifierProvider to fetch a certicate from an url.
3.

What is the expected output? What do you see instead?
I should get a List

I get an exception
[INFO] com.google.gson.JsonSyntaxException:
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true)
to accept malformed JSON at line 2 column 2
[INFO] at com.google.gson.JsonParser.parse(JsonParser.java:65)
[INFO] at com.google.gson.JsonParser.parse(JsonParser.java:45)
[INFO] at
net.oauth.jsontoken.discovery.UrlBasedVerifierProvider.findVerifier(UrlBasedVeri
fierProvider.java:58)
[INFO] at
net.oauth.jsontoken.JsonTokenParser.verifyAndDeserialize(JsonTokenParser.java:10
8)

How to Fix it
@
https://code.google.com/p/jsontoken/source/browse/trunk/src/main/java/net/oauth/
jsontoken/discovery/UrlBasedVerifierProvider.java#51

replace
String line = "";
do {
line = buff.readLine();
content.append(line + "\n");
} while (line != null);

with
String line = buff.readLine();
while (line != null) {
content.append(line + "\n");
line = buff.readLine();
} ;

The later won't add an unwanted "null" string at the end of the json string.
```

Original issue reported on code.google.com by `aurelien...@gmail.com` on 22 Aug 2013 at 8:10

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.