Skip to content

Commit 102dc8a

Browse files
committed
Polishing
1 parent 19e5a34 commit 102dc8a

File tree

10 files changed

+110
-106
lines changed

10 files changed

+110
-106
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
public interface CacheOperationInvoker {
3232

3333
/**
34-
* Invoke the cache operation defined by this instance. Wraps any
35-
* exception that is thrown during the invocation in a
36-
* {@link ThrowableWrapper}.
34+
* Invoke the cache operation defined by this instance. Wraps any exception
35+
* that is thrown during the invocation in a {@link ThrowableWrapper}.
3736
* @return the result of the operation
3837
* @throws ThrowableWrapper if an error occurred while invoking the operation
3938
*/

spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
3333
* Update the message digest with the rest of the bytes in this stream.
3434
* <p>Using this method is more optimized since it avoids creating new
3535
* byte arrays for each call.
36-
* @param messageDigest The message digest to update
36+
* @param messageDigest the message digest to update
3737
* @throws IOException when propagated from {@link #read()}
3838
*/
3939
public void updateMessageDigest(MessageDigest messageDigest) throws IOException {
@@ -47,7 +47,7 @@ public void updateMessageDigest(MessageDigest messageDigest) throws IOException
4747
* Update the message digest with the next len bytes in this stream.
4848
* <p>Using this method is more optimized since it avoids creating new
4949
* byte arrays for each call.
50-
* @param messageDigest The message digest to update
50+
* @param messageDigest the message digest to update
5151
* @param len how many bytes to read from this stream and use to update the message digest
5252
* @throws IOException when propagated from {@link #read()}
5353
*/

spring-core/src/main/java/org/springframework/util/concurrent/FutureAdapter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -24,10 +24,9 @@
2424
import org.springframework.util.Assert;
2525

2626
/**
27-
* Abstract class that adapts a {@link Future} parameterized over S into a {@code
28-
* Future} parameterized over T. All methods are delegated to the adaptee, where {@link
29-
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
30-
* result.
27+
* Abstract class that adapts a {@link Future} parameterized over S into a {@code Future}
28+
* parameterized over T. All methods are delegated to the adaptee, where {@link #get()}
29+
* and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's result.
3130
*
3231
* @author Arjen Poutsma
3332
* @since 4.0

spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java

Lines changed: 74 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,67 @@ public void unboxBooleanIfNecessary(MethodVisitor mv) {
147147
}
148148
}
149149

150+
/**
151+
* Called after the main expression evaluation method has been generated, this
152+
* method will callback any registered FieldAdders or ClinitAdders to add any
153+
* extra information to the class representing the compiled expression.
154+
*/
155+
public void finish() {
156+
if (this.fieldAdders != null) {
157+
for (FieldAdder fieldAdder : this.fieldAdders) {
158+
fieldAdder.generateField(cw,this);
159+
}
160+
}
161+
if (this.clinitAdders != null) {
162+
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
163+
mv.visitCode();
164+
this.nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
165+
for (ClinitAdder clinitAdder : this.clinitAdders) {
166+
clinitAdder.generateCode(mv, this);
167+
}
168+
mv.visitInsn(RETURN);
169+
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
170+
mv.visitEnd();
171+
}
172+
}
173+
174+
/**
175+
* Register a FieldAdder which will add a new field to the generated
176+
* class to support the code produced by an ast nodes primary
177+
* generateCode() method.
178+
*/
179+
public void registerNewField(FieldAdder fieldAdder) {
180+
if (this.fieldAdders == null) {
181+
this.fieldAdders = new ArrayList<>();
182+
}
183+
this.fieldAdders.add(fieldAdder);
184+
}
185+
186+
/**
187+
* Register a ClinitAdder which will add code to the static
188+
* initializer in the generated class to support the code
189+
* produced by an ast nodes primary generateCode() method.
190+
*/
191+
public void registerNewClinit(ClinitAdder clinitAdder) {
192+
if (this.clinitAdders == null) {
193+
this.clinitAdders = new ArrayList<>();
194+
}
195+
this.clinitAdders.add(clinitAdder);
196+
}
197+
198+
public int nextFieldId() {
199+
return this.nextFieldId++;
200+
}
201+
202+
public int nextFreeVariableId() {
203+
return this.nextFreeVariableId++;
204+
}
205+
206+
public String getClassName() {
207+
return this.clazzName;
208+
}
209+
210+
150211
/**
151212
* Insert any necessary cast and value call to convert from a boxed type to a
152213
* primitive value
@@ -778,76 +839,6 @@ public static String[] toDescriptors(Class<?>[] types) {
778839
return descriptors;
779840
}
780841

781-
/**
782-
* Called after the main expression evaluation method has been generated, this
783-
* method will callback any registered FieldAdders or ClinitAdders to add any
784-
* extra information to the class representing the compiled expression.
785-
*/
786-
public void finish() {
787-
if (fieldAdders != null) {
788-
for (FieldAdder fieldAdder: fieldAdders) {
789-
fieldAdder.generateField(cw,this);
790-
}
791-
}
792-
if (clinitAdders != null) {
793-
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
794-
mv.visitCode();
795-
nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
796-
for (ClinitAdder clinitAdder: clinitAdders) {
797-
clinitAdder.generateCode(mv, this);
798-
}
799-
mv.visitInsn(RETURN);
800-
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
801-
mv.visitEnd();
802-
}
803-
}
804-
805-
/**
806-
* Register a FieldAdder which will add a new field to the generated
807-
* class to support the code produced by an ast nodes primary
808-
* generateCode() method.
809-
*/
810-
public void registerNewField(FieldAdder fieldAdder) {
811-
if (fieldAdders == null) {
812-
fieldAdders = new ArrayList<>();
813-
}
814-
fieldAdders.add(fieldAdder);
815-
}
816-
817-
/**
818-
* Register a ClinitAdder which will add code to the static
819-
* initializer in the generated class to support the code
820-
* produced by an ast nodes primary generateCode() method.
821-
*/
822-
public void registerNewClinit(ClinitAdder clinitAdder) {
823-
if (clinitAdders == null) {
824-
clinitAdders = new ArrayList<>();
825-
}
826-
clinitAdders.add(clinitAdder);
827-
}
828-
829-
public int nextFieldId() {
830-
return nextFieldId++;
831-
}
832-
833-
public int nextFreeVariableId() {
834-
return nextFreeVariableId++;
835-
}
836-
837-
public String getClassname() {
838-
return clazzName;
839-
}
840-
841-
@FunctionalInterface
842-
public interface FieldAdder {
843-
void generateField(ClassWriter cw, CodeFlow codeflow);
844-
}
845-
846-
@FunctionalInterface
847-
public interface ClinitAdder {
848-
void generateCode(MethodVisitor mv, CodeFlow codeflow);
849-
}
850-
851842
/**
852843
* Create the optimal instruction for loading a number on the stack.
853844
* @param mv where to insert the bytecode
@@ -979,4 +970,17 @@ public static void insertNumericUnboxOrPrimitiveTypeCoercion(
979970
}
980971

981972

973+
@FunctionalInterface
974+
public interface FieldAdder {
975+
976+
void generateField(ClassWriter cw, CodeFlow codeflow);
977+
}
978+
979+
980+
@FunctionalInterface
981+
public interface ClinitAdder {
982+
983+
void generateCode(MethodVisitor mv, CodeFlow codeflow);
984+
}
985+
982986
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public boolean isCompilable() {
132132

133133
@Override
134134
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
135-
final String constantFieldName = "inlineList$"+codeflow.nextFieldId();
136-
final String clazzname = codeflow.getClassname();
135+
final String constantFieldName = "inlineList$" + codeflow.nextFieldId();
136+
final String className = codeflow.getClassName();
137137

138138
codeflow.registerNewField(new CodeFlow.FieldAdder() {
139139
public void generateField(ClassWriter cw, CodeFlow codeflow) {
@@ -143,11 +143,11 @@ public void generateField(ClassWriter cw, CodeFlow codeflow) {
143143

144144
codeflow.registerNewClinit(new CodeFlow.ClinitAdder() {
145145
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
146-
generateClinitCode(clazzname,constantFieldName, mv,codeflow,false);
146+
generateClinitCode(className, constantFieldName, mv, codeflow, false);
147147
}
148148
});
149149

150-
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
150+
mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;");
151151
codeflow.pushDescriptor("Ljava/util/List");
152152
}
153153

@@ -158,8 +158,8 @@ void generateClinitCode(String clazzname, String constantFieldName, MethodVisito
158158
if (!nested) {
159159
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
160160
}
161-
int childcount = getChildCount();
162-
for (int c=0; c < childcount; c++) {
161+
int childCount = getChildCount();
162+
for (int c = 0; c < childCount; c++) {
163163
if (!nested) {
164164
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
165165
}

spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestExecution.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@
2323
/**
2424
* Represents the context of a client-side HTTP request execution.
2525
*
26-
* <p>Used to invoke the next interceptor in the interceptor chain, or - if the calling interceptor is last - execute
27-
* the request itself.
26+
* <p>Used to invoke the next interceptor in the interceptor chain,
27+
* or - if the calling interceptor is last - execute the request itself.
2828
*
2929
* @author Arjen Poutsma
30-
* @see ClientHttpRequestInterceptor
3130
* @since 3.1
31+
* @see ClientHttpRequestInterceptor
3232
*/
3333
@FunctionalInterface
3434
public interface ClientHttpRequestExecution {
3535

3636
/**
37-
* Execute the request with the given request attributes and body, and return the response.
38-
*
37+
* Execute the request with the given request attributes and body,
38+
* and return the response.
3939
* @param request the request, containing method, URI, and headers
4040
* @param body the body of the request to execute
4141
* @return the response
4242
* @throws IOException in case of I/O errors
4343
*/
4444
ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException;
45+
4546
}

spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -51,8 +51,8 @@
5151
public interface LocaleResolver {
5252

5353
/**
54-
* Resolve the current locale via the given request. Can return a default locale as
55-
* fallback in any case.
54+
* Resolve the current locale via the given request.
55+
* Can return a default locale as fallback in any case.
5656
* @param request the request to resolve the locale for
5757
* @return the current locale (never {@code null})
5858
*/
@@ -63,8 +63,8 @@ public interface LocaleResolver {
6363
* @param request the request to be used for locale modification
6464
* @param response the response to be used for locale modification
6565
* @param locale the new locale, or {@code null} to clear the locale
66-
* @throws UnsupportedOperationException if the LocaleResolver implementation does not
67-
* support dynamic changing of the locale
66+
* @throws UnsupportedOperationException if the LocaleResolver
67+
* implementation does not support dynamic changing of the locale
6868
*/
6969
void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale);
7070

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -23,7 +23,7 @@
2323
import org.springframework.web.servlet.ModelAndView;
2424

2525
/**
26-
* Abstract adapter class for the HandlerInterceptor interface,
26+
* Abstract adapter class for the {@link AsyncHandlerInterceptor} interface,
2727
* for simplified implementation of pre-only/post-only interceptors.
2828
*
2929
* @author Juergen Hoeller
@@ -36,7 +36,8 @@ public abstract class HandlerInterceptorAdapter implements AsyncHandlerIntercept
3636
*/
3737
@Override
3838
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
39-
throws Exception {
39+
throws Exception {
40+
4041
return true;
4142
}
4243

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,17 @@ public Resource transform(HttpServletRequest request, Resource resource, Resourc
123123

124124
private boolean hasScheme(String link) {
125125
int schemeIndex = link.indexOf(":");
126-
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"))
127-
|| link.indexOf("//") == 0;
126+
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0;
128127
}
129128

130129

131130
@FunctionalInterface
132131
protected interface CssLinkParser {
133132

134133
void parseLink(String content, Set<CssLinkInfo> linkInfos);
135-
136134
}
137135

136+
138137
protected static abstract class AbstractCssLinkParser implements CssLinkParser {
139138

140139
/**
@@ -190,6 +189,7 @@ protected int addLink(int index, String endKey, String content, Set<CssLinkInfo>
190189

191190
}
192191

192+
193193
private static class ImportStatementCssLinkParser extends AbstractCssLinkParser {
194194

195195
@Override
@@ -209,6 +209,7 @@ else if (logger.isErrorEnabled()) {
209209
}
210210
}
211211

212+
212213
private static class UrlFunctionCssLinkParser extends AbstractCssLinkParser {
213214

214215
@Override
@@ -230,8 +231,7 @@ private static class CssLinkInfo implements Comparable<CssLinkInfo> {
230231

231232
private final int end;
232233

233-
234-
private CssLinkInfo(int start, int end) {
234+
public CssLinkInfo(int start, int end) {
235235
this.start = start;
236236
this.end = end;
237237
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public interface ResourceTransformer {
3636
* @param request the current request
3737
* @param resource the resource to transform
3838
* @param transformerChain the chain of remaining transformers to delegate to
39-
* @return the transformed resource, never {@code null}
39+
* @return the transformed resource (never {@code null})
4040
* @throws IOException if the transformation fails
4141
*/
4242
Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
4343
throws IOException;
4444

45-
}
45+
}

0 commit comments

Comments
 (0)