Polish "Use diamond operator where feasible"
See gh-31916
This commit is contained in:
parent
094479b55f
commit
a6e87b40c7
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class AsyncResultTests {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
values.add(result);
|
values.add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
throw new AssertionError("Failure callback not expected: " + ex, ex);
|
throw new AssertionError("Failure callback not expected: " + ex, ex);
|
||||||
|
|
@ -65,7 +64,6 @@ public class AsyncResultTests {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
throw new AssertionError("Success callback not expected: " + result);
|
throw new AssertionError("Success callback not expected: " + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
values.add(ex);
|
values.add(ex);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -152,7 +152,7 @@ public class SpelExceptionTests {
|
||||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
||||||
ctx.setVariables(new HashMap<>() {
|
ctx.setVariables(new HashMap<>() {
|
||||||
{
|
{
|
||||||
put("anArray", new int[]{1, 2, 3});
|
put("anArray", new int[] {1,2,3});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
boolean result = spelExpression.getValue(ctx, Boolean.class);
|
boolean result = spelExpression.getValue(ctx, Boolean.class);
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,6 @@ class DefaultMessageListenerContainerTests {
|
||||||
ConnectionFactory connectionFactory = mock();
|
ConnectionFactory connectionFactory = mock();
|
||||||
given(connectionFactory.createConnection()).will(new Answer<>() {
|
given(connectionFactory.createConnection()).will(new Answer<>() {
|
||||||
int currentAttempts = 0;
|
int currentAttempts = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||||
currentAttempts++;
|
currentAttempts++;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -56,8 +56,7 @@ public class MultipartBodyBuilderTests {
|
||||||
|
|
||||||
Publisher<String> publisher = Flux.just("foo", "bar", "baz");
|
Publisher<String> publisher = Flux.just("foo", "bar", "baz");
|
||||||
builder.asyncPart("publisherClass", publisher, String.class).header("baz", "qux");
|
builder.asyncPart("publisherClass", publisher, String.class).header("baz", "qux");
|
||||||
builder.asyncPart("publisherPtr", publisher, new ParameterizedTypeReference<>() {
|
builder.asyncPart("publisherPtr", publisher, new ParameterizedTypeReference<>() {}).header("baz", "qux");
|
||||||
}).header("baz", "qux");
|
|
||||||
|
|
||||||
MultiValueMap<String, HttpEntity<?>> result = builder.build();
|
MultiValueMap<String, HttpEntity<?>> result = builder.build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,8 +169,7 @@ class ChannelSendOperatorTests {
|
||||||
return Mono.never();
|
return Mono.never();
|
||||||
});
|
});
|
||||||
|
|
||||||
operator.subscribe(new BaseSubscriber<>() {
|
operator.subscribe(new BaseSubscriber<>() {});
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
writeSubscriber.signalDemand(1); // Let cached signals ("foo" and error) be published..
|
writeSubscriber.signalDemand(1); // Let cached signals ("foo" and error) be published..
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,8 +166,7 @@ class RestClientIntegrationTests {
|
||||||
ValueContainer<Pojo> result = this.restClient.get()
|
ValueContainer<Pojo> result = this.restClient.get()
|
||||||
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.body(new ParameterizedTypeReference<>() {
|
.body(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
assertThat(result.getContainerValue()).isNotNull();
|
assertThat(result.getContainerValue()).isNotNull();
|
||||||
Pojo pojo = result.getContainerValue();
|
Pojo pojo = result.getContainerValue();
|
||||||
|
|
@ -192,8 +191,7 @@ class RestClientIntegrationTests {
|
||||||
ValueContainer<List<Pojo>> result = this.restClient.get()
|
ValueContainer<List<Pojo>> result = this.restClient.get()
|
||||||
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.body(new ParameterizedTypeReference<>() {
|
.body(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
assertThat(result.containerValue).isNotNull();
|
assertThat(result.containerValue).isNotNull();
|
||||||
assertThat(result.containerValue).containsExactly(new Pojo("foofoo", "barbar"));
|
assertThat(result.containerValue).containsExactly(new Pojo("foofoo", "barbar"));
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,7 @@ class BodyExtractorsTests {
|
||||||
@Test
|
@Test
|
||||||
void toMonoParameterizedTypeReference() {
|
void toMonoParameterizedTypeReference() {
|
||||||
BodyExtractor<Mono<Map<String, String>>, ReactiveHttpInputMessage> extractor =
|
BodyExtractor<Mono<Map<String, String>>, ReactiveHttpInputMessage> extractor =
|
||||||
BodyExtractors.toMono(new ParameterizedTypeReference<>() {
|
BodyExtractors.toMono(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
byte[] bytes = "{\"username\":\"foo\",\"password\":\"bar\"}".getBytes(StandardCharsets.UTF_8);
|
byte[] bytes = "{\"username\":\"foo\",\"password\":\"bar\"}".getBytes(StandardCharsets.UTF_8);
|
||||||
DefaultDataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(ByteBuffer.wrap(bytes));
|
DefaultDataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(ByteBuffer.wrap(bytes));
|
||||||
|
|
@ -184,8 +183,7 @@ class BodyExtractorsTests {
|
||||||
@Test // SPR-15758
|
@Test // SPR-15758
|
||||||
void toMonoWithEmptyBodyAndNoContentType() {
|
void toMonoWithEmptyBodyAndNoContentType() {
|
||||||
BodyExtractor<Mono<Map<String, String>>, ReactiveHttpInputMessage> extractor =
|
BodyExtractor<Mono<Map<String, String>>, ReactiveHttpInputMessage> extractor =
|
||||||
BodyExtractors.toMono(new ParameterizedTypeReference<>() {
|
BodyExtractors.toMono(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Flux.empty());
|
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Flux.empty());
|
||||||
Mono<Map<String, String>> result = extractor.extract(request, this.context);
|
Mono<Map<String, String>> result = extractor.extract(request, this.context);
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
Mono<Map<String, String>> mono = this.webClient.get()
|
Mono<Map<String, String>> mono = this.webClient.get()
|
||||||
.uri("/sample").accept(MediaType.APPLICATION_JSON)
|
.uri("/sample").accept(MediaType.APPLICATION_JSON)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(new ParameterizedTypeReference<>() {
|
.bodyToMono(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
StepVerifier.create(mono).expectError(WebClientResponseException.class).verify(Duration.ofSeconds(3));
|
StepVerifier.create(mono).expectError(WebClientResponseException.class).verify(Duration.ofSeconds(3));
|
||||||
assertThat(this.server.getRequestCount()).isEqualTo(1);
|
assertThat(this.server.getRequestCount()).isEqualTo(1);
|
||||||
|
|
|
||||||
|
|
@ -197,8 +197,7 @@ class WebClientIntegrationTests {
|
||||||
Mono<ValueContainer<Pojo>> result = this.webClient.get()
|
Mono<ValueContainer<Pojo>> result = this.webClient.get()
|
||||||
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
.uri("/json").accept(MediaType.APPLICATION_JSON)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(new ParameterizedTypeReference<>() {
|
.bodyToMono(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
StepVerifier.create(result)
|
StepVerifier.create(result)
|
||||||
.assertNext(c -> assertThat(c.getContainerValue()).isEqualTo(new Pojo("foofoo", "barbar")))
|
.assertNext(c -> assertThat(c.getContainerValue()).isEqualTo(new Pojo("foofoo", "barbar")))
|
||||||
|
|
@ -805,8 +804,7 @@ class WebClientIntegrationTests {
|
||||||
.uri("/greeting")
|
.uri("/greeting")
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.onStatus(HttpStatusCode::is5xxServerError, response -> Mono.just(new MyException("500 error!")))
|
.onStatus(HttpStatusCode::is5xxServerError, response -> Mono.just(new MyException("500 error!")))
|
||||||
.bodyToMono(new ParameterizedTypeReference<>() {
|
.bodyToMono(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
StepVerifier.create(result)
|
StepVerifier.create(result)
|
||||||
.expectError(MyException.class)
|
.expectError(MyException.class)
|
||||||
|
|
|
||||||
|
|
@ -318,8 +318,7 @@ public class DefaultServerRequestTests {
|
||||||
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), messageReaders);
|
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), messageReaders);
|
||||||
|
|
||||||
Mono<Map<String, String>> resultMono = request.bodyToMono(
|
Mono<Map<String, String>> resultMono = request.bodyToMono(
|
||||||
new ParameterizedTypeReference<>() {
|
new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
StepVerifier.create(resultMono)
|
StepVerifier.create(resultMono)
|
||||||
.expectError(ServerWebInputException.class)
|
.expectError(ServerWebInputException.class)
|
||||||
.verify();
|
.verify();
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,7 @@ class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrati
|
||||||
.uri("/event")
|
.uri("/event")
|
||||||
.accept(TEXT_EVENT_STREAM)
|
.accept(TEXT_EVENT_STREAM)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToFlux(new ParameterizedTypeReference<>() {
|
.bodyToFlux(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
StepVerifier.create(result)
|
StepVerifier.create(result)
|
||||||
.consumeNextWith( event -> {
|
.consumeNextWith( event -> {
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
.uri("/event")
|
.uri("/event")
|
||||||
.accept(TEXT_EVENT_STREAM)
|
.accept(TEXT_EVENT_STREAM)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToFlux(new ParameterizedTypeReference<>() {
|
.bodyToFlux(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
verifyPersonEvents(result);
|
verifyPersonEvents(result);
|
||||||
}
|
}
|
||||||
|
|
@ -148,8 +147,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
.uri("/event")
|
.uri("/event")
|
||||||
.accept(TEXT_EVENT_STREAM)
|
.accept(TEXT_EVENT_STREAM)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToFlux(new ParameterizedTypeReference<>() {
|
.bodyToFlux(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
verifyPersonEvents(result);
|
verifyPersonEvents(result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ class DefaultEntityResponseBuilderTests {
|
||||||
void fromObjectTypeReference() {
|
void fromObjectTypeReference() {
|
||||||
String body = "foo";
|
String body = "foo";
|
||||||
EntityResponse<String> response = EntityResponse.fromObject(body,
|
EntityResponse<String> response = EntityResponse.fromObject(body,
|
||||||
new ParameterizedTypeReference<>() {
|
new ParameterizedTypeReference<>() {})
|
||||||
})
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertThat(response.entity()).isSameAs(body);
|
assertThat(response.entity()).isSameAs(body);
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,7 @@ class DefaultServerRequestTests {
|
||||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest,
|
DefaultServerRequest request = new DefaultServerRequest(servletRequest,
|
||||||
List.of(new MappingJackson2HttpMessageConverter()));
|
List.of(new MappingJackson2HttpMessageConverter()));
|
||||||
|
|
||||||
List<String> result = request.body(new ParameterizedTypeReference<>() {
|
List<String> result = request.body(new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
assertThat(result).hasSize(2);
|
assertThat(result).hasSize(2);
|
||||||
assertThat(result).element(0).isEqualTo("foo");
|
assertThat(result).element(0).isEqualTo("foo");
|
||||||
assertThat(result).element(1).isEqualTo("bar");
|
assertThat(result).element(1).isEqualTo("bar");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -293,8 +293,7 @@ class DefaultServerResponseBuilderTests {
|
||||||
List<String> body = new ArrayList<>();
|
List<String> body = new ArrayList<>();
|
||||||
body.add("foo");
|
body.add("foo");
|
||||||
body.add("bar");
|
body.add("bar");
|
||||||
ServerResponse response = ServerResponse.ok().body(body, new ParameterizedTypeReference<>() {
|
ServerResponse response = ServerResponse.ok().body(body, new ParameterizedTypeReference<>() {});
|
||||||
});
|
|
||||||
|
|
||||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", "https://example.com");
|
MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", "https://example.com");
|
||||||
MockHttpServletResponse mockResponse = new MockHttpServletResponse();
|
MockHttpServletResponse mockResponse = new MockHttpServletResponse();
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,6 @@ class RestTemplateXhrTransportTests {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WebSocketSession result) {
|
public void onSuccess(WebSocketSession result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
if (ex == expected) {
|
if (ex == expected) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue