Skip to content

Commit 5ca2c56

Browse files
committed
Polishing
1 parent 702d533 commit 5ca2c56

File tree

10 files changed

+79
-81
lines changed

10 files changed

+79
-81
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -33,7 +33,7 @@ public class StringLiteral extends Literal {
3333

3434

3535
public StringLiteral(String payload, int pos, String value) {
36-
super(payload,pos);
36+
super(payload, pos);
3737
value = value.substring(1, value.length() - 1);
3838
this.value = new TypedValue(value.replaceAll("''", "'").replaceAll("\"\"", "\""));
3939
this.exitTypeDescriptor = "Ljava/lang/String";

spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -132,9 +132,9 @@ private int getNextSuffix() {
132132
@Nullable
133133
private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl expressionToCompile) {
134134
// Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression'
135-
String clazzName = "spel/Ex" + getNextSuffix();
135+
String className = "spel/Ex" + getNextSuffix();
136136
ClassWriter cw = new ExpressionClassWriter();
137-
cw.visit(V1_5, ACC_PUBLIC, clazzName, null, "org/springframework/expression/spel/CompiledExpression", null);
137+
cw.visit(V1_5, ACC_PUBLIC, className, null, "org/springframework/expression/spel/CompiledExpression", null);
138138

139139
// Create default constructor
140140
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
@@ -152,7 +152,7 @@ private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl e
152152
new String[ ]{"org/springframework/expression/EvaluationException"});
153153
mv.visitCode();
154154

155-
CodeFlow cf = new CodeFlow(clazzName, cw);
155+
CodeFlow cf = new CodeFlow(className, cw);
156156

157157
// Ask the expression AST to generate the body of the method
158158
try {
@@ -181,7 +181,7 @@ private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl e
181181
byte[] data = cw.toByteArray();
182182
// TODO need to make this conditionally occur based on a debug flag
183183
// dump(expressionToCompile.toStringAST(), clazzName, data);
184-
return loadClass(clazzName.replaceAll("/", "."), data);
184+
return loadClass(className.replaceAll("/", "."), data);
185185
}
186186

187187
/**
@@ -256,12 +256,12 @@ public ChildClassLoader(@Nullable ClassLoader classLoader) {
256256
}
257257

258258
int getClassesDefinedCount() {
259-
return classesDefinedCount;
259+
return this.classesDefinedCount;
260260
}
261261

262262
public Class<?> defineClass(String name, byte[] bytes) {
263263
Class<?> clazz = super.defineClass(name, bytes, 0, bytes.length);
264-
classesDefinedCount++;
264+
this.classesDefinedCount++;
265265
return clazz;
266266
}
267267
}

spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ private Map<String, Object> getEncodeHints(ResolvableType actualType, Resolvable
199199
@Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) {
200200

201201
if (this.encoder instanceof HttpMessageEncoder) {
202-
HttpMessageEncoder<?> httpEncoder = (HttpMessageEncoder<?>) this.encoder;
203-
return httpEncoder.getEncodeHints(actualType, elementType, mediaType, request, response);
202+
HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder;
203+
return encoder.getEncodeHints(actualType, elementType, mediaType, request, response);
204204
}
205205
return Collections.emptyMap();
206206
}

spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -63,13 +63,13 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
6363
private static final List<String> SAFE_METHODS = Arrays.asList("GET", "HEAD");
6464

6565
/**
66-
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match"
66+
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
6767
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">Section 2.3 of RFC 7232</a>
6868
*/
6969
private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?");
7070

7171
/**
72-
* Date formats as specified in the HTTP RFC
72+
* Date formats as specified in the HTTP RFC.
7373
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
7474
*/
7575
private static final String[] DATE_FORMATS = new String[] {

spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ private boolean validateIfNoneMatch(@Nullable String etag) {
310310
}
311311
// We will perform this validation...
312312
etag = padEtagIfNecessary(etag);
313-
for (String clientETag : ifNoneMatch) {
313+
for (String clientEtag : ifNoneMatch) {
314314
// Compare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3
315-
if (StringUtils.hasLength(clientETag) &&
316-
clientETag.replaceFirst("^W/", "").equals(etag.replaceFirst("^W/", ""))) {
315+
if (StringUtils.hasLength(clientEtag) &&
316+
clientEtag.replaceFirst("^W/", "").equals(etag.replaceFirst("^W/", ""))) {
317317
this.notModified = true;
318318
break;
319319
}

spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -32,6 +32,8 @@
3232
import static org.junit.Assert.*;
3333

3434
/**
35+
* Unit tests for {@link ServerSentEventHttpMessageReader}.
36+
*
3537
* @author Sebastien Deleuze
3638
*/
3739
public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAllocatingTestCase {
@@ -42,24 +44,21 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAll
4244

4345
@Test
4446
public void cantRead() {
45-
assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class),
46-
new MediaType("foo", "bar")));
47+
assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("foo", "bar")));
4748
assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), null));
4849
}
4950

5051
@Test
5152
public void canRead() {
52-
assertTrue(messageReader.canRead(ResolvableType.forClass(Object.class),
53-
new MediaType("text", "event-stream")));
54-
assertTrue(messageReader.canRead(ResolvableType.forClass(ServerSentEvent.class),
55-
new MediaType("foo", "bar")));
53+
assertTrue(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("text", "event-stream")));
54+
assertTrue(messageReader.canRead(ResolvableType.forClass(ServerSentEvent.class), new MediaType("foo", "bar")));
5655
}
5756

5857
@Test
5958
public void readServerSentEvents() {
6059
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(
6160
"id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n" +
62-
"id:c43\nevent:bar\nretry:456\ndata:baz\n\n");
61+
"id:c43\nevent:bar\nretry:456\ndata:baz\n\n");
6362

6463
Flux<ServerSentEvent> events = this.messageReader
6564
.read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class),

spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageWriterTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,20 @@
4141

4242
/**
4343
* Unit tests for {@link ServerSentEventHttpMessageWriter}.
44+
*
4445
* @author Sebastien Deleuze
4546
* @author Rossen Stoyanchev
4647
*/
4748
public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocatingTestCase {
4849

4950
private static final Map<String, Object> HINTS = Collections.emptyMap();
5051

51-
5252
private ServerSentEventHttpMessageWriter messageWriter =
5353
new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder());
5454

5555

5656
@Test
5757
public void canWrite() {
58-
5958
assertTrue(this.messageWriter.canWrite(forClass(Object.class), null));
6059
assertFalse(this.messageWriter.canWrite(forClass(Object.class), new MediaType("foo", "bar")));
6160

@@ -69,7 +68,6 @@ public void canWrite() {
6968

7069
@Test
7170
public void writeServerSentEvent() {
72-
7371
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo")
7472
.comment("bla\nbla bla\nbla bla bla").retry(Duration.ofMillis(123L)).build();
7573

@@ -134,7 +132,6 @@ public void writePojo() {
134132

135133
@Test // SPR-14899
136134
public void writePojoWithPrettyPrint() {
137-
138135
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
139136
this.messageWriter = new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder(mapper));
140137

@@ -172,8 +169,8 @@ private <T> void testWrite(Publisher<T> source, MockServerHttpResponse response,
172169
testWrite(source, MediaType.TEXT_EVENT_STREAM, response, clazz);
173170
}
174171

175-
private <T> void testWrite(Publisher<T> source, MediaType mediaType, MockServerHttpResponse response,
176-
Class<T> clazz) {
172+
private <T> void testWrite(
173+
Publisher<T> source, MediaType mediaType, MockServerHttpResponse response, Class<T> clazz) {
177174

178175
this.messageWriter.write(source, forClass(clazz), mediaType, response, HINTS)
179176
.block(Duration.ofMillis(5000));

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
* </tr>
8989
* <tr class="altColor">
9090
* <td><p>MissingServletRequestParameterException</p></td>
91-
* <td><p>500 (SC_INTERNAL_SERVER_ERROR)</p></td>
91+
* <td><p>400 (SC_BAD_REQUEST)</p></td>
9292
* </tr>
9393
* <tr class="rowColor">
9494
* <td><p>ServletRequestBindingException</p></td>
@@ -364,7 +364,8 @@ protected ModelAndView handleServletRequestBindingException(ServletRequestBindin
364364
/**
365365
* Handle the case when a {@link org.springframework.web.bind.WebDataBinder} conversion cannot occur.
366366
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
367-
* Alternatively, a fallback view could be chosen, or the TypeMismatchException could be rethrown as-is.
367+
* Alternatively, a fallback view could be chosen, or the ConversionNotSupportedException could be
368+
* rethrown as-is.
368369
* @param ex the ConversionNotSupportedException to be handled
369370
* @param request current HTTP request
370371
* @param response current HTTP response
@@ -401,7 +402,7 @@ protected ModelAndView handleTypeMismatch(TypeMismatchException ex,
401402
* Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
402403
* cannot read from a HTTP request.
403404
* <p>The default implementation sends an HTTP 400 error, and returns an empty {@code ModelAndView}.
404-
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could be
405+
* Alternatively, a fallback view could be chosen, or the HttpMessageNotReadableException could be
405406
* rethrown as-is.
406407
* @param ex the HttpMessageNotReadableException to be handled
407408
* @param request current HTTP request
@@ -422,7 +423,7 @@ protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableExcept
422423
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
423424
* cannot write to a HTTP request.
424425
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
425-
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could
426+
* Alternatively, a fallback view could be chosen, or the HttpMessageNotWritableException could
426427
* be rethrown as-is.
427428
* @param ex the HttpMessageNotWritableException to be handled
428429
* @param request current HTTP request

0 commit comments

Comments
 (0)