Polishing

This commit is contained in:
Sam Brannen 2023-03-10 17:51:20 +01:00
parent 3431b2330a
commit 9cf7b0e230
8 changed files with 25 additions and 25 deletions

View File

@ -46,7 +46,7 @@ public class ObjectError extends DefaultMessageSourceResolvable {
* @param objectName the name of the affected object * @param objectName the name of the affected object
* @param defaultMessage the default message to be used to resolve this message * @param defaultMessage the default message to be used to resolve this message
*/ */
public ObjectError(String objectName, String defaultMessage) { public ObjectError(String objectName, @Nullable String defaultMessage) {
this(objectName, null, null, defaultMessage); this(objectName, null, null, defaultMessage);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 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.

View File

@ -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.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 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.

View File

@ -335,8 +335,8 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol
return BeanUtils.instantiateClass(ctor, args); return BeanUtils.instantiateClass(ctor, args);
} }
catch (BeanInstantiationException ex) { catch (BeanInstantiationException ex) {
Throwable cause = ex.getCause(); if (KotlinDetector.isKotlinType(ctor.getDeclaringClass()) &&
if (KotlinDetector.isKotlinType(ctor.getDeclaringClass()) && cause instanceof NullPointerException) { ex.getCause() instanceof NullPointerException cause) {
BindingResult result = binder.getBindingResult(); BindingResult result = binder.getBindingResult();
ObjectError error = new ObjectError(ctor.getName(), cause.getMessage()); ObjectError error = new ObjectError(ctor.getName(), cause.getMessage());
result.addError(error); result.addError(error);

View File

@ -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.
@ -122,7 +122,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder header(String headerName, String... headerValues) { public ServerRequest.Builder header(String headerName, String... headerValues) {
Assert.notNull(headerName, "Header Name must not be null"); Assert.notNull(headerName, "Header name must not be null");
for (String headerValue : headerValues) { for (String headerValue : headerValues) {
this.headers.add(headerName, headerValue); this.headers.add(headerName, headerValue);
} }
@ -131,14 +131,14 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder headers(Consumer<HttpHeaders> headersConsumer) { public ServerRequest.Builder headers(Consumer<HttpHeaders> headersConsumer) {
Assert.notNull(headersConsumer, "Header Consumer must not be null"); Assert.notNull(headersConsumer, "Headers consumer must not be null");
headersConsumer.accept(this.headers); headersConsumer.accept(this.headers);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder cookie(String name, String... values) { public ServerRequest.Builder cookie(String name, String... values) {
Assert.notNull(name, "Cookie Name must not be null"); Assert.notNull(name, "Cookie name must not be null");
for (String value : values) { for (String value : values) {
this.cookies.add(name, new HttpCookie(name, value)); this.cookies.add(name, new HttpCookie(name, value));
} }
@ -147,7 +147,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder cookies(Consumer<MultiValueMap<String, HttpCookie>> cookiesConsumer) { public ServerRequest.Builder cookies(Consumer<MultiValueMap<String, HttpCookie>> cookiesConsumer) {
Assert.notNull(cookiesConsumer, "Cookie Consumer must not be null"); Assert.notNull(cookiesConsumer, "Cookies consumer must not be null");
cookiesConsumer.accept(this.cookies); cookiesConsumer.accept(this.cookies);
return this; return this;
} }
@ -178,14 +178,14 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder attribute(String name, Object value) { public ServerRequest.Builder attribute(String name, Object value) {
Assert.notNull(name, "name must not be null"); Assert.notNull(name, "Name must not be null");
this.attributes.put(name, value); this.attributes.put(name, value);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer) { public ServerRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer) {
Assert.notNull(attributesConsumer, "AttributesConsumer must not be null"); Assert.notNull(attributesConsumer, "Attributes consumer must not be null");
attributesConsumer.accept(this.attributes); attributesConsumer.accept(this.attributes);
return this; return this;
} }

View File

@ -115,7 +115,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder header(String headerName, String... headerValues) { public ServerRequest.Builder header(String headerName, String... headerValues) {
Assert.notNull(headerName, "Header Name must not be null"); Assert.notNull(headerName, "Header name must not be null");
for (String headerValue : headerValues) { for (String headerValue : headerValues) {
this.headers.add(headerName, headerValue); this.headers.add(headerName, headerValue);
} }
@ -124,14 +124,14 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder headers(Consumer<HttpHeaders> headersConsumer) { public ServerRequest.Builder headers(Consumer<HttpHeaders> headersConsumer) {
Assert.notNull(headersConsumer, "Header Consumer must not be null"); Assert.notNull(headersConsumer, "Headers consumer must not be null");
headersConsumer.accept(this.headers); headersConsumer.accept(this.headers);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder cookie(String name, String... values) { public ServerRequest.Builder cookie(String name, String... values) {
Assert.notNull(name, "Cookie Name must not be null"); Assert.notNull(name, "Cookie name must not be null");
for (String value : values) { for (String value : values) {
this.cookies.add(name, new Cookie(name, value)); this.cookies.add(name, new Cookie(name, value));
} }
@ -140,41 +140,41 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder cookies(Consumer<MultiValueMap<String, Cookie>> cookiesConsumer) { public ServerRequest.Builder cookies(Consumer<MultiValueMap<String, Cookie>> cookiesConsumer) {
Assert.notNull(cookiesConsumer, "Cookie Consumer must not be null"); Assert.notNull(cookiesConsumer, "Cookies consumer must not be null");
cookiesConsumer.accept(this.cookies); cookiesConsumer.accept(this.cookies);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder body(byte[] body) { public ServerRequest.Builder body(byte[] body) {
Assert.notNull(body, "body must not be null"); Assert.notNull(body, "Body must not be null");
this.body = body; this.body = body;
return this; return this;
} }
@Override @Override
public ServerRequest.Builder body(String body) { public ServerRequest.Builder body(String body) {
Assert.notNull(body, "body must not be null"); Assert.notNull(body, "Body must not be null");
return body(body.getBytes(StandardCharsets.UTF_8)); return body(body.getBytes(StandardCharsets.UTF_8));
} }
@Override @Override
public ServerRequest.Builder attribute(String name, Object value) { public ServerRequest.Builder attribute(String name, Object value) {
Assert.notNull(name, "name must not be null"); Assert.notNull(name, "Name must not be null");
this.attributes.put(name, value); this.attributes.put(name, value);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer) { public ServerRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer) {
Assert.notNull(attributesConsumer, "AttributesConsumer must not be null"); Assert.notNull(attributesConsumer, "Attributes consumer must not be null");
attributesConsumer.accept(this.attributes); attributesConsumer.accept(this.attributes);
return this; return this;
} }
@Override @Override
public ServerRequest.Builder param(String name, String... values) { public ServerRequest.Builder param(String name, String... values) {
Assert.notNull(name, "name must not be null"); Assert.notNull(name, "Name must not be null");
for (String value : values) { for (String value : values) {
this.params.add(name, value); this.params.add(name, value);
} }
@ -183,7 +183,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override @Override
public ServerRequest.Builder params(Consumer<MultiValueMap<String, String>> paramsConsumer) { public ServerRequest.Builder params(Consumer<MultiValueMap<String, String>> paramsConsumer) {
Assert.notNull(paramsConsumer, "paramsConsumer must not be null"); Assert.notNull(paramsConsumer, "Parameters consumer must not be null");
paramsConsumer.accept(this.params); paramsConsumer.accept(this.params);
return this; return this;
} }