See gh-31948
pull/27373/merge
Johnny Lim 2 years ago committed by Stephane Nicoll
parent c05d0c51b7
commit 6a4681baf5

@ -41,7 +41,7 @@ import org.springframework.util.unit.DataSize;
*/
abstract class HttpSender extends Sender {
private static final DataSize MESSAGE_MAX_BYTES = DataSize.ofKilobytes(512);
private static final DataSize MESSAGE_MAX_SIZE = DataSize.ofKilobytes(512);
private volatile boolean closed;
@ -52,7 +52,7 @@ abstract class HttpSender extends Sender {
@Override
public int messageMaxBytes() {
return (int) MESSAGE_MAX_BYTES.toBytes();
return (int) MESSAGE_MAX_SIZE.toBytes();
}
@Override

@ -69,7 +69,7 @@ class ZipkinWebClientSender extends HttpSender {
@Override
protected void doEnqueue(Callback<Void> callback) {
sendRequest().subscribe((__) -> callback.onSuccess(null), callback::onError);
sendRequest().subscribe((entity) -> callback.onSuccess(null), callback::onError);
}
private Mono<ResponseEntity<Void>> sendRequest() {

@ -58,11 +58,11 @@ abstract class ZipkinHttpSenderTests {
protected void makeRequest(List<byte[]> encodedSpans, boolean async) throws IOException {
if (async) {
CallbackResult callbackResult = this.makeAsyncRequest(encodedSpans);
CallbackResult callbackResult = makeAsyncRequest(encodedSpans);
assertThat(callbackResult.success()).isTrue();
}
else {
this.makeSyncRequest(encodedSpans);
makeSyncRequest(encodedSpans);
}
}

@ -86,7 +86,7 @@ class ZipkinRestTemplateSenderTests extends ZipkinHttpSenderTests {
this.mockServer.expect(requestTo(ZIPKIN_URL)).andExpect(method(HttpMethod.POST))
.andExpect(content().contentType("application/json")).andExpect(content().string("[span1,span2]"))
.andRespond(withStatus(HttpStatus.ACCEPTED));
this.makeRequest(List.of(toByteArray("span1"), toByteArray("span2")), async);
makeRequest(List.of(toByteArray("span1"), toByteArray("span2")), async);
}
@ParameterizedTest
@ -95,12 +95,12 @@ class ZipkinRestTemplateSenderTests extends ZipkinHttpSenderTests {
this.mockServer.expect(requestTo(ZIPKIN_URL)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
if (async) {
CallbackResult callbackResult = this.makeAsyncRequest(List.of());
CallbackResult callbackResult = makeAsyncRequest(List.of());
assertThat(callbackResult.success()).isFalse();
assertThat(callbackResult.error()).isNotNull().hasMessageContaining("500 Internal Server Error");
}
else {
assertThatThrownBy(() -> this.makeSyncRequest(List.of())).hasMessageContaining("500 Internal Server Error");
assertThatThrownBy(() -> makeSyncRequest(List.of())).hasMessageContaining("500 Internal Server Error");
}
}
@ -114,7 +114,7 @@ class ZipkinRestTemplateSenderTests extends ZipkinHttpSenderTests {
this.mockServer.expect(requestTo(ZIPKIN_URL)).andExpect(method(HttpMethod.POST))
.andExpect(header("Content-Encoding", "gzip")).andExpect(content().contentType("application/json"))
.andExpect(content().bytes(compressed)).andRespond(withStatus(HttpStatus.ACCEPTED));
this.makeRequest(List.of(toByteArray(uncompressed)), async);
makeRequest(List.of(toByteArray(uncompressed)), async);
}
}

@ -46,7 +46,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
private static MockWebServer mockBackEnd;
public static String ZIPKIN_URL;
private static String ZIPKIN_URL;
@BeforeAll
static void beforeAll() throws IOException {
@ -92,7 +92,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
void sendSpansShouldSendSpansToZipkin(boolean async) throws IOException, InterruptedException {
mockBackEnd.enqueue(new MockResponse());
List<byte[]> encodedSpans = List.of(toByteArray("span1"), toByteArray("span2"));
this.makeRequest(encodedSpans, async);
makeRequest(encodedSpans, async);
requestAssertions((request) -> {
assertThat(request.getMethod()).isEqualTo("POST");
@ -106,12 +106,12 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
void sendSpansShouldHandleHttpFailures(boolean async) throws InterruptedException {
mockBackEnd.enqueue(new MockResponse().setResponseCode(500));
if (async) {
CallbackResult callbackResult = this.makeAsyncRequest(List.of());
CallbackResult callbackResult = makeAsyncRequest(List.of());
assertThat(callbackResult.success()).isFalse();
assertThat(callbackResult.error()).isNotNull().hasMessageContaining("500 Internal Server Error");
}
else {
assertThatThrownBy(() -> this.makeSyncRequest(List.of())).hasMessageContaining("500 Internal Server Error");
assertThatThrownBy(() -> makeSyncRequest(List.of())).hasMessageContaining("500 Internal Server Error");
}
requestAssertions((request) -> assertThat(request.getMethod()).isEqualTo("POST"));
@ -127,7 +127,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
mockBackEnd.enqueue(new MockResponse());
this.makeRequest(List.of(toByteArray(uncompressed)), async);
makeRequest(List.of(toByteArray(uncompressed)), async);
requestAssertions((request) -> {
assertThat(request.getMethod()).isEqualTo("POST");

@ -315,7 +315,6 @@ class WebMvcMetricsFilterTests {
@Test
void trailingSlashShouldNotRecordDuplicateMetrics() throws Exception {
this.mvc.perform(get("/api/c1/simple/10")).andExpect(status().isOk());
this.mvc.perform(get("/api/c1/simple/10/")).andExpect(status().isOk());
assertThat(this.registry.get("http.server.requests").tags("status", "200", "uri", "/api/c1/simple/{id}").timer()

@ -56,7 +56,7 @@ class WebResourcesRuntimeHintsTests {
assertThat(hints.resources().resourcePatterns()).isEmpty();
}
RuntimeHints register(ClassLoader classLoader) {
private RuntimeHints register(ClassLoader classLoader) {
RuntimeHints hints = new RuntimeHints();
WebResourcesRuntimeHints registrar = new WebResourcesRuntimeHints();
registrar.registerHints(hints, classLoader);

@ -86,7 +86,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
private JarEntryCertification[] certifications;
private final Map<Integer, FileHeader> entriesCache = Collections
.synchronizedMap(new LinkedHashMap<Integer, FileHeader>(16, 0.75f, true) {
.synchronizedMap(new LinkedHashMap<>(16, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Integer, FileHeader> eldest) {
@ -338,7 +338,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
// We fall back to use JarInputStream to obtain the certs. This isn't that
// fast, but hopefully doesn't happen too often.
try (JarInputStream certifiedJarStream = new JarInputStream(this.jarFile.getData().getInputStream())) {
java.util.jar.JarEntry certifiedEntry = null;
java.util.jar.JarEntry certifiedEntry;
while ((certifiedEntry = certifiedJarStream.getNextJarEntry()) != null) {
// Entry must be closed to trigger a read and set entry certificates
certifiedJarStream.closeEntry();

@ -33,8 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author HaiTao Zhang
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "management.endpoints.web.base-path=/", "management.server.port=0",
"logging.level.org.springframework.web=trace" })
properties = { "management.endpoints.web.base-path=/", "management.server.port=0" })
class ManagementDifferentPortSampleActuatorApplicationTests {
@LocalManagementPort

Loading…
Cancel
Save