Merge branch '6.1.x'

This commit is contained in:
Juergen Hoeller
2024-04-24 13:42:43 +02:00
4 changed files with 14 additions and 3 deletions

View File

@@ -315,6 +315,16 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"'" + beanName + "' depends on missing bean '" + dep + "'", ex);
}
catch (BeanCreationException ex) {
if (requiredType != null) {
// Wrap exception with current bean metadata but only if specifically
// requested (indicated by required type), not for depends-on cascades.
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Failed to initialize dependency '" + ex.getBeanName() + "' of " +
requiredType.getSimpleName() + " bean '" + beanName + "'", ex);
}
throw ex;
}
}
}

View File

@@ -957,7 +957,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
for (String weaverAwareName : weaverAwareNames) {
getBean(weaverAwareName);
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
}
// Stop using the temporary ClassLoader for type matching.

View File

@@ -104,7 +104,6 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
}
@Override
@SuppressWarnings("unchecked")
protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
@@ -112,6 +111,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
writeResourceRegion(resourceRegion, outputMessage);
}
else {
@SuppressWarnings("unchecked")
Collection<ResourceRegion> regions = (Collection<ResourceRegion>) object;
if (regions.size() == 1) {
writeResourceRegion(regions.iterator().next(), outputMessage);

View File

@@ -864,12 +864,14 @@ public class MvcUriComponentsBuilderTests {
}
}
interface HelloInterface {
@GetMapping("/hello/{name}")
ResponseEntity<String> get(@PathVariable String name);
}
@Controller
static class HelloController implements HelloInterface {
@@ -877,7 +879,6 @@ public class MvcUriComponentsBuilderTests {
public ResponseEntity<String> get(String name) {
return ResponseEntity.ok("Hello " + name);
}
}
}