Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Sep 15, 2020
1 parent 3ec4538 commit f010368
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -119,7 +119,7 @@ public void setAsText(String text) throws IllegalArgumentException {
setValue(createURI(uri));
}
catch (URISyntaxException ex) {
throw new IllegalArgumentException("Invalid URI syntax: " + ex);
throw new IllegalArgumentException("Invalid URI syntax: " + ex.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,18 @@ else if (logger.isDebugEnabled()) {
}

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

JavaType javaType = getJavaType(clazz, null);
JavaType javaType = getJavaType(type, contextClass);
return readJavaType(javaType, inputMessage);
}

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

JavaType javaType = getJavaType(type, contextClass);
JavaType javaType = getJavaType(clazz, null);
return readJavaType(javaType, inputMessage);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -114,15 +114,15 @@ private Object readResolved(Type resolvedType, HttpInputMessage inputMessage)
}

@Override
protected final void writeInternal(Object o, @Nullable Type type, HttpOutputMessage outputMessage)
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {

Writer writer = getWriter(outputMessage);
if (this.jsonPrefix != null) {
writer.append(this.jsonPrefix);
}
try {
writeInternal(o, type, writer);
writeInternal(object, type, writer);
}
catch (Exception ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
Expand All @@ -142,12 +142,12 @@ protected final void writeInternal(Object o, @Nullable Type type, HttpOutputMess

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


private static Reader getReader(HttpInputMessage inputMessage) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -93,17 +93,17 @@ protected Object readInternal(Type resolvedType, Reader reader) throws Exception
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -101,12 +101,12 @@ protected Object readInternal(Type resolvedType, Reader reader) throws Exception
}

@Override
protected void writeInternal(Object o, @Nullable Type type, Writer writer) throws Exception {
protected void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception {
if (type instanceof ParameterizedType) {
getJsonb().toJson(o, type, writer);
getJsonb().toJson(object, type, writer);
}
else {
getJsonb().toJson(o, writer);
getJsonb().toJson(object, writer);
}
}

Expand Down

0 comments on commit f010368

Please sign in to comment.