Skip to content

Commit fc7084d

Browse files
authored
JAVA-5505 minor refactoring (#1488)
JAVA-5505
1 parent c4af1c5 commit fc7084d

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

driver-core/src/main/com/mongodb/internal/connection/tlschannel/async/AsynchronousTlsChannel.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public <A> void read(ByteBuffer dst, A attach, CompletionHandler<Integer, ? supe
9898
new ByteBufferSet(dst),
9999
0,
100100
TimeUnit.MILLISECONDS,
101-
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
102-
e -> group.executor.submit(() -> handler.failed(e, attach)));
101+
c -> group.submit(() -> handler.completed((int) c, attach)),
102+
e -> group.submit(() -> handler.failed(e, attach)));
103103
}
104104

105105
@Override
@@ -119,8 +119,8 @@ public <A> void read(
119119
new ByteBufferSet(dst),
120120
timeout,
121121
unit,
122-
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
123-
e -> group.executor.submit(() -> handler.failed(e, attach)));
122+
c -> group.submit(() -> handler.completed((int) c, attach)),
123+
e -> group.submit(() -> handler.failed(e, attach)));
124124
}
125125

126126
@Override
@@ -145,8 +145,8 @@ public <A> void read(
145145
bufferSet,
146146
timeout,
147147
unit,
148-
c -> group.executor.submit(() -> handler.completed(c, attach)),
149-
e -> group.executor.submit(() -> handler.failed(e, attach)));
148+
c -> group.submit(() -> handler.completed(c, attach)),
149+
e -> group.submit(() -> handler.failed(e, attach)));
150150
}
151151

152152
@Override
@@ -185,8 +185,8 @@ public <A> void write(ByteBuffer src, A attach, CompletionHandler<Integer, ? sup
185185
new ByteBufferSet(src),
186186
0,
187187
TimeUnit.MILLISECONDS,
188-
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
189-
e -> group.executor.submit(() -> handler.failed(e, attach)));
188+
c -> group.submit(() -> handler.completed((int) c, attach)),
189+
e -> group.submit(() -> handler.failed(e, attach)));
190190
}
191191

192192
@Override
@@ -205,8 +205,8 @@ public <A> void write(
205205
new ByteBufferSet(src),
206206
timeout,
207207
unit,
208-
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
209-
e -> group.executor.submit(() -> handler.failed(e, attach)));
208+
c -> group.submit(() -> handler.completed((int) c, attach)),
209+
e -> group.submit(() -> handler.failed(e, attach)));
210210
}
211211

212212
@Override
@@ -228,8 +228,8 @@ public <A> void write(
228228
bufferSet,
229229
timeout,
230230
unit,
231-
c -> group.executor.submit(() -> handler.completed(c, attach)),
232-
e -> group.executor.submit(() -> handler.failed(e, attach)));
231+
c -> group.submit(() -> handler.completed(c, attach)),
232+
e -> group.submit(() -> handler.failed(e, attach)));
233233
}
234234

235235
@Override
@@ -251,11 +251,11 @@ public Future<Integer> write(ByteBuffer src) {
251251
}
252252

253253
private <A> void completeWithZeroInt(A attach, CompletionHandler<Integer, ? super A> handler) {
254-
group.executor.submit(() -> handler.completed(0, attach));
254+
group.submit(() -> handler.completed(0, attach));
255255
}
256256

257257
private <A> void completeWithZeroLong(A attach, CompletionHandler<Long, ? super A> handler) {
258-
group.executor.submit(() -> handler.completed(0L, attach));
258+
group.submit(() -> handler.completed(0L, attach));
259259
}
260260

261261
/**

driver-core/src/main/com/mongodb/internal/connection/tlschannel/async/AsynchronousTlsChannelGroup.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static final class WriteOperation extends Operation {
159159

160160
private final Selector selector;
161161

162-
final ExecutorService executor;
162+
private final ExecutorService executor;
163163

164164
private final ScheduledThreadPoolExecutor timeoutExecutor =
165165
new ScheduledThreadPoolExecutor(
@@ -228,6 +228,10 @@ public AsynchronousTlsChannelGroup() {
228228
this(Runtime.getRuntime().availableProcessors());
229229
}
230230

231+
void submit(final Runnable r) {
232+
executor.submit(r);
233+
}
234+
231235
RegisteredSocket registerSocket(TlsChannel reader, SocketChannel socketChannel) {
232236
if (shutdown != Shutdown.No) {
233237
throw new ShutdownChannelGroupException();

0 commit comments

Comments
 (0)