GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix MpscIntQueue bug (#16023) (#16027) · netty/netty@66ec8d6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common/src
    • main/java/io/netty/util/concurrent
      • MpscAtomicIntegerArrayQueue.java
    • test/java/io/netty/util/concurrent
      • MpscIntQueueTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common/src/main/java/io/netty/util/concurrent/MpscAtomicIntegerArrayQueue.java‎

Copy file name to clipboardExpand all lines: common/src/main/java/io/netty/util/concurrent/MpscAtomicIntegerArrayQueue.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public MpscAtomicIntegerArrayQueue(int capacity, int emptyValue) {
5656
super(MathUtil.safeFindNextPositivePowerOfTwo(capacity));
5757
if (emptyValue != 0) {
5858
this.emptyValue = emptyValue;
59-
int end = capacity - 1;
59+
int end = length() - 1;
6060
for (int i = 0; i < end; i++) {
6161
lazySet(i, emptyValue);
6262
}
Collapse file

‎common/src/test/java/io/netty/util/concurrent/MpscIntQueueTest.java‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package io.netty.util.concurrent;
17+
18+
import io.netty.util.IntSupplier;
19+
import org.junit.jupiter.params.ParameterizedTest;
20+
import org.junit.jupiter.params.provider.ValueSource;
21+
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
25+
class MpscIntQueueTest {
26+
@ParameterizedTest
27+
@ValueSource(ints = {1, 7, 8, 15, 16, 17})
28+
void mustFillWithSpecifiedEmptyEntry(int size) throws Exception {
29+
MpscIntQueue queue = new MpscAtomicIntegerArrayQueue(size, -1);
30+
int filled = queue.fill(size, new IntSupplier() {
31+
@Override
32+
public int get() throws Exception {
33+
return 42;
34+
}
35+
});
36+
assertEquals(size, filled);
37+
for (int i = 0; i < size; i++) {
38+
assertEquals(42, queue.poll());
39+
}
40+
assertEquals(-1, queue.poll());
41+
assertTrue(queue.isEmpty());
42+
}
43+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.