Avoid regex pattern matching for simple String replacement steps
Issue: SPR-17279
This commit is contained in:
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import java.util.UUID;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.IdGenerator;
|
||||
import org.springframework.util.JdkIdGenerator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.socket.sockjs.transport.TransportType;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@@ -68,7 +69,7 @@ public class SockJsUrlInfo {
|
||||
|
||||
public String getSessionId() {
|
||||
if (this.sessionId == null) {
|
||||
this.sessionId = getUuid().toString().replace("-","");
|
||||
this.sessionId = StringUtils.delete(getUuid().toString(), "-");
|
||||
}
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents a SockJS frame. Provides factory methods to create SockJS frames.
|
||||
@@ -142,7 +143,9 @@ public class SockJsFrame {
|
||||
if (result.length() > 80) {
|
||||
result = result.substring(0, 80) + "...(truncated)";
|
||||
}
|
||||
return "SockJsFrame content='" + result.replace("\n", "\\n").replace("\r", "\\r") + "'";
|
||||
result = StringUtils.replace(result, "\n", "\\n");
|
||||
result = StringUtils.replace(result, "\r", "\\r");
|
||||
return "SockJsFrame content='" + result + "'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user