You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "00sense (via GitHub)" <gi...@apache.org> on 2026/06/24 17:03:28 UTC

[PR] fix(java): fix unbounded LinkedBlockingQueue deserialization [fory]

00sense opened a new pull request, #3786:
URL: https://github.com/apache/fory/pull/3786

   ## Why?
   
   `LinkedBlockingQueueSerializer` fails to deserialize default unbounded `new LinkedBlockingQueue<>()`. Serialize works, deserialize throws `IndexOutOfBoundsException` because capacity on the wire is `Integer.MAX_VALUE` and `checkReadableBytes(capacity)` tries to read ~2GB. Bounded queues like `new LinkedBlockingQueue<>(16)` work fine.
   
   ## What does this PR do?
   
   - Drop `checkReadableBytes(capacity)` in `LinkedBlockingQueueSerializer.newCollection`
   - Add regression test for unbounded queue round-trip
   
   ## Related issues
   
   - Fixes #3783
   
   ## AI Contribution Checklist
   
   - [x] Substantial AI assistance was used in this PR: `no`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] fix(java): fix unbounded LinkedBlockingQueue deserialization [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang merged PR #3786:
URL: https://github.com/apache/fory/pull/3786


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] fix(java): fix unbounded LinkedBlockingQueue deserialization [fory]

Posted by "00sense (via GitHub)" <gi...@apache.org>.
00sense commented on code in PR #3786:
URL: https://github.com/apache/fory/pull/3786#discussion_r3468952604


##########
java/fory-core/src/test/java/org/apache/fory/serializer/collection/CollectionSerializersTest.java:
##########
@@ -1153,6 +1153,13 @@ public void testSerializeJavaBlockingQueue() {
       assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
       assertEquals(deserialized.remainingCapacity() + deserialized.size(), 3);
     }
+    {
+      LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
+      queue.add(1);
+      queue.add(2);
+      LinkedBlockingQueue<Integer> deserialized = serDe(fory, queue);
+      assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
+    }

Review Comment:
   For unbounded LinkedBlockingQueue, remainingCapacity() returns Integer.MAX_VALUE regardless of size(), so remainingCapacity() + size() overflows. The bounded assertion above works because remainingCapacity = capacity - size there. I'd drop that line or use assertEquals(Integer.MAX_VALUE, deserialized.remainingCapacity()) if we want a capacity check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] fix(java): fix unbounded LinkedBlockingQueue deserialization [fory]

Posted by "00sense (via GitHub)" <gi...@apache.org>.
00sense commented on code in PR #3786:
URL: https://github.com/apache/fory/pull/3786#discussion_r3468986563


##########
java/fory-core/src/test/java/org/apache/fory/serializer/collection/CollectionSerializersTest.java:
##########
@@ -1153,6 +1153,13 @@ public void testSerializeJavaBlockingQueue() {
       assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
       assertEquals(deserialized.remainingCapacity() + deserialized.size(), 3);
     }
+    {
+      LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
+      queue.add(1);
+      queue.add(2);
+      LinkedBlockingQueue<Integer> deserialized = serDe(fory, queue);
+      assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
+    }

Review Comment:
   Ignore my earlier comment — I was wrong about the overflow here. For LBQ, remainingCapacity() is capacity - size(), so the assertion is fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] fix(java): fix unbounded LinkedBlockingQueue deserialization [fory]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3786:
URL: https://github.com/apache/fory/pull/3786#discussion_r3468899819


##########
java/fory-core/src/test/java/org/apache/fory/serializer/collection/CollectionSerializersTest.java:
##########
@@ -1153,6 +1153,13 @@ public void testSerializeJavaBlockingQueue() {
       assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
       assertEquals(deserialized.remainingCapacity() + deserialized.size(), 3);
     }
+    {
+      LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
+      queue.add(1);
+      queue.add(2);
+      LinkedBlockingQueue<Integer> deserialized = serDe(fory, queue);
+      assertEquals(new ArrayList<>(deserialized), new ArrayList<>(queue));
+    }

Review Comment:
   The regression test for the default (effectively unbounded) `LinkedBlockingQueue` only verifies element round-trip. Since this serializer is specifically responsible for preserving queue capacity, it would be good to also assert the deserialized queue keeps the `Integer.MAX_VALUE` capacity (via `remainingCapacity() + size()`). This strengthens the regression by ensuring we still exercise the large-capacity case that previously triggered the failure.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org