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 incorrect cast in NioDomainSocketChannel.parent() (#14409) · netty/netty@8e95a48

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pom.xml
  • transport/src
    • main/java/io/netty/channel/socket/nio
      • NioDomainSocketChannel.java
    • test/java/io/netty/channel/socket/nio
      • NioDomainSocketChannelTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pom.xml‎

Copy file name to clipboardExpand all lines: pom.xml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,13 @@
14111411
<old>method io.netty.channel.ChannelFactory&lt;&amp; extends io.netty.channel.socket.DatagramChannel&gt; io.netty.resolver.dns.DnsNameResolverBuilder::channelFactory()</old>
14121412
<justification>Protected methods of a final class.</justification>
14131413
</item>
1414+
<item>
1415+
<ignore>true</ignore>
1416+
<code>java.method.returnTypeChanged</code>
1417+
<old>method io.netty.channel.socket.ServerSocketChannel io.netty.channel.socket.nio.NioDomainSocketChannel::parent()</old>
1418+
<new>method io.netty.channel.ServerChannel io.netty.channel.socket.nio.NioDomainSocketChannel::parent()</new>
1419+
<justification>Old return type made no sense, the parent channel is a NioServerDomainSocketChannel which does not implement ServerSocketChannel. The method always threw a ClassCastException (except for null).</justification>
1420+
</item>
14141421
</differences>
14151422
</revapi.differences>
14161423
</analysisConfiguration>
@@ -1443,6 +1450,7 @@
14431450
<exclude>@io.netty.util.internal.UnstableApi</exclude>
14441451
<exclude>io.netty.util.internal.shaded</exclude>
14451452
<exclude>io.netty.buffer.AdaptivePoolingAllocator$ChunkAllocator</exclude>
1453+
<exclude>io.netty.channel.socket.nio.NioDomainSocketChannel#parent()</exclude>
14461454
</excludes>
14471455
<overrideCompatibilityChangeParameters>
14481456
<overrideCompatibilityChangeParameter>
Collapse file

‎transport/src/main/java/io/netty/channel/socket/nio/NioDomainSocketChannel.java‎

Copy file name to clipboardExpand all lines: transport/src/main/java/io/netty/channel/socket/nio/NioDomainSocketChannel.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
import io.netty.channel.FileRegion;
3131
import io.netty.channel.MessageSizeEstimator;
3232
import io.netty.channel.RecvByteBufAllocator;
33+
import io.netty.channel.ServerChannel;
3334
import io.netty.channel.WriteBufferWaterMark;
3435
import io.netty.channel.nio.AbstractNioByteChannel;
3536
import io.netty.channel.socket.DuplexChannel;
3637
import io.netty.channel.socket.DuplexChannelConfig;
37-
import io.netty.channel.socket.ServerSocketChannel;
3838
import io.netty.util.internal.PlatformDependent;
3939
import io.netty.util.internal.SocketUtils;
4040
import io.netty.util.internal.SuppressJava6Requirement;
@@ -73,7 +73,7 @@ public final class NioDomainSocketChannel extends AbstractNioByteChannel
7373
private volatile boolean isInputShutdown;
7474
private volatile boolean isOutputShutdown;
7575

76-
private static SocketChannel newChannel(SelectorProvider provider) {
76+
static SocketChannel newChannel(SelectorProvider provider) {
7777
if (PlatformDependent.javaVersion() < 16) {
7878
throw new UnsupportedOperationException("Only supported on java 16+");
7979
}
@@ -125,8 +125,8 @@ public NioDomainSocketChannel(Channel parent, SocketChannel socket) {
125125
}
126126

127127
@Override
128-
public ServerSocketChannel parent() {
129-
return (ServerSocketChannel) super.parent();
128+
public ServerChannel parent() {
129+
return (ServerChannel) super.parent();
130130
}
131131

132132
@Override
Collapse file

‎transport/src/test/java/io/netty/channel/socket/nio/NioDomainSocketChannelTest.java‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2024 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.channel.socket.nio;
17+
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
20+
import org.junit.jupiter.api.condition.EnabledForJreRange;
21+
import org.junit.jupiter.api.condition.JRE;
22+
23+
import java.io.IOException;
24+
import java.nio.channels.SocketChannel;
25+
import java.nio.channels.spi.SelectorProvider;
26+
27+
@EnabledForJreRange(min = JRE.JAVA_16)
28+
class NioDomainSocketChannelTest {
29+
@Test
30+
void accessParent() throws IOException {
31+
NioServerDomainSocketChannel parent = new NioServerDomainSocketChannel();
32+
SocketChannel ch = NioDomainSocketChannel.newChannel(SelectorProvider.provider());
33+
NioDomainSocketChannel child = new NioDomainSocketChannel(parent, ch);
34+
Assertions.assertSame(parent, child.parent());
35+
ch.close();
36+
}
37+
}

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.