Skip to content

Commit

Permalink
Merge pull request #154 from nextcloud/1.0.43.1
Browse files Browse the repository at this point in the history
Backport of #153: ignore unhandled rich objects
  • Loading branch information
AndyScherzinger authored Jul 4, 2018
2 parents 2c7ac04 + d3f0ac2 commit b9b97b3
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,31 @@ private RichObject readObject(String tag, JsonReader in) throws IOException {
RichObject richObject = new RichObject();
richObject.setTag(tag);
while (in.hasNext()) {
String name = in.nextName();

String name;
try {
name = in.nextName();
} catch (IllegalStateException e) {
name = "";
}

switch (name) {
case "type":
richObject.setType(in.nextString());
richObject.setType(getNextString(in));
break;
case "id":
richObject.setId(in.nextString());
richObject.setId(getNextString(in));
break;
case "name":
richObject.setName(in.nextString());
richObject.setName(getNextString(in));
break;
case "path":
richObject.setPath(in.nextString());
richObject.setPath(getNextString(in));
break;
case "link":
richObject.setLink(in.nextString());
richObject.setLink(getNextString(in));
break;
case "server":
richObject.setLink(in.nextString());
richObject.setLink(getNextString(in));
break;
default:
in.skipValue(); // ignore value
Expand All @@ -124,5 +129,13 @@ private RichObject readObject(String tag, JsonReader in) throws IOException {
in.endObject();
return richObject;
}

private String getNextString(JsonReader in) {
try {
return in.nextString();
} catch (IllegalStateException | IOException e) {
return "";
}
}
}

0 comments on commit b9b97b3

Please sign in to comment.