Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private String getPathId(Object source) {
private String getPathId(Class<?> source) {
Endpoint annotation = AnnotationUtils.findAnnotation(source, Endpoint.class);
Assert.state(annotation != null,
"Class " + source + " is not annotated with @Endpoint");
() -> "Class " + source + " is not annotated with @Endpoint");
return annotation.id();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private Map<Class<?>, EndpointExtensionInfo<T>> discoverExtensions(
AnnotationAttributes endpointAttributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(endpointType, Endpoint.class);
Assert.state(isExposedOver(endpointAttributes, exposure),
"Invalid extension " + beanType.getName() + "': endpoint '"
() -> "Invalid extension " + beanType.getName() + "': endpoint '"
+ endpointType.getName()
+ "' does not support such extension");
EndpointInfo<T> info = getEndpointInfo(endpoints, beanType, endpointType);
Expand All @@ -163,7 +163,7 @@ private Map<Class<?>, EndpointExtensionInfo<T>> discoverExtensions(
private EndpointInfo<T> getEndpointInfo(Map<Class<?>, EndpointInfo<T>> endpoints,
Class<?> beanType, Class<?> endpointClass) {
EndpointInfo<T> endpoint = endpoints.get(endpointClass);
Assert.state(endpoint != null, "Invalid extension '" + beanType.getName()
Assert.state(endpoint != null, () -> "Invalid extension '" + beanType.getName()
+ "': no endpoint found with type '" + endpointClass.getName() + "'");
return endpoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private CacheConfigurations() {

public static String getConfigurationClass(CacheType cacheType) {
Class<?> configurationClass = MAPPINGS.get(cacheType);
Assert.state(configurationClass != null, "Unknown cache type " + cacheType);
Assert.state(configurationClass != null, () -> "Unknown cache type " + cacheType);
return configurationClass.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void checkLocationExists() {
"Migration script locations not configured");
boolean exists = hasAtLeastOneLocation();
Assert.state(exists,
"Cannot find migrations location in: " + this.properties
() -> "Cannot find migrations location in: " + this.properties
.getLocations()
+ " (please add migrations or check your Flyway configuration)");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void setDriverClassName(String driverClassName) {
public String determineDriverClassName() {
if (StringUtils.hasText(this.driverClassName)) {
Assert.state(driverClassIsLoadable(),
"Cannot load driver class: " + this.driverClassName);
() -> "Cannot load driver class: " + this.driverClassName);
return this.driverClassName;
}
String driverClassName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void checkChangelogExists() {
Resource resource = this.resourceLoader
.getResource(this.properties.getChangeLog());
Assert.state(resource.exists(),
"Cannot find changelog location: " + resource
() -> "Cannot find changelog location: " + resource
+ " (please add changelog or check your Liquibase "
+ "configuration)");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private SessionStoreMappings() {
public static String getConfigurationClass(StoreType sessionStoreType) {
Class<?> configurationClass = MAPPINGS.get(sessionStoreType);
Assert.state(configurationClass != null,
"Unknown session store type " + sessionStoreType);
() -> "Unknown session store type " + sessionStoreType);
return configurationClass.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public String getUserId() {
SecurityContext context = SecurityContextHolder.getContext();
Authentication authentication = context.getAuthentication();
Assert.state(authentication != null,
"Unable to get a " + "ConnectionRepository: no user signed in");
"Unable to get a ConnectionRepository: no user signed in");
return authentication.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private File findLaunchScript() throws IOException {
File bin = new File(unpacked.listFiles()[0], "bin");
File launchScript = new File(bin, isWindows() ? "spring.bat" : "spring");
Assert.state(launchScript.exists() && launchScript.isFile(),
"Could not find CLI launch script " + launchScript.getAbsolutePath());
() -> "Could not find CLI launch script " + launchScript.getAbsolutePath());
return launchScript;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String getRelativeName() {
File file = this.file.getAbsoluteFile();
String folderName = StringUtils.cleanPath(folder.getPath());
String fileName = StringUtils.cleanPath(file.getPath());
Assert.state(fileName.startsWith(folderName), "The file " + fileName
Assert.state(fileName.startsWith(folderName), () -> "The file " + fileName
+ " is not contained in the source folder " + folderName);
return fileName.substring(folderName.length() + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void checkNotDisconnected() {
long timeout = HttpTunnelServer.this.disconnectTimeout;
long duration = System.currentTimeMillis() - this.lastHttpRequestTime;
Assert.state(duration < timeout,
"Disconnect timeout: " + timeout + " " + duration);
() -> "Disconnect timeout: " + timeout + " " + duration);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private Class<?> scanPackage(String source) {
Set<BeanDefinition> components = this.scanner.findCandidateComponents(source);
if (!components.isEmpty()) {
Assert.state(components.size() == 1,
"Found multiple @SpringBootConfiguration annotated classes "
() -> "Found multiple @SpringBootConfiguration annotated classes "
+ components);
return ClassUtils.resolveClassName(
components.iterator().next().getBeanClassName(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public ApplicationContext loadContext(MergedContextConfiguration config)
Assert.state(
!ObjectUtils.isEmpty(configClasses)
|| !ObjectUtils.isEmpty(configLocations),
"No configuration classes "
() -> "No configuration classes "
+ "or locations found in @SpringApplicationConfiguration. "
+ "For default configuration detection to work you need "
+ "Spring 4.0.3 or better (found " + SpringVersion.getVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void parseElement(AnnotatedElement element) {
private void parseMockBeanAnnotation(MockBean annotation, AnnotatedElement element) {
Set<ResolvableType> typesToMock = getOrDeduceTypes(element, annotation.value());
Assert.state(!typesToMock.isEmpty(),
"Unable to deduce type to mock from " + element);
() -> "Unable to deduce type to mock from " + element);
if (StringUtils.hasLength(annotation.name())) {
Assert.state(typesToMock.size() == 1,
"The name attribute can only be used when mocking a single class");
Expand All @@ -93,7 +93,7 @@ private void parseMockBeanAnnotation(MockBean annotation, AnnotatedElement eleme
private void parseSpyBeanAnnotation(SpyBean annotation, AnnotatedElement element) {
Set<ResolvableType> typesToSpy = getOrDeduceTypes(element, annotation.value());
Assert.state(!typesToSpy.isEmpty(),
"Unable to deduce type to spy from " + element);
() -> "Unable to deduce type to spy from " + element);
if (StringUtils.hasLength(annotation.name())) {
Assert.state(typesToSpy.size() == 1,
"The name attribute can only be used when spying a single class");
Expand All @@ -109,7 +109,8 @@ private void parseSpyBeanAnnotation(SpyBean annotation, AnnotatedElement element
private void addDefinition(AnnotatedElement element, Definition definition,
String type) {
boolean isNewDefinition = this.definitions.add(definition);
Assert.state(isNewDefinition, "Duplicate " + type + " definition " + definition);
Assert.state(isNewDefinition,
() -> "Duplicate " + type + " definition " + definition);
if (element instanceof Field) {
Field field = (Field) element;
this.definitionFields.put(definition, field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void postProcessField(Object bean, Field field) {
void inject(Field field, Object target, Definition definition) {
String beanName = this.beanNameRegistry.get(definition);
Assert.state(StringUtils.hasLength(beanName),
"No bean found for definition " + definition);
() -> "No bean found for definition " + definition);
inject(field, target, beanName, definition);
}

Expand All @@ -389,7 +389,7 @@ private void inject(Field field, Object target, String beanName,
try {
field.setAccessible(true);
Assert.state(ReflectionUtils.getField(field, target) == null,
"The field " + field + " cannot have an existing value");
() -> "The field " + field + " cannot have an existing value");
Object bean = this.beanFactory.getBean(beanName, field.getType());
if (definition.isProxyTargetAware() && isAopProxy(bean)) {
MockitoAopProxyTargetInterceptor.applyTo(bean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private File findInJavaHome(String javaHome) {
File bin = new File(new File(javaHome), "bin");
File command = new File(bin, "java.exe");
command = (command.exists() ? command : new File(bin, "java"));
Assert.state(command.exists(), "Unable to find java in " + javaHome);
Assert.state(command.exists(), () -> "Unable to find java in " + javaHome);
return command;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public File getDir() {
this.dir = new File(getTempDirectory(), toHexString(hash));
this.dir.mkdirs();
Assert.state(this.dir.exists(),
"Unable to create temp directory " + this.dir);
() -> "Unable to create temp directory " + this.dir);
}
}
return this.dir;
Expand All @@ -90,8 +90,8 @@ private File getTempDirectory() {
String property = System.getProperty("java.io.tmpdir");
Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set");
File file = new File(property);
Assert.state(file.exists(), "Temp directory" + file + " does not exist");
Assert.state(file.isDirectory(), "Temp location " + file + " is not a directory");
Assert.state(file.exists(), () -> "Temp directory" + file + " does not exist");
Assert.state(file.isDirectory(), () -> "Temp location " + file + " is not a directory");
return file;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected final JsonNode getRequiredNode(JsonNode tree, String fieldName) {
Assert.notNull(tree, "Tree must not be null");
JsonNode node = tree.get(fieldName);
Assert.state(node != null && !(node instanceof NullNode),
"Missing JSON field '" + fieldName + "'");
() -> "Missing JSON field '" + fieldName + "'");
return node;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void initialize() {
@Override
protected void doStart() throws Exception {
for (Connector connector : JettyWebServer.this.connectors) {
Assert.state(connector.isStopped(), "Connector " + connector
Assert.state(connector.isStopped(), () -> "Connector " + connector
+ " has been started prematurely");
}
JettyWebServer.this.server.setConnectors(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private void configureSession(Context context) {

private void configurePersistSession(Manager manager) {
Assert.state(manager instanceof StandardManager,
"Unable to persist HTTP session state using manager type "
() -> "Unable to persist HTTP session state using manager type "
+ manager.getClass().getName());
File dir = getValidSessionStoreDir();
File file = new File(dir, "SESSIONS.ser");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected final String getOrDeduceName(Object value) {
*/
protected void configure(Registration.Dynamic registration) {
Assert.state(registration != null,
"Registration is null. Was something already registered for name=["
() -> "Registration is null. Was something already registered for name=["
+ this.name + "]?");
registration.setAsyncSupported(this.asyncSupported);
if (!this.initParameters.isEmpty()) {
Expand Down