Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
1a44b3e6
Commit
1a44b3e6
authored
Jan 09, 2014
by
Christian Dupuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sorting of auto configuration classes on JDK 8
parent
fd15b62a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
AutoConfigurationSorter.java
...framework/boot/autoconfigure/AutoConfigurationSorter.java
+6
-3
AutoConfigurationSorterTests.java
...work/boot/autoconfigure/AutoConfigurationSorterTests.java
+9
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java
View file @
1a44b3e6
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
springframework
.
boot
.
autoconfigure
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -38,6 +37,7 @@ import org.springframework.core.type.classreading.MetadataReader;
import
org.springframework.core.type.classreading.MetadataReaderFactory
;
import
org.springframework.util.Assert
;
/**
* Sort {@link EnableAutoConfiguration auto-configuration} classes into priority order by
* reading {@link Ordered} and {@link AutoConfigureAfter} annotations (without loading
...
...
@@ -63,6 +63,9 @@ class AutoConfigurationSorter {
List
<
String
>
orderedClassNames
=
new
ArrayList
<
String
>(
classNames
);
// Sort initially by order
Collections
.
sort
(
orderedClassNames
);
// Then sort by order
Collections
.
sort
(
orderedClassNames
,
new
Comparator
<
String
>()
{
@Override
public
int
compare
(
String
o1
,
String
o2
)
{
...
...
@@ -130,7 +133,7 @@ class AutoConfigurationSorter {
}
public
Set
<
String
>
getClassesRequestedAfter
(
String
className
)
{
Set
<
String
>
rtn
=
new
HashSet
<
String
>();
Set
<
String
>
rtn
=
new
Linked
HashSet
<
String
>();
rtn
.
addAll
(
get
(
className
).
getAfter
());
for
(
Map
.
Entry
<
String
,
AutoConfigurationClass
>
entry
:
this
.
classes
.
entrySet
())
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationSorterTests.java
View file @
1a44b3e6
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -94,6 +94,14 @@ public class AutoConfigurationSorterTests {
assertThat
(
actual
,
nameMatcher
(
C
,
W
,
B
,
A
,
X
));
}
@Test
public
void
byAutoConfigureMixedBeforeAndAfterWithDifferentInputOrder
()
throws
Exception
{
List
<
String
>
actual
=
this
.
sorter
.
getInPriorityOrder
(
Arrays
.
asList
(
W
,
X
,
A
,
B
,
C
));
assertThat
(
actual
,
nameMatcher
(
C
,
W
,
B
,
A
,
X
));
}
@Test
public
void
byAutoConfigureAfterWithMissing
()
throws
Exception
{
List
<
String
>
actual
=
this
.
sorter
.
getInPriorityOrder
(
Arrays
.
asList
(
A
,
B
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment