Skip to content

Commit dc5dc01

Browse files
committed
Rename Lambda parameters by type in JedisConnection and JedisInvoker.
Refactor, organize source and fix compiler warnings.
1 parent 4c269a7 commit dc5dc01

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private Object doInvoke(boolean status, Function<Jedis, Object> directFunction,
209209
Function<ResponseCommands, Response<Object>> pipelineFunction, Converter<Object, Object> converter,
210210
Supplier<Object> nullDefault) {
211211

212-
return doWithJedis(it -> {
212+
return doWithJedis(jedis -> {
213213

214214
if (isQueueing()) {
215215

@@ -225,7 +225,7 @@ private Object doInvoke(boolean status, Function<Jedis, Object> directFunction,
225225
return null;
226226
}
227227

228-
Object result = directFunction.apply(getJedis());
228+
Object result = directFunction.apply(jedis);
229229

230230
if (result == null) {
231231
return nullDefault.get();
@@ -378,7 +378,7 @@ public void openPipeline() {
378378
}
379379

380380
if (pipeline == null) {
381-
pipeline = jedis.pipelined();
381+
pipeline = getJedis().pipelined();
382382
}
383383
}
384384

@@ -411,7 +411,8 @@ private List<Object> convertPipelineResults() {
411411
Object data = result.get();
412412

413413
if (!result.isStatus()) {
414-
results.add(result.conversionRequired() ? result.convert(data) : data);
414+
Object resolvedData = result.conversionRequired() ? result.convert(data) : data;
415+
results.add(resolvedData);
415416
}
416417
} catch (JedisDataException e) {
417418
DataAccessException dataAccessException = convertJedisAccessException(e);
@@ -550,17 +551,20 @@ JedisInvoker invokeStatus() {
550551
}
551552

552553
<T> JedisResult<T, T> newJedisResult(Response<T> response) {
553-
return JedisResultBuilder.<T, T> forResponse(response).build();
554+
return JedisResultBuilder.<T, T>forResponse(response).build();
554555
}
555556

556557
<T, R> JedisResult<T, R> newJedisResult(Response<T> response, Converter<T, R> converter, Supplier<R> defaultValue) {
557558

558-
return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
559-
.convertPipelineAndTxResults(convertPipelineAndTxResults).mapNullTo(defaultValue).build();
559+
return JedisResultBuilder.<T, R>forResponse(response)
560+
.convertPipelineAndTxResults(this.convertPipelineAndTxResults)
561+
.mapNullTo(defaultValue)
562+
.mappedWith(converter)
563+
.build();
560564
}
561565

562566
<T> JedisStatusResult<T, T> newStatusResult(Response<T> response) {
563-
return JedisResultBuilder.<T, T> forResponse(response).buildStatusResult();
567+
return JedisResultBuilder.<T, T>forResponse(response).buildStatusResult();
564568
}
565569

566570
@Override

src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <R> R just(ConnectionFunction0<R> function) {
8282

8383
Assert.notNull(function, "ConnectionFunction must not be null");
8484

85-
return synchronizer.invoke(function::apply, it -> {
85+
return synchronizer.invoke(function::apply, responseCommands -> {
8686
throw new InvalidDataAccessApiUsageException("Operation not supported by Jedis in pipelining/transaction mode");
8787
}, Converters.identityConverter(), () -> null);
8888
}
@@ -115,7 +115,8 @@ <R, T1> R just(ConnectionFunction1<T1, R> function, PipelineFunction1<T1, R> pip
115115
Assert.notNull(function, "ConnectionFunction must not be null");
116116
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
117117

118-
return synchronizer.invoke(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
118+
return synchronizer.invoke(jedis -> function.apply(jedis, t1),
119+
responseCommands -> pipelineFunction.apply(responseCommands, t1));
119120
}
120121

121122
/**
@@ -133,7 +134,8 @@ <R, T1, T2> R just(ConnectionFunction2<T1, T2, R> function, PipelineFunction2<T1
133134
Assert.notNull(function, "ConnectionFunction must not be null");
134135
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
135136

136-
return synchronizer.invoke(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
137+
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2),
138+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
137139
}
138140

139141
/**
@@ -152,7 +154,8 @@ <R, T1, T2, T3> R just(ConnectionFunction3<T1, T2, T3, R> function, PipelineFunc
152154
Assert.notNull(function, "ConnectionFunction must not be null");
153155
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
154156

155-
return synchronizer.invoke(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
157+
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3),
158+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
156159
}
157160

158161
/**
@@ -172,7 +175,7 @@ <R, T1, T2, T3, T4> R just(ConnectionFunction4<T1, T2, T3, T4, R> function,
172175
Assert.notNull(function, "ConnectionFunction must not be null");
173176
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
174177

175-
return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4),
178+
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4),
176179
it -> pipelineFunction.apply(it, t1, t2, t3, t4));
177180
}
178181

@@ -194,7 +197,7 @@ <R, T1, T2, T3, T4, T5> R just(ConnectionFunction5<T1, T2, T3, T4, T5, R> functi
194197
Assert.notNull(function, "ConnectionFunction must not be null");
195198
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
196199

197-
return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4, t5),
200+
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
198201
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
199202
}
200203

@@ -217,8 +220,8 @@ <R, T1, T2, T3, T4, T5, T6> R just(ConnectionFunction6<T1, T2, T3, T4, T5, T6, R
217220
Assert.notNull(function, "ConnectionFunction must not be null");
218221
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
219222

220-
return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
221-
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
223+
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
224+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
222225
}
223226

224227
/**
@@ -265,7 +268,7 @@ <R, T1> SingleInvocationSpec<R> from(ConnectionFunction1<T1, R> function, Pipeli
265268
Assert.notNull(function, "ConnectionFunction must not be null");
266269
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
267270

268-
return from(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
271+
return from(jedis -> function.apply(jedis, t1), responseCommands -> pipelineFunction.apply(responseCommands, t1));
269272
}
270273

271274
/**
@@ -283,7 +286,8 @@ <R, T1, T2> SingleInvocationSpec<R> from(ConnectionFunction2<T1, T2, R> function
283286
Assert.notNull(function, "ConnectionFunction must not be null");
284287
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
285288

286-
return from(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
289+
return from(jedis -> function.apply(jedis, t1, t2),
290+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
287291
}
288292

289293
/**
@@ -302,7 +306,8 @@ <R, T1, T2, T3> SingleInvocationSpec<R> from(ConnectionFunction3<T1, T2, T3, R>
302306
Assert.notNull(function, "ConnectionFunction must not be null");
303307
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
304308

305-
return from(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
309+
return from(jedis -> function.apply(jedis, t1, t2, t3),
310+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
306311
}
307312

308313
/**
@@ -322,7 +327,8 @@ <R, T1, T2, T3, T4> SingleInvocationSpec<R> from(ConnectionFunction4<T1, T2, T3,
322327
Assert.notNull(function, "ConnectionFunction must not be null");
323328
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
324329

325-
return from(it -> function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4));
330+
return from(jedis -> function.apply(jedis, t1, t2, t3, t4),
331+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4));
326332
}
327333

328334
/**
@@ -343,7 +349,8 @@ <R, T1, T2, T3, T4, T5> SingleInvocationSpec<R> from(ConnectionFunction5<T1, T2,
343349
Assert.notNull(function, "ConnectionFunction must not be null");
344350
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
345351

346-
return from(it -> function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
352+
return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
353+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5));
347354
}
348355

349356
/**
@@ -365,8 +372,8 @@ <R, T1, T2, T3, T4, T5, T6> SingleInvocationSpec<R> from(ConnectionFunction6<T1,
365372
Assert.notNull(function, "ConnectionFunction must not be null");
366373
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
367374

368-
return from(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
369-
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
375+
return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
376+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
370377
}
371378

372379
/**
@@ -414,7 +421,8 @@ <R extends Collection<E>, E, T1> ManyInvocationSpec<E> fromMany(ConnectionFuncti
414421
Assert.notNull(function, "ConnectionFunction must not be null");
415422
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
416423

417-
return fromMany(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
424+
return fromMany(jedis -> function.apply(jedis, t1),
425+
responseCommands -> pipelineFunction.apply(responseCommands, t1));
418426
}
419427

420428
/**
@@ -432,7 +440,8 @@ <R extends Collection<E>, E, T1, T2> ManyInvocationSpec<E> fromMany(ConnectionFu
432440
Assert.notNull(function, "ConnectionFunction must not be null");
433441
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
434442

435-
return fromMany(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
443+
return fromMany(jedis -> function.apply(jedis, t1, t2),
444+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
436445
}
437446

438447
/**
@@ -451,7 +460,8 @@ <R extends Collection<E>, E, T1, T2, T3> ManyInvocationSpec<E> fromMany(Connecti
451460
Assert.notNull(function, "ConnectionFunction must not be null");
452461
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
453462

454-
return fromMany(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
463+
return fromMany(jedis -> function.apply(jedis, t1, t2, t3),
464+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
455465
}
456466

457467
/**
@@ -472,7 +482,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4> ManyInvocationSpec<E> fromMany(
472482
Assert.notNull(function, "ConnectionFunction must not be null");
473483
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
474484

475-
return fromMany(it -> function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4));
485+
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4),
486+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4));
476487
}
477488

478489
/**
@@ -494,7 +505,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4, T5> ManyInvocationSpec<E> fromMany(
494505
Assert.notNull(function, "ConnectionFunction must not be null");
495506
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
496507

497-
return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
508+
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
509+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5));
498510
}
499511

500512
/**
@@ -517,8 +529,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4, T5, T6> ManyInvocationSpec<E> fromM
517529
Assert.notNull(function, "ConnectionFunction must not be null");
518530
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");
519531

520-
return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
521-
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
532+
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
533+
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
522534
}
523535

524536
/**

0 commit comments

Comments
 (0)