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
968b68c3
Commit
968b68c3
authored
Jun 02, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
10f7031e
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
107 additions
and
98 deletions
+107
-98
MetricFilterAutoConfiguration.java
.../actuate/autoconfigure/MetricFilterAutoConfiguration.java
+2
-4
ManagementSecurityAutoConfigurationTests.java
...toconfigure/ManagementSecurityAutoConfigurationTests.java
+17
-26
BeanTypeRegistry.java
...mework/boot/autoconfigure/condition/BeanTypeRegistry.java
+19
-18
GzipFilterProperties.java
...ramework/boot/autoconfigure/web/GzipFilterProperties.java
+1
-1
ElasticsearchRepositoriesAutoConfigurationTests.java
...arch/ElasticsearchRepositoriesAutoConfigurationTests.java
+10
-10
ElasticsearchAutoConfigurationTests.java
...re/elasticsearch/ElasticsearchAutoConfigurationTests.java
+1
-1
ElasticsearchDataAutoConfigurationTests.java
...lasticsearch/ElasticsearchDataAutoConfigurationTests.java
+2
-1
RunProcessCommand.java
...ngframework/boot/cli/command/shell/RunProcessCommand.java
+1
-0
SampleElasticsearchApplicationTests.java
...ta/elasticsearch/SampleElasticsearchApplicationTests.java
+6
-5
JarEntryData.java
...ava/org/springframework/boot/loader/jar/JarEntryData.java
+21
-12
JarFileTests.java
...ava/org/springframework/boot/loader/jar/JarFileTests.java
+1
-1
PropertySourcesPropertyValues.java
...ingframework/boot/bind/PropertySourcesPropertyValues.java
+12
-10
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+7
-5
PropertySourcesPropertyValuesTests.java
...amework/boot/bind/PropertySourcesPropertyValuesTests.java
+7
-4
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfiguration.java
View file @
968b68c3
...
@@ -135,14 +135,12 @@ public class MetricFilterAutoConfiguration {
...
@@ -135,14 +135,12 @@ public class MetricFilterAutoConfiguration {
}
}
private
boolean
is4xxClientError
(
int
status
)
{
private
boolean
is4xxClientError
(
int
status
)
{
HttpStatus
httpStatus
=
HttpStatus
.
OK
;
try
{
try
{
httpStatus
=
HttpStatus
.
valueOf
(
status
);
return
HttpStatus
.
valueOf
(
status
).
is4xxClientError
(
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
// not convertible
return
false
;
}
}
return
httpStatus
.
is4xxClientError
();
}
}
private
String
getKey
(
String
string
)
{
private
String
getKey
(
String
string
)
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfigurationTests.java
View file @
968b68c3
...
@@ -44,11 +44,11 @@ import org.springframework.security.core.userdetails.UserDetailsService;
...
@@ -44,11 +44,11 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import
org.springframework.security.web.FilterChainProxy
;
import
org.springframework.security.web.FilterChainProxy
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.ResultMatcher
;
import
org.springframework.test.web.servlet.request.MockMvcRequestBuilders
;
import
org.springframework.test.web.servlet.request.MockMvcRequestBuilders
;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
...
@@ -209,44 +209,36 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -209,44 +209,36 @@ public class ManagementSecurityAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
MockMvc
mockMvc
=
MockMvcBuilders
Filter
filter
=
this
.
context
.
getBean
(
"springSecurityFilterChain"
,
Filter
.
class
);
.
webAppContextSetup
((
WebApplicationContext
)
this
.
context
)
MockMvc
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
)
.
addFilters
(
.
addFilters
(
filter
).
build
();
this
.
context
.
getBean
(
"springSecurityFilterChain"
,
Filter
.
class
))
.
build
();
// no user (Main)
// no user (Main)
mockMvc
.
perform
(
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/"
))
MockMvcRequestBuilders
.
get
(
"/"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
.
andExpect
(
springAuthenticateRealmHeader
());
MockMvcResultMatchers
.
header
().
string
(
"www-authenticate"
,
Matchers
.
containsString
(
"realm=\"Spring\""
)));
// invalid user (Main)
// invalid user (Main)
mockMvc
.
perform
(
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/"
).
header
(
"authorization"
,
"Basic xxx"
))
MockMvcRequestBuilders
.
get
(
"/"
).
header
(
"authorization"
,
"Basic xxx"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
.
andExpect
(
springAuthenticateRealmHeader
());
MockMvcResultMatchers
.
header
().
string
(
"www-authenticate"
,
Matchers
.
containsString
(
"realm=\"Spring\""
)));
// no user (Management)
// no user (Management)
mockMvc
.
perform
(
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/beans"
))
MockMvcRequestBuilders
.
get
(
"/beans"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
.
andExpect
(
springAuthenticateRealmHeader
());
MockMvcResultMatchers
.
header
().
string
(
"www-authenticate"
,
Matchers
.
containsString
(
"realm=\"Spring\""
)));
// invalid user (Management)
// invalid user (Management)
mockMvc
.
perform
(
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/beans"
).
header
(
"authorization"
,
"Basic xxx"
))
MockMvcRequestBuilders
.
get
(
"/beans"
).
header
(
"authorization"
,
"Basic xxx"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isUnauthorized
())
.
andExpect
(
.
andExpect
(
springAuthenticateRealmHeader
());
MockMvcResultMatchers
.
header
().
string
(
"www-authenticate"
,
}
Matchers
.
containsString
(
"realm=\"Spring\""
)));
private
ResultMatcher
springAuthenticateRealmHeader
()
{
return
MockMvcResultMatchers
.
header
().
string
(
"www-authenticate"
,
Matchers
.
containsString
(
"realm=\"Spring\""
));
}
}
@EnableGlobalAuthentication
@EnableGlobalAuthentication
...
@@ -254,9 +246,8 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -254,9 +246,8 @@ public class ManagementSecurityAutoConfigurationTests {
static
class
AuthenticationConfig
{
static
class
AuthenticationConfig
{
@Autowired
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
auth
.
inMemoryAuthentication
().
withUser
(
"user"
).
password
(
"password"
)
.
inMemoryAuthentication
()
.
roles
(
"USER"
);
.
withUser
(
"user"
).
password
(
"password"
).
roles
(
"USER"
);
}
}
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java
View file @
968b68c3
...
@@ -116,26 +116,14 @@ abstract class BeanTypeRegistry {
...
@@ -116,26 +116,14 @@ abstract class BeanTypeRegistry {
definition
.
getFactoryMethodName
());
definition
.
getFactoryMethodName
());
Class
<?>
generic
=
ResolvableType
.
forMethodReturnType
(
method
)
Class
<?>
generic
=
ResolvableType
.
forMethodReturnType
(
method
)
.
as
(
FactoryBean
.
class
).
resolveGeneric
();
.
as
(
FactoryBean
.
class
).
resolveGeneric
();
if
(
generic
==
null
||
generic
.
equals
(
Object
.
class
))
{
if
((
generic
==
null
||
generic
.
equals
(
Object
.
class
))
generic
=
determineTypeFromDefinitionAttribute
(
factoryDefinition
);
&&
definition
.
hasAttribute
(
FACTORY_BEAN_OBJECT_TYPE
))
{
generic
=
getTypeFromAttribute
(
definition
.
getAttribute
(
FACTORY_BEAN_OBJECT_TYPE
));
}
}
return
generic
;
return
generic
;
}
}
private
Class
<?>
determineTypeFromDefinitionAttribute
(
BeanDefinition
definition
)
throws
ClassNotFoundException
,
LinkageError
{
if
(
definition
.
hasAttribute
(
FACTORY_BEAN_OBJECT_TYPE
))
{
Object
attributeObject
=
definition
.
getAttribute
(
FACTORY_BEAN_OBJECT_TYPE
);
if
(
attributeObject
instanceof
Class
<?>)
{
return
(
Class
<?>)
attributeObject
;
}
else
if
(
attributeObject
instanceof
String
)
{
return
ClassUtils
.
forName
((
String
)
attributeObject
,
null
);
}
}
return
Object
.
class
;
}
private
Class
<?>
getDirectFactoryBeanGeneric
(
private
Class
<?>
getDirectFactoryBeanGeneric
(
ConfigurableListableBeanFactory
beanFactory
,
BeanDefinition
definition
,
ConfigurableListableBeanFactory
beanFactory
,
BeanDefinition
definition
,
String
name
)
throws
ClassNotFoundException
,
LinkageError
{
String
name
)
throws
ClassNotFoundException
,
LinkageError
{
...
@@ -143,12 +131,25 @@ abstract class BeanTypeRegistry {
...
@@ -143,12 +131,25 @@ abstract class BeanTypeRegistry {
beanFactory
.
getBeanClassLoader
());
beanFactory
.
getBeanClassLoader
());
Class
<?>
generic
=
ResolvableType
.
forClass
(
factoryBeanClass
)
Class
<?>
generic
=
ResolvableType
.
forClass
(
factoryBeanClass
)
.
as
(
FactoryBean
.
class
).
resolveGeneric
();
.
as
(
FactoryBean
.
class
).
resolveGeneric
();
if
(
generic
==
null
||
generic
.
equals
(
Object
.
class
))
{
if
((
generic
==
null
||
generic
.
equals
(
Object
.
class
))
generic
=
determineTypeFromDefinitionAttribute
(
definition
);
&&
definition
.
hasAttribute
(
FACTORY_BEAN_OBJECT_TYPE
))
{
generic
=
getTypeFromAttribute
(
definition
.
getAttribute
(
FACTORY_BEAN_OBJECT_TYPE
));
}
}
return
generic
;
return
generic
;
}
}
private
Class
<?>
getTypeFromAttribute
(
Object
attribute
)
throws
ClassNotFoundException
,
LinkageError
{
if
(
attribute
instanceof
Class
<?>)
{
return
(
Class
<?>)
attribute
;
}
if
(
attribute
instanceof
String
)
{
return
ClassUtils
.
forName
((
String
)
attribute
,
null
);
}
return
null
;
}
/**
/**
* Factory method to get the {@link BeanTypeRegistry} for a given {@link BeanFactory}.
* Factory method to get the {@link BeanTypeRegistry} for a given {@link BeanFactory}.
* @param beanFactory the source bean factory
* @param beanFactory the source bean factory
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/GzipFilterProperties.java
View file @
968b68c3
...
@@ -163,7 +163,7 @@ public class GzipFilterProperties {
...
@@ -163,7 +163,7 @@ public class GzipFilterProperties {
}
}
public
List
<
MimeType
>
getExcludedMimeTypes
()
{
public
List
<
MimeType
>
getExcludedMimeTypes
()
{
return
excludedMimeTypes
;
return
this
.
excludedMimeTypes
;
}
}
public
void
setExcludedMimeTypes
(
List
<
MimeType
>
excludedMimeTypes
)
{
public
void
setExcludedMimeTypes
(
List
<
MimeType
>
excludedMimeTypes
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfigurationTests.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -51,9 +51,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
...
@@ -51,9 +51,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
addElasticsearchProperties
(
this
.
context
);
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
);
this
.
context
.
register
(
TestConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
@@ -67,9 +65,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
...
@@ -67,9 +65,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
testNoRepositoryConfiguration
()
throws
Exception
{
public
void
testNoRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
addElasticsearchProperties
(
this
.
context
);
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
);
this
.
context
.
register
(
EmptyConfiguration
.
class
,
this
.
context
.
register
(
EmptyConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
@@ -82,9 +78,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
...
@@ -82,9 +78,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
doesNotTriggerDefaultRepositoryDetectionIfCustomized
()
{
public
void
doesNotTriggerDefaultRepositoryDetectionIfCustomized
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
addElasticsearchProperties
(
this
.
context
);
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
);
this
.
context
.
register
(
CustomizedConfiguration
.
class
,
this
.
context
.
register
(
CustomizedConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
@@ -94,6 +88,12 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
...
@@ -94,6 +88,12 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
assertNotNull
(
this
.
context
.
getBean
(
CityElasticsearchDbRepository
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
CityElasticsearchDbRepository
.
class
));
}
}
private
void
addElasticsearchProperties
(
AnnotationConfigApplicationContext
context
)
{
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
);
}
@Configuration
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestConfiguration
{
protected
static
class
TestConfiguration
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfigurationTests.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchDataAutoConfigurationTests.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -54,4 +54,5 @@ public class ElasticsearchDataAutoConfigurationTests {
...
@@ -54,4 +54,5 @@ public class ElasticsearchDataAutoConfigurationTests {
assertEquals
(
1
,
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
ElasticsearchTemplate
.
class
).
length
);
this
.
context
.
getBeanNamesForType
(
ElasticsearchTemplate
.
class
).
length
);
}
}
}
}
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/RunProcessCommand.java
View file @
968b68c3
...
@@ -34,6 +34,7 @@ import org.springframework.boot.loader.tools.RunProcess;
...
@@ -34,6 +34,7 @@ import org.springframework.boot.loader.tools.RunProcess;
class
RunProcessCommand
extends
AbstractCommand
{
class
RunProcessCommand
extends
AbstractCommand
{
private
final
String
[]
command
;
private
final
String
[]
command
;
private
volatile
RunProcess
process
;
private
volatile
RunProcess
process
;
public
RunProcessCommand
(
String
...
command
)
{
public
RunProcessCommand
(
String
...
command
)
{
...
...
spring-boot-samples/spring-boot-sample-data-elasticsearch/src/test/java/sample/data/elasticsearch/SampleElasticsearchApplicationTests.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -33,6 +33,10 @@ import static org.junit.Assert.assertTrue;
...
@@ -33,6 +33,10 @@ import static org.junit.Assert.assertTrue;
*/
*/
public
class
SampleElasticsearchApplicationTests
{
public
class
SampleElasticsearchApplicationTests
{
private
static
final
String
[]
PROPERTIES
=
{
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
};
@Rule
@Rule
public
OutputCapture
outputCapture
=
new
OutputCapture
();
public
OutputCapture
outputCapture
=
new
OutputCapture
();
...
@@ -40,10 +44,7 @@ public class SampleElasticsearchApplicationTests {
...
@@ -40,10 +44,7 @@ public class SampleElasticsearchApplicationTests {
public
void
testDefaultSettings
()
throws
Exception
{
public
void
testDefaultSettings
()
throws
Exception
{
try
{
try
{
new
SpringApplicationBuilder
(
SampleElasticsearchApplication
.
class
)
new
SpringApplicationBuilder
(
SampleElasticsearchApplication
.
class
)
.
properties
(
.
properties
(
PROPERTIES
).
run
();
"spring.data.elasticsearch.properties.path.data:target/data"
,
"spring.data.elasticsearch.properties.path.logs:target/logs"
)
.
run
();
}
}
catch
(
IllegalStateException
ex
)
{
catch
(
IllegalStateException
ex
)
{
if
(
serverNotRunning
(
ex
))
{
if
(
serverNotRunning
(
ex
))
{
...
...
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntryData.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -19,6 +19,7 @@ package org.springframework.boot.loader.jar;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.loader.jar;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.SoftReference
;
import
java.util.Calendar
;
import
java.util.GregorianCalendar
;
import
java.util.GregorianCalendar
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
...
@@ -31,6 +32,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
...
@@ -31,6 +32,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
* the entry is actually needed.
* the entry is actually needed.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
*/
*/
public
final
class
JarEntryData
{
public
final
class
JarEntryData
{
...
@@ -146,20 +148,27 @@ public final class JarEntryData {
...
@@ -146,20 +148,27 @@ public final class JarEntryData {
}
}
public
long
getTime
()
{
public
long
getTime
()
{
long
time
=
Bytes
.
littleEndianValue
(
this
.
header
,
12
,
2
);
int
seconds
=
(
int
)
((
time
<<
1
)
&
0x3E
);
int
minutes
=
(
int
)
((
time
>>
5
)
&
0x3F
);
int
hours
=
(
int
)
((
time
>>
11
)
&
0x1F
);
long
date
=
Bytes
.
littleEndianValue
(
this
.
header
,
14
,
2
);
long
date
=
Bytes
.
littleEndianValue
(
this
.
header
,
14
,
2
);
long
time
=
Bytes
.
littleEndianValue
(
this
.
header
,
12
,
2
);
return
decodeMsDosFormatDateTime
(
date
,
time
).
getTimeInMillis
();
}
int
day
=
(
int
)
(
date
&
0x1F
);
/**
int
month
=
(
int
)
((
date
>>
5
)
&
0xF
)
-
1
;
* Decode MSDOS Date Time details. See <a
* href="http://mindprod.com/jgloss/zip.html">mindprod.com/jgloss/zip.html</a> for
* more details of the format.
* @param date the date part
* @param time the time part
* @return a {@link Calendar} containing the decoded date.
*/
private
Calendar
decodeMsDosFormatDateTime
(
long
date
,
long
time
)
{
int
year
=
(
int
)
((
date
>>
9
)
&
0x7F
)
+
1980
;
int
year
=
(
int
)
((
date
>>
9
)
&
0x7F
)
+
1980
;
int
month
=
(
int
)
((
date
>>
5
)
&
0xF
)
-
1
;
return
new
GregorianCalendar
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
)
int
day
=
(
int
)
(
date
&
0x1F
);
.
getTimeInMillis
();
int
hours
=
(
int
)
((
time
>>
11
)
&
0x1F
);
int
minutes
=
(
int
)
((
time
>>
5
)
&
0x3F
);
int
seconds
=
(
int
)
((
time
<<
1
)
&
0x3E
);
return
new
GregorianCalendar
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
);
}
}
public
long
getCrc
()
{
public
long
getCrc
()
{
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java
View file @
968b68c3
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
...
spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java
View file @
968b68c3
...
@@ -121,16 +121,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
...
@@ -121,16 +121,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
.
contains
(
source
.
getName
())
&&
!
includes
.
matches
(
propertyName
))
{
.
contains
(
source
.
getName
())
&&
!
includes
.
matches
(
propertyName
))
{
continue
;
continue
;
}
}
Object
value
=
null
;
Object
value
=
getEnumerableProperty
(
source
,
resolver
,
propertyName
);
try
{
value
=
resolver
.
getProperty
(
propertyName
,
Object
.
class
);
}
catch
(
RuntimeException
ex
)
{
// Probably could not resolve placeholders, ignore it here
if
(
value
==
null
)
{
value
=
source
.
getProperty
(
propertyName
);
}
}
if
(!
this
.
propertyValues
.
containsKey
(
propertyName
))
{
if
(!
this
.
propertyValues
.
containsKey
(
propertyName
))
{
this
.
propertyValues
.
put
(
propertyName
,
new
PropertyValue
(
propertyName
,
this
.
propertyValues
.
put
(
propertyName
,
new
PropertyValue
(
propertyName
,
value
));
value
));
...
@@ -139,6 +130,17 @@ public class PropertySourcesPropertyValues implements PropertyValues {
...
@@ -139,6 +130,17 @@ public class PropertySourcesPropertyValues implements PropertyValues {
}
}
}
}
private
Object
getEnumerableProperty
(
EnumerablePropertySource
<?>
source
,
PropertySourcesPropertyResolver
resolver
,
String
propertyName
)
{
try
{
return
resolver
.
getProperty
(
propertyName
,
Object
.
class
);
}
catch
(
RuntimeException
ex
)
{
// Probably could not resolve placeholders, ignore it here
return
source
.
getProperty
(
propertyName
);
}
}
private
void
processCompositePropertySource
(
CompositePropertySource
source
,
private
void
processCompositePropertySource
(
CompositePropertySource
source
,
PropertySourcesPropertyResolver
resolver
,
PropertySourcesPropertyResolver
resolver
,
PropertyNamePatternsMatcher
includes
,
Collection
<
String
>
exacts
)
{
PropertyNamePatternsMatcher
includes
,
Collection
<
String
>
exacts
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
968b68c3
...
@@ -387,15 +387,17 @@ public class ConfigFileApplicationListener implements
...
@@ -387,15 +387,17 @@ public class ConfigFileApplicationListener implements
.
getProperty
(
INCLUDE_PROFILES_PROPERTY
));
.
getProperty
(
INCLUDE_PROFILES_PROPERTY
));
}
}
}
}
StringBuilder
msg
=
new
StringBuilder
();
StringBuilder
msg
=
new
StringBuilder
();
msg
.
append
(
propertySource
==
null
?
"Skipped "
:
"Loaded "
);
msg
.
append
(
propertySource
==
null
?
"Skipped "
:
"Loaded "
);
msg
.
append
(
"config file "
);
msg
.
append
(
"config file "
);
msg
.
append
(
"'"
).
append
(
location
).
append
(
"' "
);
msg
.
append
(
"'"
).
append
(
location
).
append
(
"'"
);
msg
.
append
(
StringUtils
.
hasLength
(
profile
)
?
"for profile "
+
profile
:
" "
);
if
(
StringUtils
.
hasLength
(
profile
))
{
msg
.
append
(
resource
==
null
||
!
resource
.
exists
()
?
"resource not found"
:
""
);
msg
.
append
(
" for profile"
+
profile
);
}
if
(
resource
==
null
||
!
resource
.
exists
())
{
msg
.
append
(
" resource not found"
);
}
this
.
debug
.
add
(
msg
);
this
.
debug
.
add
(
msg
);
return
propertySource
;
return
propertySource
;
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesPropertyValuesTests.java
View file @
968b68c3
...
@@ -20,6 +20,7 @@ import java.util.ArrayList;
...
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -44,6 +45,7 @@ public class PropertySourcesPropertyValuesTests {
...
@@ -44,6 +45,7 @@ public class PropertySourcesPropertyValuesTests {
@Before
@Before
public
void
init
()
{
public
void
init
()
{
this
.
propertySources
.
addFirst
(
new
PropertySource
<
String
>(
"static"
,
"foo"
)
{
this
.
propertySources
.
addFirst
(
new
PropertySource
<
String
>(
"static"
,
"foo"
)
{
@Override
@Override
public
Object
getProperty
(
String
name
)
{
public
Object
getProperty
(
String
name
)
{
if
(
name
.
equals
(
getSource
()))
{
if
(
name
.
equals
(
getSource
()))
{
...
@@ -59,10 +61,8 @@ public class PropertySourcesPropertyValuesTests {
...
@@ -59,10 +61,8 @@ public class PropertySourcesPropertyValuesTests {
@Test
@Test
public
void
testTypesPreserved
()
{
public
void
testTypesPreserved
()
{
this
.
propertySources
.
replace
(
Map
<
String
,
Object
>
map
=
Collections
.<
String
,
Object
>
singletonMap
(
"name"
,
123
);
"map"
,
this
.
propertySources
.
replace
(
"map"
,
new
MapPropertySource
(
"map"
,
map
));
new
MapPropertySource
(
"map"
,
Collections
.<
String
,
Object
>
singletonMap
(
"name"
,
123
)));
PropertySourcesPropertyValues
propertyValues
=
new
PropertySourcesPropertyValues
(
PropertySourcesPropertyValues
propertyValues
=
new
PropertySourcesPropertyValues
(
this
.
propertySources
);
this
.
propertySources
);
assertEquals
(
123
,
propertyValues
.
getPropertyValues
()[
0
].
getValue
());
assertEquals
(
123
,
propertyValues
.
getPropertyValues
()[
0
].
getValue
());
...
@@ -123,6 +123,7 @@ public class PropertySourcesPropertyValuesTests {
...
@@ -123,6 +123,7 @@ public class PropertySourcesPropertyValuesTests {
@Test
@Test
public
void
testNonEnumeratedPlaceholder
()
{
public
void
testNonEnumeratedPlaceholder
()
{
this
.
propertySources
.
addFirst
(
new
PropertySource
<
String
>(
"another"
,
"baz"
)
{
this
.
propertySources
.
addFirst
(
new
PropertySource
<
String
>(
"another"
,
"baz"
)
{
@Override
@Override
public
Object
getProperty
(
String
name
)
{
public
Object
getProperty
(
String
name
)
{
if
(
name
.
equals
(
getSource
()))
{
if
(
name
.
equals
(
getSource
()))
{
...
@@ -179,10 +180,12 @@ public class PropertySourcesPropertyValuesTests {
...
@@ -179,10 +180,12 @@ public class PropertySourcesPropertyValuesTests {
TestBean
target
=
new
TestBean
();
TestBean
target
=
new
TestBean
();
DataBinder
binder
=
new
DataBinder
(
target
);
DataBinder
binder
=
new
DataBinder
(
target
);
this
.
propertySources
.
addFirst
(
new
PropertySource
<
Object
>(
"application"
,
"STUFF"
)
{
this
.
propertySources
.
addFirst
(
new
PropertySource
<
Object
>(
"application"
,
"STUFF"
)
{
@Override
@Override
public
Object
getProperty
(
String
name
)
{
public
Object
getProperty
(
String
name
)
{
return
new
Object
();
return
new
Object
();
}
}
});
});
binder
.
bind
(
new
PropertySourcesPropertyValues
(
this
.
propertySources
,
binder
.
bind
(
new
PropertySourcesPropertyValues
(
this
.
propertySources
,
(
Collection
<
String
>)
null
,
Collections
.
singleton
(
"name"
)));
(
Collection
<
String
>)
null
,
Collections
.
singleton
(
"name"
)));
...
...
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