mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '3.1.x'
Closes gh-37884
This commit is contained in:
commit
085e12aa93
@ -59,14 +59,18 @@ class WebServletHandler extends ServletComponentHandler {
|
||||
: beanDefinition.getBeanClassName());
|
||||
}
|
||||
|
||||
private MultipartConfigElement determineMultipartConfig(AnnotatedBeanDefinition beanDefinition) {
|
||||
private BeanDefinition determineMultipartConfig(AnnotatedBeanDefinition beanDefinition) {
|
||||
Map<String, Object> attributes = beanDefinition.getMetadata()
|
||||
.getAnnotationAttributes(MultipartConfig.class.getName());
|
||||
if (attributes == null) {
|
||||
return null;
|
||||
}
|
||||
return new MultipartConfigElement((String) attributes.get("location"), (Long) attributes.get("maxFileSize"),
|
||||
(Long) attributes.get("maxRequestSize"), (Integer) attributes.get("fileSizeThreshold"));
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(MultipartConfigElement.class);
|
||||
builder.addConstructorArgValue(attributes.get("location"));
|
||||
builder.addConstructorArgValue(attributes.get("maxFileSize"));
|
||||
builder.addConstructorArgValue(attributes.get("maxRequestSize"));
|
||||
builder.addConstructorArgValue(attributes.get("fileSizeThreshold"));
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import org.springframework.javapoet.ClassName;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/**
|
||||
* Tests for {@link ServletComponentScanRegistrar}
|
||||
@ -158,6 +159,16 @@ class ServletComponentScanRegistrarTests {
|
||||
.accepts(generationContext.getRuntimeHints());
|
||||
}
|
||||
|
||||
@Test
|
||||
void processAheadOfTimeSucceedsForWebServletWithMultipartConfig() {
|
||||
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
context.registerBean(ScanServletPackage.class);
|
||||
TestGenerationContext generationContext = new TestGenerationContext(
|
||||
ClassName.get(getClass().getPackageName(), "TestTarget"));
|
||||
assertThatNoException()
|
||||
.isThrownBy(() -> new ApplicationContextAotGenerator().processAheadOfTime(context, generationContext));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void compile(GenericApplicationContext context, Consumer<GenericApplicationContext> freshContext) {
|
||||
TestGenerationContext generationContext = new TestGenerationContext(
|
||||
@ -215,4 +226,10 @@ class ServletComponentScanRegistrarTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ServletComponentScan("org.springframework.boot.web.servlet.testcomponents.servlet")
|
||||
static class ScanServletPackage {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user