From dedbbf0a7908c33a27e717ff3ffbc46848ff9b02 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 8 Nov 2022 12:04:56 +0100 Subject: [PATCH 1/2] Avoid warnings in tests --- .../org/springframework/context/annotation/Gh29105Tests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java index e954f5e989f..f4955d7df49 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Stephane Nicoll */ -public class Gh29105Tests { +class Gh29105Tests { @Test void beanProviderWithParentContextReuseOrder() { @@ -47,6 +47,7 @@ public class Gh29105Tests { List> orderedTypes = child.getBeanProvider(MyService.class) .orderedStream().map(Object::getClass).collect(Collectors.toList()); assertThat(orderedTypes).containsExactly(CustomService.class, DefaultService.class); + child.close(); } @@ -78,4 +79,5 @@ public class Gh29105Tests { } } + } From e5878ab15b46079e29043426d38ac7f1543ca377 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 8 Nov 2022 12:08:08 +0100 Subject: [PATCH 2/2] Fix precondition assertions --- .../transaction/reactive/TransactionalOperatorImpl.java | 4 ++-- .../java/org/springframework/http/ContentDisposition.java | 5 +++-- .../http/server/reactive/UndertowServerHttpResponse.java | 2 +- .../web/servlet/handler/RequestMatchResult.java | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionalOperatorImpl.java b/spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionalOperatorImpl.java index ece11c5ec1f..9a1c8a6b4be 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionalOperatorImpl.java +++ b/spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionalOperatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ final class TransactionalOperatorImpl implements TransactionalOperator { */ TransactionalOperatorImpl(ReactiveTransactionManager transactionManager, TransactionDefinition transactionDefinition) { Assert.notNull(transactionManager, "ReactiveTransactionManager must not be null"); - Assert.notNull(transactionManager, "TransactionDefinition must not be null"); + Assert.notNull(transactionDefinition, "TransactionDefinition must not be null"); this.transactionManager = transactionManager; this.transactionDefinition = transactionDefinition; } diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index f9c3a97eff4..119d0a29f2e 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -465,8 +465,9 @@ public final class ContentDisposition { * @see RFC 5987 */ private static String decodeFilename(String filename, Charset charset) { - Assert.notNull(filename, "'input' String should not be null"); - Assert.notNull(charset, "'charset' should not be null"); + Assert.notNull(filename, "'filename' must not be null"); + Assert.notNull(charset, "'charset' must not be null"); + byte[] value = filename.getBytes(charset); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int index = 0; diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java index 95526d20d97..8394a47d03d 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java @@ -63,12 +63,12 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl HttpServerExchange exchange, DataBufferFactory bufferFactory, UndertowServerHttpRequest request) { super(bufferFactory, createHeaders(exchange)); - Assert.notNull(exchange, "HttpServerExchange must not be null"); this.exchange = exchange; this.request = request; } private static HttpHeaders createHeaders(HttpServerExchange exchange) { + Assert.notNull(exchange, "HttpServerExchange must not be null"); UndertowHeadersAdapter headersMap = new UndertowHeadersAdapter(exchange.getResponseHeaders()); return new HttpHeaders(headersMap); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java index d5f4b09e8df..da02aa2b9df 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class RequestMatchResult { */ public RequestMatchResult(PathPattern pathPattern, PathContainer lookupPath) { Assert.notNull(pathPattern, "PathPattern is required"); - Assert.notNull(pathPattern, "PathContainer is required"); + Assert.notNull(lookupPath, "PathContainer is required"); this.pattern = null; this.lookupPath = null;