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
e27bc9dd
Commit
e27bc9dd
authored
Jun 11, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
6dc0ecb1
f27bdcb7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
15 deletions
+82
-15
DataSourceBuilder.java
...gframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
+2
-4
AbstractDevToolsDataSourceAutoConfigurationTests.java
...ure/AbstractDevToolsDataSourceAutoConfigurationTests.java
+0
-1
TypeUtils.java
...pringframework/boot/configurationprocessor/TypeUtils.java
+19
-7
BeanDefinitionLoader.java
...n/java/org/springframework/boot/BeanDefinitionLoader.java
+24
-1
BasicJsonParser.java
...n/java/org/springframework/boot/json/BasicJsonParser.java
+2
-2
BeanDefinitionLoaderTests.java
...a/org/springframework/boot/BeanDefinitionLoaderTests.java
+11
-0
MyComponentInPackageWithoutDot.java
...est/java/sampleconfig/MyComponentInPackageWithoutDot.java
+24
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
View file @
e27bc9dd
...
...
@@ -84,10 +84,8 @@ public class DataSourceBuilder {
private
void
bind
(
DataSource
result
)
{
MutablePropertyValues
properties
=
new
MutablePropertyValues
(
this
.
properties
);
new
RelaxedDataBinder
(
result
)
.
withAlias
(
"url"
,
"jdbcUrl"
)
.
withAlias
(
"username"
,
"user"
)
.
bind
(
properties
);
new
RelaxedDataBinder
(
result
).
withAlias
(
"url"
,
"jdbcUrl"
)
.
withAlias
(
"username"
,
"user"
).
bind
(
properties
);
}
public
DataSourceBuilder
type
(
Class
<?
extends
DataSource
>
type
)
{
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java
View file @
e27bc9dd
...
...
@@ -76,7 +76,6 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
@Test
public
void
emptyFactoryMethodMetadataIgnored
()
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
DataSource
dataSource
=
mock
(
DataSource
.
class
);
AnnotatedGenericBeanDefinition
beanDefinition
=
new
AnnotatedGenericBeanDefinition
(
dataSource
.
getClass
());
...
...
spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java
View file @
e27bc9dd
...
...
@@ -27,7 +27,6 @@ import javax.lang.model.element.TypeElement;
import
javax.lang.model.type.DeclaredType
;
import
javax.lang.model.type.TypeKind
;
import
javax.lang.model.type.TypeMirror
;
import
javax.lang.model.type.WildcardType
;
import
javax.lang.model.util.Types
;
/**
...
...
@@ -73,12 +72,25 @@ class TypeUtils {
TypeUtils
(
ProcessingEnvironment
env
)
{
this
.
env
=
env
;
Types
types
=
env
.
getTypeUtils
();
WildcardType
wc
=
types
.
getWildcardType
(
null
,
null
);
this
.
collectionType
=
types
.
getDeclaredType
(
this
.
env
.
getElementUtils
().
getTypeElement
(
Collection
.
class
.
getName
()),
wc
);
this
.
mapType
=
types
.
getDeclaredType
(
this
.
env
.
getElementUtils
().
getTypeElement
(
Map
.
class
.
getName
()),
wc
,
wc
);
this
.
collectionType
=
getDeclaredType
(
types
,
Collection
.
class
,
1
);
this
.
mapType
=
getDeclaredType
(
types
,
Map
.
class
,
2
);
}
private
TypeMirror
getDeclaredType
(
Types
types
,
Class
<?>
typeClass
,
int
numberOfTypeArgs
)
{
TypeMirror
[]
typeArgs
=
new
TypeMirror
[
numberOfTypeArgs
];
for
(
int
i
=
0
;
i
<
typeArgs
.
length
;
i
++)
{
typeArgs
[
i
]
=
types
.
getWildcardType
(
null
,
null
);
}
TypeElement
typeElement
=
this
.
env
.
getElementUtils
()
.
getTypeElement
(
typeClass
.
getName
());
try
{
return
types
.
getDeclaredType
(
typeElement
,
typeArgs
);
}
catch
(
IllegalArgumentException
ex
)
{
// Try again without generics for older Java versions
return
types
.
getDeclaredType
(
typeElement
);
}
}
public
String
getType
(
Element
element
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java
View file @
e27bc9dd
...
...
@@ -33,6 +33,7 @@ import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import
org.springframework.context.annotation.ClassPathBeanDefinitionScanner
;
import
org.springframework.core.annotation.AnnotationUtils
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
...
...
@@ -201,7 +202,7 @@ class BeanDefinitionLoader {
int
loadCount
=
0
;
boolean
atLeastOneResourceExists
=
false
;
for
(
Resource
resource
:
resources
)
{
if
(
resource
!=
null
&&
resource
.
exists
(
))
{
if
(
isLoadCandidate
(
resource
))
{
atLeastOneResourceExists
=
true
;
loadCount
+=
load
(
resource
);
}
...
...
@@ -235,6 +236,28 @@ class BeanDefinitionLoader {
}
}
private
boolean
isLoadCandidate
(
Resource
resource
)
{
if
(
resource
==
null
||
!
resource
.
exists
())
{
return
false
;
}
if
(
resource
instanceof
ClassPathResource
)
{
// A simple package without a '.' may accidentally get loaded as an XML
// document if we're not careful. The result of getInputStream() will be
// a file list of the package content. We double check here that it's not
// actually a package.
String
path
=
((
ClassPathResource
)
resource
).
getPath
();
if
(
path
.
indexOf
(
"."
)
==
-
1
)
{
try
{
return
Package
.
getPackage
(
path
)
==
null
;
}
catch
(
Exception
ex
)
{
// Ignore
}
}
}
return
true
;
}
private
Package
findPackage
(
CharSequence
source
)
{
Package
pkg
=
Package
.
getPackage
(
source
.
toString
());
if
(
pkg
!=
null
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java
View file @
e27bc9dd
...
...
@@ -93,14 +93,14 @@ public class BasicJsonParser implements JsonParser {
}
private
static
String
trimTrailingCharacter
(
String
string
,
char
c
)
{
if
(
string
.
length
()
>
=
0
&&
string
.
charAt
(
string
.
length
()
-
1
)
==
c
)
{
if
(
string
.
length
()
>
0
&&
string
.
charAt
(
string
.
length
()
-
1
)
==
c
)
{
return
string
.
substring
(
0
,
string
.
length
()
-
1
);
}
return
string
;
}
private
static
String
trimLeadingCharacter
(
String
string
,
char
c
)
{
if
(
string
.
length
()
>
=
0
&&
string
.
charAt
(
0
)
==
c
)
{
if
(
string
.
length
()
>
0
&&
string
.
charAt
(
0
)
==
c
)
{
return
string
.
substring
(
1
);
}
return
string
;
...
...
spring-boot/src/test/java/org/springframework/boot/BeanDefinitionLoaderTests.java
View file @
e27bc9dd
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
sampleconfig.MyComponentInPackageWithoutDot
;
import
org.springframework.boot.sampleconfig.MyComponent
;
import
org.springframework.context.support.StaticApplicationContext
;
...
...
@@ -123,6 +124,16 @@ public class BeanDefinitionLoaderTests {
assertThat
(
this
.
registry
.
containsBean
(
"myComponent"
)).
isTrue
();
}
@Test
public
void
loadPackageNameWithoutDot
()
throws
Exception
{
// See gh-6126
BeanDefinitionLoader
loader
=
new
BeanDefinitionLoader
(
this
.
registry
,
MyComponentInPackageWithoutDot
.
class
.
getPackage
().
getName
());
int
loaded
=
loader
.
load
();
assertThat
(
loaded
,
equalTo
(
1
));
assertTrue
(
this
.
registry
.
containsBean
(
"myComponentInPackageWithoutDot"
));
}
@Test
public
void
loadPackageAndClassDoesNotDoubleAdd
()
throws
Exception
{
BeanDefinitionLoader
loader
=
new
BeanDefinitionLoader
(
this
.
registry
,
...
...
spring-boot/src/test/java/sampleconfig/MyComponentInPackageWithoutDot.java
0 → 100644
View file @
e27bc9dd
/*
* Copyright 2012-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
sampleconfig
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyComponentInPackageWithoutDot
{
}
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