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 IDE warnings in SslHandler (#16237) (#16299) · netty/netty@dffffe2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler/src/main/java/io/netty/handler/ssl
    • SslHandler.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/SslHandler.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/SslHandler.java
+33-81Lines changed: 33 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,7 @@ public void closeOutbound(final Promise<Void> promise) {
649649
if (ctx.executor().inEventLoop()) {
650650
closeOutbound0(promise);
651651
} else {
652-
ctx.executor().execute(new Runnable() {
653-
@Override
654-
public void run() {
655-
closeOutbound0(promise);
656-
}
657-
});
652+
ctx.executor().execute(() -> closeOutbound0(promise));
658653
}
659654
}
660655

@@ -1017,12 +1012,6 @@ private boolean wrapNonAppData(final ChannelHandlerContext ctx, boolean inUnwrap
10171012
if (result.bytesProduced() == 0 && status != HandshakeStatus.NEED_TASK) {
10181013
break;
10191014
}
1020-
1021-
// It should not consume empty buffers when it is not handshaking
1022-
// Fix for Android, where it was encrypting empty buffers even when not handshaking
1023-
if (result.bytesConsumed() == 0 && result.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
1024-
break;
1025-
}
10261015
}
10271016
} finally {
10281017
if (out != null) {
@@ -1589,25 +1578,15 @@ private boolean setHandshakeSuccessUnwrapMarkReentry() throws SSLException {
15891578

15901579
private void executeNotifyClosePromise(final ChannelHandlerContext ctx) {
15911580
try {
1592-
ctx.executor().execute(new Runnable() {
1593-
@Override
1594-
public void run() {
1595-
notifyClosePromise(null);
1596-
}
1597-
});
1581+
ctx.executor().execute(() -> notifyClosePromise(null));
15981582
} catch (RejectedExecutionException e) {
15991583
notifyClosePromise(e);
16001584
}
16011585
}
16021586

16031587
private void executeChannelRead(final ChannelHandlerContext ctx, final ByteBuf decodedOut) {
16041588
try {
1605-
ctx.executor().execute(new Runnable() {
1606-
@Override
1607-
public void run() {
1608-
ctx.fireChannelRead(decodedOut);
1609-
}
1610-
});
1589+
ctx.executor().execute(() -> ctx.fireChannelRead(decodedOut));
16111590
} catch (RejectedExecutionException e) {
16121591
decodedOut.release();
16131592
throw e;
@@ -1722,12 +1701,7 @@ boolean resumeLater() {
17221701
*/
17231702
private final class SslTasksRunner implements Runnable {
17241703
private final boolean inUnwrap;
1725-
private final Runnable runCompleteTask = new Runnable() {
1726-
@Override
1727-
public void run() {
1728-
runComplete();
1729-
}
1730-
};
1704+
private final Runnable runCompleteTask = this::runComplete;
17311705

17321706
SslTasksRunner(boolean inUnwrap) {
17331707
this.inUnwrap = inUnwrap;
@@ -1882,12 +1856,7 @@ void runComplete() {
18821856
// decoding.
18831857
//
18841858
// See https://github.com/netty/netty-tcnative/issues/680
1885-
executor.execute(new Runnable() {
1886-
@Override
1887-
public void run() {
1888-
resumeOnEventExecutor();
1889-
}
1890-
});
1859+
executor.execute(this::resumeOnEventExecutor);
18911860
}
18921861

18931862
@Override
@@ -1917,12 +1886,9 @@ private void handleException(final Throwable cause) {
19171886
safeExceptionCaught(cause);
19181887
} else {
19191888
try {
1920-
executor.execute(new Runnable() {
1921-
@Override
1922-
public void run() {
1923-
clearState(STATE_PROCESS_TASK);
1924-
safeExceptionCaught(cause);
1925-
}
1889+
executor.execute(() -> {
1890+
clearState(STATE_PROCESS_TASK);
1891+
safeExceptionCaught(cause);
19261892
});
19271893
} catch (RejectedExecutionException ignore) {
19281894
clearState(STATE_PROCESS_TASK);
@@ -2152,7 +2118,7 @@ public Future<Channel> renegotiate() {
21522118
throw new IllegalStateException();
21532119
}
21542120

2155-
return renegotiate(ctx.executor().<Channel>newPromise());
2121+
return renegotiate(ctx.executor().newPromise());
21562122
}
21572123

21582124
/**
@@ -2168,12 +2134,7 @@ public Future<Channel> renegotiate(final Promise<Channel> promise) {
21682134

21692135
EventExecutor executor = ctx.executor();
21702136
if (!executor.inEventLoop()) {
2171-
executor.execute(new Runnable() {
2172-
@Override
2173-
public void run() {
2174-
renegotiateOnEventLoop(promise);
2175-
}
2176-
});
2137+
executor.execute(() -> renegotiateOnEventLoop(promise));
21772138
return promise;
21782139
}
21792140

@@ -2238,21 +2199,18 @@ private void applyHandshakeTimeout() {
22382199
return;
22392200
}
22402201

2241-
final Future<?> timeoutFuture = ctx.executor().schedule(new Runnable() {
2242-
@Override
2243-
public void run() {
2244-
if (localHandshakePromise.isDone()) {
2245-
return;
2246-
}
2247-
SSLException exception =
2248-
new SslHandshakeTimeoutException("handshake timed out after " + handshakeTimeoutMillis + "ms");
2249-
try {
2250-
if (localHandshakePromise.tryFailure(exception)) {
2251-
SslUtils.handleHandshakeFailure(ctx, exception, true);
2252-
}
2253-
} finally {
2254-
releaseAndFailAll(ctx, exception);
2202+
final Future<?> timeoutFuture = ctx.executor().schedule(() -> {
2203+
if (localHandshakePromise.isDone()) {
2204+
return;
2205+
}
2206+
SSLException exception =
2207+
new SslHandshakeTimeoutException("handshake timed out after " + handshakeTimeoutMillis + "ms");
2208+
try {
2209+
if (localHandshakePromise.tryFailure(exception)) {
2210+
SslUtils.handleHandshakeFailure(ctx, exception, true);
22552211
}
2212+
} finally {
2213+
releaseAndFailAll(ctx, exception);
22562214
}
22572215
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
22582216

@@ -2296,15 +2254,12 @@ private void safeClose(
22962254
long closeNotifyTimeout = closeNotifyFlushTimeoutMillis;
22972255
if (closeNotifyTimeout > 0) {
22982256
// Force-close the connection if close_notify is not fully sent in time.
2299-
timeoutFuture = ctx.executor().schedule(new Runnable() {
2300-
@Override
2301-
public void run() {
2302-
// May be done in the meantime as cancel(...) is only best effort.
2303-
if (!flushFuture.isDone()) {
2304-
logger.warn("{} Last write attempt timed out; force-closing the connection.",
2305-
ctx.channel());
2257+
timeoutFuture = ctx.executor().schedule(() -> {
2258+
// May be done in the meantime as cancel(...) is only best effort.
2259+
if (!flushFuture.isDone()) {
2260+
logger.warn("{} Last write attempt timed out; force-closing the connection.",
2261+
ctx.channel());
23062262
addCloseListener(ctx.close(), promise);
2307-
}
23082263
}
23092264
}, closeNotifyTimeout, TimeUnit.MILLISECONDS);
23102265
} else {
@@ -2328,17 +2283,14 @@ public void run() {
23282283
final Future<?> closeNotifyReadTimeoutFuture;
23292284

23302285
if (!sslClosePromise.isDone()) {
2331-
closeNotifyReadTimeoutFuture = ctx.executor().schedule(new Runnable() {
2332-
@Override
2333-
public void run() {
2334-
if (!sslClosePromise.isDone()) {
2335-
logger.debug(
2336-
"{} did not receive close_notify in {}ms; force-closing the connection.",
2337-
ctx.channel(), closeNotifyReadTimeout);
2338-
2339-
// Do the close now...
2286+
closeNotifyReadTimeoutFuture = ctx.executor().schedule(() -> {
2287+
if (!sslClosePromise.isDone()) {
2288+
logger.debug(
2289+
"{} did not receive close_notify in {}ms; force-closing the connection.",
2290+
ctx.channel(), closeNotifyReadTimeout);
2291+
2292+
// Do the close now...
23402293
addCloseListener(ctx.close(), promise);
2341-
}
23422294
}
23432295
}, closeNotifyReadTimeout, TimeUnit.MILLISECONDS);
23442296
} else {

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.