Polishing

This commit is contained in:
Juergen Hoeller
2018-09-17 14:39:54 +02:00
parent 702d533e6f
commit 5ca2c56cf0
10 changed files with 79 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class StringLiteral extends Literal {
public StringLiteral(String payload, int pos, String value) { public StringLiteral(String payload, int pos, String value) {
super(payload,pos); super(payload, pos);
value = value.substring(1, value.length() - 1); value = value.substring(1, value.length() - 1);
this.value = new TypedValue(value.replaceAll("''", "'").replaceAll("\"\"", "\"")); this.value = new TypedValue(value.replaceAll("''", "'").replaceAll("\"\"", "\""));
this.exitTypeDescriptor = "Ljava/lang/String"; this.exitTypeDescriptor = "Ljava/lang/String";

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -132,9 +132,9 @@ public class SpelCompiler implements Opcodes {
@Nullable @Nullable
private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl expressionToCompile) { private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl expressionToCompile) {
// Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression' // Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression'
String clazzName = "spel/Ex" + getNextSuffix(); String className = "spel/Ex" + getNextSuffix();
ClassWriter cw = new ExpressionClassWriter(); ClassWriter cw = new ExpressionClassWriter();
cw.visit(V1_5, ACC_PUBLIC, clazzName, null, "org/springframework/expression/spel/CompiledExpression", null); cw.visit(V1_5, ACC_PUBLIC, className, null, "org/springframework/expression/spel/CompiledExpression", null);
// Create default constructor // Create default constructor
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
@@ -152,7 +152,7 @@ public class SpelCompiler implements Opcodes {
new String[ ]{"org/springframework/expression/EvaluationException"}); new String[ ]{"org/springframework/expression/EvaluationException"});
mv.visitCode(); mv.visitCode();
CodeFlow cf = new CodeFlow(clazzName, cw); CodeFlow cf = new CodeFlow(className, cw);
// Ask the expression AST to generate the body of the method // Ask the expression AST to generate the body of the method
try { try {
@@ -181,7 +181,7 @@ public class SpelCompiler implements Opcodes {
byte[] data = cw.toByteArray(); byte[] data = cw.toByteArray();
// TODO need to make this conditionally occur based on a debug flag // TODO need to make this conditionally occur based on a debug flag
// dump(expressionToCompile.toStringAST(), clazzName, data); // dump(expressionToCompile.toStringAST(), clazzName, data);
return loadClass(clazzName.replaceAll("/", "."), data); return loadClass(className.replaceAll("/", "."), data);
} }
/** /**
@@ -256,12 +256,12 @@ public class SpelCompiler implements Opcodes {
} }
int getClassesDefinedCount() { int getClassesDefinedCount() {
return classesDefinedCount; return this.classesDefinedCount;
} }
public Class<?> defineClass(String name, byte[] bytes) { public Class<?> defineClass(String name, byte[] bytes) {
Class<?> clazz = super.defineClass(name, bytes, 0, bytes.length); Class<?> clazz = super.defineClass(name, bytes, 0, bytes.length);
classesDefinedCount++; this.classesDefinedCount++;
return clazz; return clazz;
} }
} }

View File

@@ -199,8 +199,8 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
@Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) {
if (this.encoder instanceof HttpMessageEncoder) { if (this.encoder instanceof HttpMessageEncoder) {
HttpMessageEncoder<?> httpEncoder = (HttpMessageEncoder<?>) this.encoder; HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder;
return httpEncoder.getEncodeHints(actualType, elementType, mediaType, request, response); return encoder.getEncodeHints(actualType, elementType, mediaType, request, response);
} }
return Collections.emptyMap(); return Collections.emptyMap();
} }

View File

@@ -1,11 +1,11 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@@ -63,13 +63,13 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
private static final List<String> SAFE_METHODS = Arrays.asList("GET", "HEAD"); private static final List<String> SAFE_METHODS = Arrays.asList("GET", "HEAD");
/** /**
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match" * Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">Section 2.3 of RFC 7232</a> * @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">Section 2.3 of RFC 7232</a>
*/ */
private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?"); private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?");
/** /**
* Date formats as specified in the HTTP RFC * Date formats as specified in the HTTP RFC.
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a> * @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
*/ */
private static final String[] DATE_FORMATS = new String[] { private static final String[] DATE_FORMATS = new String[] {

View File

@@ -310,10 +310,10 @@ public class DefaultServerWebExchange implements ServerWebExchange {
} }
// We will perform this validation... // We will perform this validation...
etag = padEtagIfNecessary(etag); etag = padEtagIfNecessary(etag);
for (String clientETag : ifNoneMatch) { for (String clientEtag : ifNoneMatch) {
// Compare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3 // Compare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3
if (StringUtils.hasLength(clientETag) && if (StringUtils.hasLength(clientEtag) &&
clientETag.replaceFirst("^W/", "").equals(etag.replaceFirst("^W/", ""))) { clientEtag.replaceFirst("^W/", "").equals(etag.replaceFirst("^W/", ""))) {
this.notModified = true; this.notModified = true;
break; break;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Unit tests for {@link ServerSentEventHttpMessageReader}.
*
* @author Sebastien Deleuze * @author Sebastien Deleuze
*/ */
public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAllocatingTestCase { public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAllocatingTestCase {
@@ -42,24 +44,21 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAll
@Test @Test
public void cantRead() { public void cantRead() {
assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("foo", "bar")));
new MediaType("foo", "bar")));
assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), null)); assertFalse(messageReader.canRead(ResolvableType.forClass(Object.class), null));
} }
@Test @Test
public void canRead() { public void canRead() {
assertTrue(messageReader.canRead(ResolvableType.forClass(Object.class), assertTrue(messageReader.canRead(ResolvableType.forClass(Object.class), new MediaType("text", "event-stream")));
new MediaType("text", "event-stream"))); assertTrue(messageReader.canRead(ResolvableType.forClass(ServerSentEvent.class), new MediaType("foo", "bar")));
assertTrue(messageReader.canRead(ResolvableType.forClass(ServerSentEvent.class),
new MediaType("foo", "bar")));
} }
@Test @Test
public void readServerSentEvents() { public void readServerSentEvents() {
MockServerHttpRequest request = MockServerHttpRequest.post("/").body( MockServerHttpRequest request = MockServerHttpRequest.post("/").body(
"id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n" + "id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n" +
"id:c43\nevent:bar\nretry:456\ndata:baz\n\n"); "id:c43\nevent:bar\nretry:456\ndata:baz\n\n");
Flux<ServerSentEvent> events = this.messageReader Flux<ServerSentEvent> events = this.messageReader
.read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class), .read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class),

View File

@@ -41,6 +41,7 @@ import static org.springframework.core.ResolvableType.*;
/** /**
* Unit tests for {@link ServerSentEventHttpMessageWriter}. * Unit tests for {@link ServerSentEventHttpMessageWriter}.
*
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
@@ -48,14 +49,12 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
private static final Map<String, Object> HINTS = Collections.emptyMap(); private static final Map<String, Object> HINTS = Collections.emptyMap();
private ServerSentEventHttpMessageWriter messageWriter = private ServerSentEventHttpMessageWriter messageWriter =
new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder()); new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder());
@Test @Test
public void canWrite() { public void canWrite() {
assertTrue(this.messageWriter.canWrite(forClass(Object.class), null)); assertTrue(this.messageWriter.canWrite(forClass(Object.class), null));
assertFalse(this.messageWriter.canWrite(forClass(Object.class), new MediaType("foo", "bar"))); assertFalse(this.messageWriter.canWrite(forClass(Object.class), new MediaType("foo", "bar")));
@@ -69,7 +68,6 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
@Test @Test
public void writeServerSentEvent() { public void writeServerSentEvent() {
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo") ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo")
.comment("bla\nbla bla\nbla bla bla").retry(Duration.ofMillis(123L)).build(); .comment("bla\nbla bla\nbla bla bla").retry(Duration.ofMillis(123L)).build();
@@ -134,7 +132,6 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
@Test // SPR-14899 @Test // SPR-14899
public void writePojoWithPrettyPrint() { public void writePojoWithPrettyPrint() {
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build(); ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
this.messageWriter = new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder(mapper)); this.messageWriter = new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder(mapper));
@@ -172,8 +169,8 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
testWrite(source, MediaType.TEXT_EVENT_STREAM, response, clazz); testWrite(source, MediaType.TEXT_EVENT_STREAM, response, clazz);
} }
private <T> void testWrite(Publisher<T> source, MediaType mediaType, MockServerHttpResponse response, private <T> void testWrite(
Class<T> clazz) { Publisher<T> source, MediaType mediaType, MockServerHttpResponse response, Class<T> clazz) {
this.messageWriter.write(source, forClass(clazz), mediaType, response, HINTS) this.messageWriter.write(source, forClass(clazz), mediaType, response, HINTS)
.block(Duration.ofMillis(5000)); .block(Duration.ofMillis(5000));

View File

@@ -88,7 +88,7 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
* </tr> * </tr>
* <tr class="altColor"> * <tr class="altColor">
* <td><p>MissingServletRequestParameterException</p></td> * <td><p>MissingServletRequestParameterException</p></td>
* <td><p>500 (SC_INTERNAL_SERVER_ERROR)</p></td> * <td><p>400 (SC_BAD_REQUEST)</p></td>
* </tr> * </tr>
* <tr class="rowColor"> * <tr class="rowColor">
* <td><p>ServletRequestBindingException</p></td> * <td><p>ServletRequestBindingException</p></td>
@@ -364,7 +364,8 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
/** /**
* Handle the case when a {@link org.springframework.web.bind.WebDataBinder} conversion cannot occur. * Handle the case when a {@link org.springframework.web.bind.WebDataBinder} conversion cannot occur.
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}. * <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
* Alternatively, a fallback view could be chosen, or the TypeMismatchException could be rethrown as-is. * Alternatively, a fallback view could be chosen, or the ConversionNotSupportedException could be
* rethrown as-is.
* @param ex the ConversionNotSupportedException to be handled * @param ex the ConversionNotSupportedException to be handled
* @param request current HTTP request * @param request current HTTP request
* @param response current HTTP response * @param response current HTTP response
@@ -401,7 +402,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter} * Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
* cannot read from a HTTP request. * cannot read from a HTTP request.
* <p>The default implementation sends an HTTP 400 error, and returns an empty {@code ModelAndView}. * <p>The default implementation sends an HTTP 400 error, and returns an empty {@code ModelAndView}.
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could be * Alternatively, a fallback view could be chosen, or the HttpMessageNotReadableException could be
* rethrown as-is. * rethrown as-is.
* @param ex the HttpMessageNotReadableException to be handled * @param ex the HttpMessageNotReadableException to be handled
* @param request current HTTP request * @param request current HTTP request
@@ -422,7 +423,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converter} * {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
* cannot write to a HTTP request. * cannot write to a HTTP request.
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}. * <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could * Alternatively, a fallback view could be chosen, or the HttpMessageNotWritableException could
* be rethrown as-is. * be rethrown as-is.
* @param ex the HttpMessageNotWritableException to be handled * @param ex the HttpMessageNotWritableException to be handled
* @param request current HTTP request * @param request current HTTP request

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ import org.springframework.web.util.TagUtils;
import org.springframework.web.util.UriUtils; import org.springframework.web.util.UriUtils;
/** /**
* The {@code <url>} tag creates URLs. Modeled after the JSTL c:url tag with * The {@code <url>} tag creates URLs. Modeled after the JSTL {@code c:url} tag with
* backwards compatibility in mind. * backwards compatibility in mind.
* *
* <p>Enhancements to the JSTL functionality include: * <p>Enhancements to the JSTL functionality include:
@@ -76,56 +76,56 @@ import org.springframework.web.util.UriUtils;
* <caption>Attribute Summary</caption> * <caption>Attribute Summary</caption>
* <thead> * <thead>
* <tr> * <tr>
* <th class="colFirst">Attribute</th> * <th>Attribute</th>
* <th class="colOne">Required?</th> * <th>Required?</th>
* <th class="colOne">Runtime Expression?</th> * <th>Runtime Expression?</th>
* <th class="colLast">Description</th> * <th>Description</th>
* </tr> * </tr>
* </thead> * </thead>
* <tbody> * <tbody>
* <tr class="altColor"> * <tr>
* <td>value</p></td> * <td>value</td>
* <td>true</p></td> * <td>true</td>
* <td>true</p></td> * <td>true</td>
* <td>The URL to build. This value can include template {placeholders} that are * <td>The URL to build. This value can include template {placeholders} that are
* replaced with the URL encoded value of the named parameter. Parameters * replaced with the URL encoded value of the named parameter. Parameters
* must be defined using the param tag inside the body of this tag.</p></td> * must be defined using the param tag inside the body of this tag.</td>
* </tr> * </tr>
* <tr class="rowColor"> * <tr>
* <td>context</p></td> * <td>context</td>
* <td>false</p></td> * <td>false</td>
* <td>true</p></td> * <td>true</td>
* <td>Specifies a remote application context path. * <td>Specifies a remote application context path.
* The default is the current application context path.</p></td> * The default is the current application context path.</td>
* </tr> * </tr>
* <tr class="altColor"> * <tr>
* <td>var</p></td> * <td>var</td>
* <td>false</p></td> * <td>false</td>
* <td>true</p></td> * <td>true</td>
* <td>The name of the variable to export the URL value to. * <td>The name of the variable to export the URL value to.
* If not specified the URL is written as output.</p></td> * If not specified the URL is written as output.</td>
* </tr> * </tr>
* <tr class="rowColor"> * <tr>
* <td>scope</p></td> * <td>scope</td>
* <td>false</p></td> * <td>false</td>
* <td>true</p></td> * <td>true</td>
* <td>The scope for the var. 'application', 'session', 'request' and 'page' * <td>The scope for the var. 'application', 'session', 'request' and 'page'
* scopes are supported. Defaults to page scope. This attribute has no * scopes are supported. Defaults to page scope. This attribute has no
* effect unless the var attribute is also defined.</p></td> * effect unless the var attribute is also defined.</td>
* </tr> * </tr>
* <tr class="altColor"> * <tr>
* <td>htmlEscape</p></td> * <td>htmlEscape</td>
* <td>false</p></td> * <td>false</td>
* <td>true</p></td> * <td>true</td>
* <td>Set HTML escaping for this tag, as a boolean value. Overrides the * <td>Set HTML escaping for this tag, as a boolean value. Overrides the
* default HTML escaping setting for the current page.</p></td> * default HTML escaping setting for the current page.</td>
* </tr> * </tr>
* <tr class="rowColor"> * <tr>
* <td>javaScriptEscape</p></td> * <td>javaScriptEscape</td>
* <td>false</p></td> * <td>false</td>
* <td>true</p></td> * <td>true</td>
* <td>Set JavaScript escaping for this tag, as a boolean value. * <td>Set JavaScript escaping for this tag, as a boolean value.
* Default is false.</p></td> * Default is false.</td>
* </tr> * </tr>
* </tbody> * </tbody>
* </table> * </table>
@@ -166,7 +166,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
/** /**
* Sets the value of the URL * Sets the value of the URL.
*/ */
public void setValue(String value) { public void setValue(String value) {
if (value.contains(URL_TYPE_ABSOLUTE)) { if (value.contains(URL_TYPE_ABSOLUTE)) {
@@ -245,7 +245,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
if (this.var == null) { if (this.var == null) {
// print the url to the writer // print the url to the writer
try { try {
pageContext.getOut().print(url); this.pageContext.getOut().print(url);
} }
catch (IOException ex) { catch (IOException ex) {
throw new JspException(ex); throw new JspException(ex);
@@ -253,7 +253,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
} }
else { else {
// store the url as a variable // store the url as a variable
pageContext.setAttribute(var, url, scope); this.pageContext.setAttribute(this.var, url, this.scope);
} }
return EVAL_PAGE; return EVAL_PAGE;
} }
@@ -265,8 +265,8 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
*/ */
String createUrl() throws JspException { String createUrl() throws JspException {
Assert.state(this.value != null, "No value set"); Assert.state(this.value != null, "No value set");
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); HttpServletResponse response = (HttpServletResponse) this.pageContext.getResponse();
StringBuilder url = new StringBuilder(); StringBuilder url = new StringBuilder();
if (this.type == UrlType.CONTEXT_RELATIVE) { if (this.type == UrlType.CONTEXT_RELATIVE) {
@@ -317,7 +317,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
protected String createQueryString(List<Param> params, Set<String> usedParams, boolean includeQueryStringDelimiter) protected String createQueryString(List<Param> params, Set<String> usedParams, boolean includeQueryStringDelimiter)
throws JspException { throws JspException {
String encoding = pageContext.getResponse().getCharacterEncoding(); String encoding = this.pageContext.getResponse().getCharacterEncoding();
StringBuilder qs = new StringBuilder(); StringBuilder qs = new StringBuilder();
for (Param param : params) { for (Param param : params) {
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) { if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
@@ -354,14 +354,15 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
protected String replaceUriTemplateParams(String uri, List<Param> params, Set<String> usedParams) protected String replaceUriTemplateParams(String uri, List<Param> params, Set<String> usedParams)
throws JspException { throws JspException {
String encoding = pageContext.getResponse().getCharacterEncoding(); String encoding = this.pageContext.getResponse().getCharacterEncoding();
for (Param param : params) { for (Param param : params) {
String template = URL_TEMPLATE_DELIMITER_PREFIX + param.getName() + URL_TEMPLATE_DELIMITER_SUFFIX; String template = URL_TEMPLATE_DELIMITER_PREFIX + param.getName() + URL_TEMPLATE_DELIMITER_SUFFIX;
if (uri.contains(template)) { if (uri.contains(template)) {
usedParams.add(param.getName()); usedParams.add(param.getName());
String value = param.getValue(); String value = param.getValue();
try { try {
uri = uri.replace(template, (value != null ? UriUtils.encodePath(value, encoding) : "")); uri = uri.replace(template,
(value != null ? UriUtils.encodePath(value, encoding) : ""));
} }
catch (UnsupportedCharsetException ex) { catch (UnsupportedCharsetException ex) {
throw new JspException(ex); throw new JspException(ex);

View File

@@ -68,7 +68,7 @@ public class SockJsUrlInfo {
public String getSessionId() { public String getSessionId() {
if (this.sessionId == null) { if (this.sessionId == null) {
this.sessionId = getUuid().toString().replace("-",""); this.sessionId = getUuid().toString().replace("-", "");
} }
return this.sessionId; return this.sessionId;
} }