Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
8b306df1
Commit
8b306df1
authored
Apr 20, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use @PropertySource instead of @Bean for http encoder properties
Protects us against changes in Spring Boot 1.4 where the naming convention changes.
parent
8a4fb82b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
27 deletions
+35
-27
CloudJacksonJson.java
...amework/cloud/netflix/eureka/server/CloudJacksonJson.java
+29
-17
EurekaServerConfiguration.java
...loud/netflix/eureka/server/EurekaServerConfiguration.java
+4
-10
server.properties
...eureka-server/src/main/resources/eureka/server.properties
+2
-0
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/CloudJacksonJson.java
View file @
8b306df1
...
...
@@ -42,26 +42,26 @@ public class CloudJacksonJson extends LegacyJacksonJson {
@Override
public
<
T
>
String
encode
(
T
object
)
throws
IOException
{
return
codec
.
writeToString
(
object
);
return
this
.
codec
.
writeToString
(
object
);
}
@Override
public
<
T
>
void
encode
(
T
object
,
OutputStream
outputStream
)
throws
IOException
{
codec
.
writeTo
(
object
,
outputStream
);
this
.
codec
.
writeTo
(
object
,
outputStream
);
}
@Override
public
<
T
>
T
decode
(
String
textValue
,
Class
<
T
>
type
)
throws
IOException
{
return
codec
.
readValue
(
type
,
textValue
);
return
this
.
codec
.
readValue
(
type
,
textValue
);
}
@Override
public
<
T
>
T
decode
(
InputStream
inputStream
,
Class
<
T
>
type
)
throws
IOException
{
return
codec
.
readValue
(
type
,
inputStream
);
return
this
.
codec
.
readValue
(
type
,
inputStream
);
}
static
class
CloudJacksonCodec
extends
EurekaJacksonCodec
{
private
static
final
Version
VERSION
=
new
Version
(
1
,
1
,
0
,
null
);
private
static
final
Version
VERSION
=
new
Version
(
1
,
1
,
0
,
null
,
null
,
null
);
@SuppressWarnings
(
"deprecation"
)
public
CloudJacksonCodec
()
{
...
...
@@ -74,26 +74,37 @@ public class CloudJacksonJson extends LegacyJacksonJson {
module
.
addSerializer
(
DataCenterInfo
.
class
,
new
DataCenterInfoSerializer
());
module
.
addSerializer
(
InstanceInfo
.
class
,
new
CloudInstanceInfoSerializer
());
module
.
addSerializer
(
Application
.
class
,
new
ApplicationSerializer
());
module
.
addSerializer
(
Applications
.
class
,
new
ApplicationsSerializer
(
this
.
getVersionDeltaKey
(),
this
.
getAppHashCodeKey
()));
module
.
addSerializer
(
Applications
.
class
,
new
ApplicationsSerializer
(
this
.
getVersionDeltaKey
(),
this
.
getAppHashCodeKey
()));
module
.
addDeserializer
(
DataCenterInfo
.
class
,
new
DataCenterInfoDeserializer
());
module
.
addDeserializer
(
DataCenterInfo
.
class
,
new
DataCenterInfoDeserializer
());
module
.
addDeserializer
(
LeaseInfo
.
class
,
new
LeaseInfoDeserializer
());
module
.
addDeserializer
(
InstanceInfo
.
class
,
new
CloudInstanceInfoDeserializer
(
mapper
));
module
.
addDeserializer
(
Application
.
class
,
new
ApplicationDeserializer
(
mapper
));
module
.
addDeserializer
(
Applications
.
class
,
new
ApplicationsDeserializer
(
mapper
,
this
.
getVersionDeltaKey
(),
this
.
getAppHashCodeKey
()));
module
.
addDeserializer
(
InstanceInfo
.
class
,
new
CloudInstanceInfoDeserializer
(
mapper
));
module
.
addDeserializer
(
Application
.
class
,
new
ApplicationDeserializer
(
mapper
));
module
.
addDeserializer
(
Applications
.
class
,
new
ApplicationsDeserializer
(
mapper
,
this
.
getVersionDeltaKey
(),
this
.
getAppHashCodeKey
()));
mapper
.
registerModule
(
module
);
HashMap
<
Class
<?>,
ObjectReader
>
readers
=
new
HashMap
<>();
readers
.
put
(
InstanceInfo
.
class
,
mapper
.
reader
().
withType
(
InstanceInfo
.
class
).
withRootName
(
"instance"
));
readers
.
put
(
Application
.
class
,
mapper
.
reader
().
withType
(
Application
.
class
).
withRootName
(
"application"
));
readers
.
put
(
Applications
.
class
,
mapper
.
reader
().
withType
(
Applications
.
class
).
withRootName
(
"applications"
));
readers
.
put
(
InstanceInfo
.
class
,
mapper
.
reader
().
withType
(
InstanceInfo
.
class
)
.
withRootName
(
"instance"
));
readers
.
put
(
Application
.
class
,
mapper
.
reader
().
withType
(
Application
.
class
)
.
withRootName
(
"application"
));
readers
.
put
(
Applications
.
class
,
mapper
.
reader
().
withType
(
Applications
.
class
)
.
withRootName
(
"applications"
));
setField
(
"objectReaderByClass"
,
readers
);
HashMap
<
Class
<?>,
ObjectWriter
>
writers
=
new
HashMap
<>();
writers
.
put
(
InstanceInfo
.
class
,
mapper
.
writer
().
withType
(
InstanceInfo
.
class
).
withRootName
(
"instance"
));
writers
.
put
(
Application
.
class
,
mapper
.
writer
().
withType
(
Application
.
class
).
withRootName
(
"application"
));
writers
.
put
(
Applications
.
class
,
mapper
.
writer
().
withType
(
Applications
.
class
).
withRootName
(
"applications"
));
writers
.
put
(
InstanceInfo
.
class
,
mapper
.
writer
().
withType
(
InstanceInfo
.
class
)
.
withRootName
(
"instance"
));
writers
.
put
(
Application
.
class
,
mapper
.
writer
().
withType
(
Application
.
class
)
.
withRootName
(
"application"
));
writers
.
put
(
Applications
.
class
,
mapper
.
writer
().
withType
(
Applications
.
class
)
.
withRootName
(
"applications"
));
setField
(
"objectWriterByClass"
,
writers
);
setField
(
"mapper"
,
mapper
);
...
...
@@ -108,7 +119,8 @@ public class CloudJacksonJson extends LegacyJacksonJson {
static
class
CloudInstanceInfoSerializer
extends
InstanceInfoSerializer
{
@Override
public
void
serialize
(
InstanceInfo
info
,
JsonGenerator
jgen
,
SerializerProvider
provider
)
throws
IOException
{
public
void
serialize
(
InstanceInfo
info
,
JsonGenerator
jgen
,
SerializerProvider
provider
)
throws
IOException
{
if
(
info
.
getInstanceId
()
==
null
&&
info
.
getMetadata
()
!=
null
)
{
String
instanceId
=
info
.
getMetadata
().
get
(
"instanceId"
);
...
...
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
View file @
8b306df1
...
...
@@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.web.HttpEncodingProperties
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.client.actuator.HasFeatures
;
...
...
@@ -42,6 +41,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ResourceLoader
;
...
...
@@ -71,6 +71,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
@Import
(
EurekaServerInitializerConfiguration
.
class
)
@EnableDiscoveryClient
@EnableConfigurationProperties
(
EurekaDashboardProperties
.
class
)
@PropertySource
(
"classpath:/eureka/server.properties"
)
public
class
EurekaServerConfiguration
extends
WebMvcConfigurerAdapter
{
/**
* List of packages containing Jersey resources required by the Eureka server
...
...
@@ -121,14 +122,6 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
}
}
// TODO: is there a better way?
@Bean
(
name
=
"spring.http.encoding.CONFIGURATION_PROPERTIES"
)
public
HttpEncodingProperties
httpEncodingProperties
()
{
HttpEncodingProperties
properties
=
new
HttpEncodingProperties
();
properties
.
setForce
(
false
);
return
properties
;
}
@Bean
@ConditionalOnProperty
(
prefix
=
"eureka.dashboard"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
public
EurekaController
eurekaController
()
{
...
...
@@ -148,7 +141,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
private
static
CodecWrapper
getFullXml
(
EurekaServerConfig
serverConfig
)
{
CodecWrapper
codec
=
CodecWrappers
.
getCodec
(
serverConfig
.
getXmlCodecName
());
return
codec
==
null
?
CodecWrappers
.
getCodec
(
CodecWrappers
.
XStreamXml
.
class
)
:
codec
;
return
codec
==
null
?
CodecWrappers
.
getCodec
(
CodecWrappers
.
XStreamXml
.
class
)
:
codec
;
}
class
CloudServerCodecs
extends
DefaultServerCodecs
{
...
...
spring-cloud-netflix-eureka-server/src/main/resources/eureka/server.properties
0 → 100644
View file @
8b306df1
spring.http.encoding.force
=
false
\ No newline at end of file
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