Avoid String allocations with Assert.state()

This commit is contained in:
Sam Brannen 2022-11-04 15:51:32 +01:00
parent 6022065ad3
commit 34b1857236
2 changed files with 4 additions and 3 deletions

View File

@ -179,7 +179,7 @@ public final class AotServices<T> implements Iterable<T> {
public Source getSource(T service) {
Source source = this.sources.get(service);
Assert.state(source != null,
"Unable to find service " + ObjectUtils.identityToString(source));
() -> "Unable to find service " + ObjectUtils.identityToString(source));
return source;
}

View File

@ -40,11 +40,12 @@ public class RegisterReflectionForBindingProcessor implements ReflectiveProcesso
RegisterReflectionForBinding registerReflection = AnnotationUtils.getAnnotation(element, RegisterReflectionForBinding.class);
if (registerReflection != null) {
Class<?>[] classes = registerReflection.classes();
Assert.state(classes.length != 0, "A least one class should be specified in" +
" @RegisterReflectionForBinding attributes and none was provided on " + element);
Assert.state(classes.length != 0, () -> "A least one class should be specified in " +
"@RegisterReflectionForBinding attributes, and none was provided on " + element);
for (Class<?> type : classes) {
this.bindingRegistrar.registerReflectionHints(hints, type);
}
}
}
}