Skip to content

Commit c3a1540

Browse files
authored
Use ChannelException if DomainSocketChannelConfig method throws (#15543)
Motivation: We usually use ChannelException if one of the ChannelConfig methods throw so we should do the same also for the DomainSocketChannelConfig implementations Modifications: - Replace RuntimeException with ChannelException Result: Cleanup and more consistent behaviour
1 parent 87970fb commit c3a1540

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDomainSocketChannelConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.netty.channel.epoll;
1717

1818
import io.netty.buffer.ByteBufAllocator;
19+
import io.netty.channel.ChannelException;
1920
import io.netty.channel.ChannelOption;
2021
import io.netty.channel.MessageSizeEstimator;
2122
import io.netty.channel.RecvByteBufAllocator;
@@ -185,7 +186,7 @@ public int getSendBufferSize() {
185186
try {
186187
return ((EpollDomainSocketChannel) channel).socket.getSendBufferSize();
187188
} catch (IOException e) {
188-
throw new RuntimeException(e);
189+
throw new ChannelException(e);
189190
}
190191
}
191192

@@ -194,15 +195,15 @@ public EpollDomainSocketChannelConfig setSendBufferSize(int sendBufferSize) {
194195
((EpollDomainSocketChannel) channel).socket.setSendBufferSize(sendBufferSize);
195196
return this;
196197
} catch (IOException e) {
197-
throw new RuntimeException(e);
198+
throw new ChannelException(e);
198199
}
199200
}
200201

201202
public int getReceiveBufferSize() {
202203
try {
203204
return ((EpollDomainSocketChannel) channel).socket.getReceiveBufferSize();
204205
} catch (IOException e) {
205-
throw new RuntimeException(e);
206+
throw new ChannelException(e);
206207
}
207208
}
208209

@@ -211,7 +212,7 @@ public EpollDomainSocketChannelConfig setReceiveBufferSize(int receiveBufferSize
211212
((EpollDomainSocketChannel) channel).socket.setReceiveBufferSize(receiveBufferSize);
212213
return this;
213214
} catch (IOException e) {
214-
throw new RuntimeException(e);
215+
throw new ChannelException(e);
215216
}
216217
}
217218
}

transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringDomainSocketChannelConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.netty.channel.uring;
1717

1818
import io.netty.buffer.ByteBufAllocator;
19+
import io.netty.channel.ChannelException;
1920
import io.netty.channel.ChannelOption;
2021
import io.netty.channel.MessageSizeEstimator;
2122
import io.netty.channel.RecvByteBufAllocator;
@@ -92,7 +93,7 @@ public int getSendBufferSize() {
9293
try {
9394
return ((IoUringDomainSocketChannel) channel).socket.getSendBufferSize();
9495
} catch (IOException e) {
95-
throw new RuntimeException(e);
96+
throw new ChannelException(e);
9697
}
9798
}
9899

@@ -101,15 +102,15 @@ public IoUringDomainSocketChannelConfig setSendBufferSize(int sendBufferSize) {
101102
((IoUringDomainSocketChannel) channel).socket.setSendBufferSize(sendBufferSize);
102103
return this;
103104
} catch (IOException e) {
104-
throw new RuntimeException(e);
105+
throw new ChannelException(e);
105106
}
106107
}
107108

108109
public int getReceiveBufferSize() {
109110
try {
110111
return ((IoUringDomainSocketChannel) channel).socket.getReceiveBufferSize();
111112
} catch (IOException e) {
112-
throw new RuntimeException(e);
113+
throw new ChannelException(e);
113114
}
114115
}
115116

@@ -118,7 +119,7 @@ public IoUringDomainSocketChannelConfig setReceiveBufferSize(int receiveBufferSi
118119
((IoUringDomainSocketChannel) channel).socket.setReceiveBufferSize(receiveBufferSize);
119120
return this;
120121
} catch (IOException e) {
121-
throw new RuntimeException(e);
122+
throw new ChannelException(e);
122123
}
123124
}
124125

transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueDomainSocketChannelConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.netty.channel.kqueue;
1717

1818
import io.netty.buffer.ByteBufAllocator;
19+
import io.netty.channel.ChannelException;
1920
import io.netty.channel.ChannelOption;
2021
import io.netty.channel.MessageSizeEstimator;
2122
import io.netty.channel.RecvByteBufAllocator;
@@ -174,7 +175,7 @@ public int getSendBufferSize() {
174175
try {
175176
return ((KQueueDomainSocketChannel) channel).socket.getSendBufferSize();
176177
} catch (IOException e) {
177-
throw new RuntimeException(e);
178+
throw new ChannelException(e);
178179
}
179180
}
180181

@@ -183,15 +184,15 @@ public KQueueDomainSocketChannelConfig setSendBufferSize(int sendBufferSize) {
183184
((KQueueDomainSocketChannel) channel).socket.setSendBufferSize(sendBufferSize);
184185
return this;
185186
} catch (IOException e) {
186-
throw new RuntimeException(e);
187+
throw new ChannelException(e);
187188
}
188189
}
189190

190191
public int getReceiveBufferSize() {
191192
try {
192193
return ((KQueueDomainSocketChannel) channel).socket.getReceiveBufferSize();
193194
} catch (IOException e) {
194-
throw new RuntimeException(e);
195+
throw new ChannelException(e);
195196
}
196197
}
197198

@@ -200,7 +201,7 @@ public KQueueDomainSocketChannelConfig setReceiveBufferSize(int receiveBufferSiz
200201
((KQueueDomainSocketChannel) channel).socket.setReceiveBufferSize(receiveBufferSize);
201202
return this;
202203
} catch (IOException e) {
203-
throw new RuntimeException(e);
204+
throw new ChannelException(e);
204205
}
205206
}
206207

0 commit comments

Comments
 (0)