Skip to content

Commit c1287d4

Browse files
committed
Polishing
1 parent 528029a commit c1287d4

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

framework-docs/modules/ROOT/pages/data-access/orm/jpa.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ The actual JPA provider bootstrapping is handed off to the specified executor an
268268
running in parallel, to the application bootstrap thread. The exposed `EntityManagerFactory`
269269
proxy can be injected into other application components and is even able to respond to
270270
`EntityManagerFactoryInfo` configuration inspection. However, once the actual JPA provider
271-
is being accessed by other components (for example, calling `createEntityManager`), those calls
272-
block until the background bootstrapping has completed. In particular, when you use
271+
is being accessed by other components (for example, calling `createEntityManager`), those
272+
calls block until the background bootstrapping has completed. In particular, when you use
273273
Spring Data JPA, make sure to set up deferred bootstrapping for its repositories as well.
274274

275275

@@ -284,9 +284,9 @@ to a newly created `EntityManager` per operation, in effect making its usage thr
284284

285285
It is possible to write code against the plain JPA without any Spring dependencies, by
286286
using an injected `EntityManagerFactory` or `EntityManager`. Spring can understand the
287-
`@PersistenceUnit` and `@PersistenceContext` annotations both at the field and the method level
288-
if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example shows a plain
289-
JPA DAO implementation that uses the `@PersistenceUnit` annotation:
287+
`@PersistenceUnit` and `@PersistenceContext` annotations both at the field and the method
288+
level if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example
289+
shows a plain JPA DAO implementation that uses the `@PersistenceUnit` annotation:
290290

291291
[tabs]
292292
======

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -161,6 +161,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
161161
/** Map from scope identifier String to corresponding Scope. */
162162
private final Map<String, Scope> scopes = new LinkedHashMap<>(8);
163163

164+
/** Application startup metrics. **/
165+
private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT;
166+
164167
/** Map from bean name to merged RootBeanDefinition. */
165168
private final Map<String, RootBeanDefinition> mergedBeanDefinitions = new ConcurrentHashMap<>(256);
166169

@@ -171,8 +174,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
171174
private final ThreadLocal<Object> prototypesCurrentlyInCreation =
172175
new NamedThreadLocal<>("Prototype beans currently in creation");
173176

174-
/** Application startup metrics. **/
175-
private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT;
176177

177178
/**
178179
* Create a new AbstractBeanFactory.

spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() {
293293
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
294294
scanner.setIncludeAnnotationConfig(false);
295295
scanner.scan("org.springframework.context.annotation2");
296+
296297
assertThatIllegalStateException().isThrownBy(() -> scanner.scan(BASE_PACKAGE))
297298
.withMessageContaining("myNamedDao")
298299
.withMessageContaining(NamedStubDao.class.getName())

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -568,7 +568,7 @@ protected Resource[] findPathMatchingResources(String locationPattern) throws IO
568568
String rootDirPath = determineRootDir(locationPattern);
569569
String subPattern = locationPattern.substring(rootDirPath.length());
570570
Resource[] rootDirResources = getResources(rootDirPath);
571-
Set<Resource> result = new LinkedHashSet<>(16);
571+
Set<Resource> result = new LinkedHashSet<>(64);
572572
for (Resource rootDirResource : rootDirResources) {
573573
rootDirResource = resolveRootDirResource(rootDirResource);
574574
URL rootDirUrl = rootDirResource.getURL();
@@ -726,7 +726,7 @@ protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource,
726726
// The Sun JRE does not return a slash here, but BEA JRockit does.
727727
rootEntryPath = rootEntryPath + "/";
728728
}
729-
Set<Resource> result = new LinkedHashSet<>(8);
729+
Set<Resource> result = new LinkedHashSet<>(64);
730730
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
731731
JarEntry entry = entries.nextElement();
732732
String entryPath = entry.getName();
@@ -777,7 +777,7 @@ protected JarFile getJarFile(String jarFileUrl) throws IOException {
777777
protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern)
778778
throws IOException {
779779

780-
Set<Resource> result = new LinkedHashSet<>();
780+
Set<Resource> result = new LinkedHashSet<>(64);
781781
URI rootDirUri;
782782
try {
783783
rootDirUri = rootDirResource.getURI();
@@ -886,7 +886,7 @@ protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource
886886
* @see PathMatcher#match(String, String)
887887
*/
888888
protected Set<Resource> findAllModulePathResources(String locationPattern) throws IOException {
889-
Set<Resource> result = new LinkedHashSet<>(16);
889+
Set<Resource> result = new LinkedHashSet<>(64);
890890

891891
// Skip scanning the module path when running in a native image.
892892
if (NativeDetector.inNativeImage()) {
@@ -987,7 +987,7 @@ private static class PatternVirtualFileVisitor implements InvocationHandler {
987987

988988
private final String rootPath;
989989

990-
private final Set<Resource> resources = new LinkedHashSet<>();
990+
private final Set<Resource> resources = new LinkedHashSet<>(64);
991991

992992
public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) {
993993
this.subPattern = subPattern;
@@ -1000,15 +1000,17 @@ public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher
10001000
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
10011001
String methodName = method.getName();
10021002
if (Object.class == method.getDeclaringClass()) {
1003-
switch(methodName) {
1004-
case "equals":
1003+
switch (methodName) {
1004+
case "equals" -> {
10051005
// Only consider equal when proxies are identical.
10061006
return (proxy == args[0]);
1007-
case "hashCode":
1007+
}
1008+
case "hashCode" -> {
10081009
return System.identityHashCode(proxy);
1010+
}
10091011
}
10101012
}
1011-
return switch(methodName) {
1013+
return switch (methodName) {
10121014
case "getAttributes" -> getAttributes();
10131015
case "visit" -> {
10141016
visit(args[0]);

0 commit comments

Comments
 (0)