Avoid ConstantConditions warnings suppression (plus related polishing)
Issue: SPR-15756
This commit is contained in:
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.codec.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -79,7 +81,7 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo
|
||||
|
||||
@Nullable
|
||||
private Decoder<?> getSseDecoder() {
|
||||
return this.sseDecoder != null ? this.sseDecoder : jackson2Present ? getJackson2JsonDecoder() : null;
|
||||
return (this.sseDecoder != null ? this.sseDecoder : jackson2Present ? getJackson2JsonDecoder() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,10 +89,16 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo
|
||||
typedWriters.add(new MultipartHttpMessageWriter(getPartWriters(), new FormHttpMessageWriter()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private List<HttpMessageWriter<?>> getPartWriters() {
|
||||
return this.multipartCodecs != null ?
|
||||
this.multipartCodecs.getWriters() : this.partWritersSupplier.get();
|
||||
if (this.multipartCodecs != null) {
|
||||
return this.multipartCodecs.getWriters();
|
||||
}
|
||||
else if (this.partWritersSupplier != null) {
|
||||
return this.partWritersSupplier.get();
|
||||
}
|
||||
else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +109,6 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo
|
||||
|
||||
private final List<HttpMessageWriter<?>> writers = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public ClientCodecConfigurer.MultipartCodecs encoder(Encoder<?> encoder) {
|
||||
writer(new EncoderHttpMessageWriter<>(encoder));
|
||||
|
||||
@@ -26,13 +26,11 @@ import org.springframework.http.codec.ClientCodecConfigurer;
|
||||
*/
|
||||
public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements ClientCodecConfigurer {
|
||||
|
||||
|
||||
public DefaultClientCodecConfigurer() {
|
||||
super(new ClientDefaultCodecsImpl());
|
||||
((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClientDefaultCodecs defaultCodecs() {
|
||||
return (ClientDefaultCodecs) super.defaultCodecs();
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
*/
|
||||
public class DefaultServerCodecConfigurer extends BaseCodecConfigurer implements ServerCodecConfigurer {
|
||||
|
||||
|
||||
public DefaultServerCodecConfigurer() {
|
||||
super(new ServerDefaultCodecsImpl());
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web.test.server;
|
||||
|
||||
import java.time.Clock;
|
||||
@@ -22,6 +23,8 @@ import java.util.Map;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.server.WebSession;
|
||||
import org.springframework.web.server.session.InMemoryWebSessionStore;
|
||||
|
||||
@@ -46,13 +49,14 @@ public class MockWebSession implements WebSession {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public MockWebSession(Clock clock) {
|
||||
public MockWebSession(@Nullable Clock clock) {
|
||||
InMemoryWebSessionStore sessionStore = new InMemoryWebSessionStore();
|
||||
if (clock != null) {
|
||||
sessionStore.setClock(clock);
|
||||
}
|
||||
this.delegate = sessionStore.createWebSession().block();
|
||||
WebSession session = sessionStore.createWebSession().block();
|
||||
Assert.state(session != null, "WebSession must not be null");
|
||||
this.delegate = session;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user