Skip to content

Commit d1241e1

Browse files
committed
Polishing
(cherry picked from commit f010368)
1 parent 4525d38 commit d1241e1

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

spring-beans/src/main/java/org/springframework/beans/propertyeditors/URIEditor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -119,7 +119,7 @@ public void setAsText(String text) throws IllegalArgumentException {
119119
setValue(createURI(uri));
120120
}
121121
catch (URISyntaxException ex) {
122-
throw new IllegalArgumentException("Invalid URI syntax: " + ex);
122+
throw new IllegalArgumentException("Invalid URI syntax: " + ex.getMessage());
123123
}
124124
}
125125
}

spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -210,18 +210,18 @@ else if (logger.isDebugEnabled()) {
210210
}
211211

212212
@Override
213-
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage)
213+
public Object read(Type type, @Nullable Class<?> contextClass, HttpInputMessage inputMessage)
214214
throws IOException, HttpMessageNotReadableException {
215215

216-
JavaType javaType = getJavaType(clazz, null);
216+
JavaType javaType = getJavaType(type, contextClass);
217217
return readJavaType(javaType, inputMessage);
218218
}
219219

220220
@Override
221-
public Object read(Type type, @Nullable Class<?> contextClass, HttpInputMessage inputMessage)
221+
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage)
222222
throws IOException, HttpMessageNotReadableException {
223223

224-
JavaType javaType = getJavaType(type, contextClass);
224+
JavaType javaType = getJavaType(clazz, null);
225225
return readJavaType(javaType, inputMessage);
226226
}
227227

spring-web/src/main/java/org/springframework/http/converter/json/AbstractJsonHttpMessageConverter.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,6 +50,9 @@
5050
*/
5151
public abstract class AbstractJsonHttpMessageConverter extends AbstractGenericHttpMessageConverter<Object> {
5252

53+
/**
54+
* The default charset used by the converter.
55+
*/
5356
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
5457

5558
@Nullable
@@ -111,15 +114,15 @@ private Object readResolved(Type resolvedType, HttpInputMessage inputMessage)
111114
}
112115

113116
@Override
114-
protected final void writeInternal(Object o, @Nullable Type type, HttpOutputMessage outputMessage)
117+
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
115118
throws IOException, HttpMessageNotWritableException {
116119

117120
Writer writer = getWriter(outputMessage);
118121
if (this.jsonPrefix != null) {
119122
writer.append(this.jsonPrefix);
120123
}
121124
try {
122-
writeInternal(o, type, writer);
125+
writeInternal(object, type, writer);
123126
}
124127
catch (Exception ex) {
125128
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
@@ -139,12 +142,12 @@ protected final void writeInternal(Object o, @Nullable Type type, HttpOutputMess
139142

140143
/**
141144
* Template method that writes the JSON-bound object to the given {@link Writer}.
142-
* @param o the object to write to the output message
145+
* @param object the object to write to the output message
143146
* @param type the type of object to write (may be {@code null})
144147
* @param writer the {@code} Writer to use
145148
* @throws Exception in case of write failures
146149
*/
147-
protected abstract void writeInternal(Object o, @Nullable Type type, Writer writer) throws Exception;
150+
protected abstract void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception;
148151

149152

150153
private static Reader getReader(HttpInputMessage inputMessage) throws IOException {

spring-web/src/main/java/org/springframework/http/converter/json/GsonHttpMessageConverter.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,17 +93,17 @@ protected Object readInternal(Type resolvedType, Reader reader) throws Exception
9393
}
9494

9595
@Override
96-
protected void writeInternal(Object o, @Nullable Type type, Writer writer) throws Exception {
96+
protected void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception {
9797
// In Gson, toJson with a type argument will exclusively use that given type,
9898
// ignoring the actual type of the object... which might be more specific,
9999
// e.g. a subclass of the specified type which includes additional fields.
100100
// As a consequence, we're only passing in parameterized type declarations
101101
// which might contain extra generics that the object instance doesn't retain.
102102
if (type instanceof ParameterizedType) {
103-
getGson().toJson(o, type, writer);
103+
getGson().toJson(object, type, writer);
104104
}
105105
else {
106-
getGson().toJson(o, writer);
106+
getGson().toJson(object, writer);
107107
}
108108
}
109109

spring-web/src/main/java/org/springframework/http/converter/json/JsonbHttpMessageConverter.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -100,12 +100,12 @@ protected Object readInternal(Type resolvedType, Reader reader) throws Exception
100100
}
101101

102102
@Override
103-
protected void writeInternal(Object o, @Nullable Type type, Writer writer) throws Exception {
103+
protected void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception {
104104
if (type instanceof ParameterizedType) {
105-
getJsonb().toJson(o, type, writer);
105+
getJsonb().toJson(object, type, writer);
106106
}
107107
else {
108-
getJsonb().toJson(o, writer);
108+
getJsonb().toJson(object, writer);
109109
}
110110
}
111111

0 commit comments

Comments
 (0)