Skip to content

Commit 8fe3715

Browse files
authored
replace ReactorNettyClient#Identity() with Function.identity() (#116)
Motivation: Closing [issue-113](#113) Modification: Replaced the custom class ReactorNettyClient#Identity() with Function.identity() Result: Сode has become more universal
1 parent af54bae commit 8fe3715

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/main/java/io/asyncer/r2dbc/mysql/client/ReactorNettyClient.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public <T> Flux<T> exchange(ClientMessage request,
156156
.doOnDiscard(ReferenceCounted.class, RELEASE);
157157

158158
requestQueue.submit(RequestTask.wrap(request, sink, responses));
159-
}).flatMapMany(identity());
159+
}).flatMapMany(Function.identity());
160160
}
161161

162162
@Override
@@ -189,7 +189,7 @@ public <T> Flux<T> exchange(FluxExchangeable<T> exchangeable) {
189189
requestQueue.submit(RequestTask.wrap(exchangeable, sink, OperatorUtils.discardOnCancel(responses)
190190
.doOnDiscard(ReferenceCounted.class, RELEASE)
191191
.doOnCancel(exchangeable::dispose)));
192-
}).flatMapMany(identity());
192+
}).flatMapMany(Function.identity());
193193
}
194194

195195
@Override
@@ -208,7 +208,7 @@ public Mono<Void> close() {
208208
logger.error("Exit message sending failed due to {}, force closing", result);
209209
}
210210
})));
211-
}).flatMap(identity()).onErrorResume(e -> {
211+
}).flatMap(Function.identity()).onErrorResume(e -> {
212212
logger.error("Exit message sending failed, force closing", e);
213213
return Mono.empty();
214214
}).then(forceClose());
@@ -286,11 +286,6 @@ private void handleClose() {
286286
}
287287
}
288288

289-
@SuppressWarnings("unchecked")
290-
private static <T> Function<T, T> identity() {
291-
return (Function<T, T>) Identity.INSTANCE;
292-
}
293-
294289
private final class ResponseSubscriber implements CoreSubscriber<Object> {
295290

296291
private final ResponseSink sink;
@@ -361,14 +356,4 @@ public void next(ServerMessage message) {
361356
responseProcessor.emitNext(message, EmitFailureHandler.FAIL_FAST);
362357
}
363358
}
364-
365-
private static final class Identity implements Function<Object, Object> {
366-
367-
private static final Identity INSTANCE = new Identity();
368-
369-
@Override
370-
public Object apply(Object o) {
371-
return o;
372-
}
373-
}
374359
}

0 commit comments

Comments
 (0)