Skip to content

Commit 1170eff

Browse files
committed
remove not required SuppressWarnings annotation
1 parent 13b1427 commit 1170eff

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ private JsonObject getChildAdditionalData(IJsonBackedObject serializableObject,
154154

155155
// If the object is a HashMap, iterate through its children
156156
if (fieldObject instanceof HashMap) {
157-
@SuppressWarnings("unchecked")
158157
HashMap<String, Object> serializableChildren = (HashMap<String, Object>) fieldObject;
159158
Iterator<Entry<String, Object>> it = serializableChildren.entrySet().iterator();
160159

src/test/java/com/microsoft/graph/serializer/DefaultSerializerTests.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,21 @@ public void testDeserializeDerivedType() throws Exception {
103103
}
104104

105105
@Test
106-
public void testSerializerCanSerializeVoid() {
106+
public void testSerializerCanSerializeVoidWithoutEmittingWarning() {
107+
// Unfortunately does not assert for existence of Java 9 illegal access warnings
108+
// which seem to written to the console without use of System.err/System.out (so cannot be captured AFAIK).
109+
// @davidmoten
107110
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
108-
Test1 t = new Test1();
111+
HasVoidMember t = new HasVoidMember();
109112
String json = serializer.serializeObject(t);
110113
// this line will emit a warning from Java 9 about illegal access to the constructor of Void
111114
// if gson TypeAdapterFactory is not handling Void properly
112-
serializer.deserializeObject(json, Test1.class);
115+
HasVoidMember t2 = serializer.deserializeObject(json, HasVoidMember.class);
116+
assertEquals(t.x, t2.x);
117+
assertEquals(t.y, t2.y);
113118
}
114119

115-
public static final class Test1 {
120+
public static final class HasVoidMember {
116121
@SerializedName("x")
117122
@Expose
118123
int x = 1;

0 commit comments

Comments
 (0)