Avoid String allocations with Assert.isTrue()
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -54,7 +54,7 @@ public class RedirectViewControllerRegistration {
|
||||
* will select {@code HttpStatus.MOVED_TEMPORARILY (302)} by default.
|
||||
*/
|
||||
public RedirectViewControllerRegistration setStatusCode(HttpStatus statusCode) {
|
||||
Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code");
|
||||
Assert.isTrue(statusCode.is3xxRedirection(), () -> "Not a redirect status code: " + statusCode);
|
||||
this.redirectView.setStatusCode(statusCode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -133,8 +133,8 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
||||
|
||||
private void assertNumberOfConditions(CompositeRequestCondition other) {
|
||||
Assert.isTrue(getLength() == other.getLength(),
|
||||
"Cannot combine CompositeRequestConditions with a different number of conditions. " +
|
||||
ObjectUtils.nullSafeToString(this.requestConditions) + " and " +
|
||||
() -> "Cannot combine CompositeRequestConditions with a different number of conditions. " +
|
||||
ObjectUtils.nullSafeToString(this.requestConditions) + " and " +
|
||||
ObjectUtils.nullSafeToString(other.requestConditions));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user