Browse Source

Polishing

pull/32754/head
Juergen Hoeller 2 years ago
parent
commit
915d5bddea
  1. 7
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  2. 3
      spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java
  3. 9
      spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -166,6 +166,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
/** Map from scope identifier String to corresponding Scope. */ /** Map from scope identifier String to corresponding Scope. */
private final Map<String, Scope> scopes = new LinkedHashMap<>(8); private final Map<String, Scope> scopes = new LinkedHashMap<>(8);
/** Application startup metrics. **/
private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT;
/** Security context used when running with a SecurityManager. */ /** Security context used when running with a SecurityManager. */
@Nullable @Nullable
private SecurityContextProvider securityContextProvider; private SecurityContextProvider securityContextProvider;
@ -180,8 +183,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
private final ThreadLocal<Object> prototypesCurrentlyInCreation = private final ThreadLocal<Object> prototypesCurrentlyInCreation =
new NamedThreadLocal<>("Prototype beans currently in creation"); new NamedThreadLocal<>("Prototype beans currently in creation");
/** Application startup metrics. **/
private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT;
/** /**
* Create a new AbstractBeanFactory. * Create a new AbstractBeanFactory.

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -268,6 +268,7 @@ public class ClassPathBeanDefinitionScannerTests {
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
scanner.setIncludeAnnotationConfig(false); scanner.setIncludeAnnotationConfig(false);
scanner.scan("org.springframework.context.annotation2"); scanner.scan("org.springframework.context.annotation2");
assertThatIllegalStateException().isThrownBy(() -> scanner.scan(BASE_PACKAGE)) assertThatIllegalStateException().isThrownBy(() -> scanner.scan(BASE_PACKAGE))
.withMessageContaining("myNamedDao") .withMessageContaining("myNamedDao")
.withMessageContaining(NamedStubDao.class.getName()) .withMessageContaining(NamedStubDao.class.getName())

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -496,7 +496,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
String rootDirPath = determineRootDir(locationPattern); String rootDirPath = determineRootDir(locationPattern);
String subPattern = locationPattern.substring(rootDirPath.length()); String subPattern = locationPattern.substring(rootDirPath.length());
Resource[] rootDirResources = getResources(rootDirPath); Resource[] rootDirResources = getResources(rootDirPath);
Set<Resource> result = new LinkedHashSet<>(16); Set<Resource> result = new LinkedHashSet<>(64);
for (Resource rootDirResource : rootDirResources) { for (Resource rootDirResource : rootDirResources) {
rootDirResource = resolveRootDirResource(rootDirResource); rootDirResource = resolveRootDirResource(rootDirResource);
URL rootDirUrl = rootDirResource.getURL(); URL rootDirUrl = rootDirResource.getURL();
@ -648,7 +648,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
// The Sun JRE does not return a slash here, but BEA JRockit does. // The Sun JRE does not return a slash here, but BEA JRockit does.
rootEntryPath = rootEntryPath + "/"; rootEntryPath = rootEntryPath + "/";
} }
Set<Resource> result = new LinkedHashSet<>(8); Set<Resource> result = new LinkedHashSet<>(64);
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
JarEntry entry = entries.nextElement(); JarEntry entry = entries.nextElement();
String entryPath = entry.getName(); String entryPath = entry.getName();
@ -864,7 +864,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
private final String rootPath; private final String rootPath;
private final Set<Resource> resources = new LinkedHashSet<>(); private final Set<Resource> resources = new LinkedHashSet<>(64);
public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) { public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) {
this.subPattern = subPattern; this.subPattern = subPattern;
@ -895,7 +895,6 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
else if ("toString".equals(methodName)) { else if ("toString".equals(methodName)) {
return toString(); return toString();
} }
throw new IllegalStateException("Unexpected method invocation: " + method); throw new IllegalStateException("Unexpected method invocation: " + method);
} }

Loading…
Cancel
Save