Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-06-05 11:52:16 -0400
committerKevin Sawicki2012-06-06 13:03:26 -0400
commit2056b1f217eebf7c862c0995a5026ccb491de9a4 (patch)
tree0e952789984450f11b7d3e52ab80631bf09250b8
parent3dbb4dd7e04e56da8fb8f46e0b1047a7225623c5 (diff)
downloadegit-github-2056b1f217eebf7c862c0995a5026ccb491de9a4.tar.gz
egit-github-2056b1f217eebf7c862c0995a5026ccb491de9a4.tar.xz
egit-github-2056b1f217eebf7c862c0995a5026ccb491de9a4.zip
Suppress parse exceptions deserializing event payloads
Older events may include payloads with different field names or value types and parse exceptions that occur currently cause the entire list parsing to fail. By catching the parse exception on payload deserialization the event can still be returned with core fields but just a missing payload. This will allow returned pages with a mix of legacy and new event payloads to return successfully with proper payloads for new events and null payloads for legacy events. Change-Id: Iac866dd2d7a68ebbcb4ea7bec0c567a37e560ba0
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java
index 8cbfb9ab..cc53bcad 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java
@@ -123,8 +123,14 @@ public class EventFormatter implements JsonDeserializer<Event> {
else
return event;
- EventPayload typedPayload = context.deserialize(rawPayload,
- payloadClass);
- return event.setPayload(typedPayload);
+ try {
+ EventPayload typedPayload = context.deserialize(rawPayload,
+ payloadClass);
+ return event.setPayload(typedPayload);
+ } catch (JsonParseException jpe) {
+ // Parse exception here denotes legacy payloads with differing
+ // fields than built-in payload classes provide
+ return event;
+ }
}
}

Back to the top