nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: skiptests/astraea
Pull request #336 (2022-05-13 17:29:29)

Nonexistent instance group id should be null
將不存在的instance id改為顯示null，這是因為gson還不支援optional


Patch:
diff --git a/app/src/main/java/org/astraea/web/GroupHandler.java b/app/src/main/java/org/astraea/web/GroupHandler.java
index fe9ceee4..d579d50c 100644
--- a/app/src/main/java/org/astraea/web/GroupHandler.java
+++ b/app/src/main/java/org/astraea/web/GroupHandler.java
@@ -36,7 +36,9 @@ public class GroupHandler implements Handler {
                                 entry ->
                                     new Member(
                                         entry.getKey().memberId(),
-                                        entry.getKey().groupInstanceId(),
+                                        // gson does not support Optional
+                                        // see https://github.com/google/gson/issues/1102
+                                        entry.getKey().groupInstanceId().orElse(null),
                                         entry.getKey().clientId(),
                                         entry.getKey().host(),
                                         entry.getValue().stream()
@@ -87,15 +89,15 @@ public class GroupHandler implements Handler {
   }
 
   static class Member implements JsonObject {
-    private final String memberId;
-    private final Optional<String> groupInstanceId;
-    private final String clientId;
-    private final String host;
-    private final List<OffsetProgress> offsetProgress;
+    final String memberId;
+    final String groupInstanceId;
+    final String clientId;
+    final String host;
+    final List<OffsetProgress> offsetProgress;
 
     Member(
         String memberId,
-        Optional<String> groupInstanceId,
+        String groupInstanceId,
         String clientId,
         String host,
         List<OffsetProgress> offsetProgress) {


Test patch:
diff --git a/app/src/test/java/org/astraea/web/GroupHandlerTest.java b/app/src/test/java/org/astraea/web/GroupHandlerTest.java
index 068212ce..9434c6a6 100644
--- a/app/src/test/java/org/astraea/web/GroupHandlerTest.java
+++ b/app/src/test/java/org/astraea/web/GroupHandlerTest.java
@@ -37,6 +37,12 @@ public class GroupHandlerTest extends RequireBrokerCluster {
         Assertions.assertEquals(1, response.groups.size());
         Assertions.assertEquals(groupId, response.groups.iterator().next().groupId);
         Assertions.assertEquals(1, response.groups.iterator().next().members.size());
+        response
+            .groups
+            .iterator()
+            .next()
+            .members
+            .forEach(m -> Assertions.assertNull(m.groupInstanceId));
       }
     }
   }