Merge branch '5.3.x' into main

This commit is contained in:
rstoyanchev
2022-02-14 20:52:09 +00:00
4 changed files with 24 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -79,13 +79,7 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
if (logger.isDebugEnabled()) {
logger.debug("Connection already closed (but not removed yet) for " + sockJsSession);
}
SockJsFrame frame = SockJsFrame.closeFrameGoAway();
try {
response.getBody().write(frame.getContentBytes());
}
catch (IOException ex) {
throw new SockJsException("Failed to send " + frame, sockJsSession.getId(), ex);
}
writeFrame(SockJsFrame.closeFrameGoAway(), request, response, sockJsSession);
}
else if (!sockJsSession.isActive()) {
if (logger.isTraceEnabled()) {
@@ -97,13 +91,19 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
if (logger.isDebugEnabled()) {
logger.debug("Another " + getTransportType() + " connection still open for " + sockJsSession);
}
String formattedFrame = getFrameFormat(request).format(SockJsFrame.closeFrameAnotherConnectionOpen());
try {
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
}
catch (IOException ex) {
throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex);
}
writeFrame(SockJsFrame.closeFrameAnotherConnectionOpen(), request, response, sockJsSession);
}
}
private void writeFrame(SockJsFrame frame, ServerHttpRequest request, ServerHttpResponse response,
AbstractHttpSockJsSession sockJsSession) {
String formattedFrame = getFrameFormat(request).format(frame);
try {
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
}
catch (IOException ex) {
throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 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.
@@ -257,7 +257,8 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
synchronized (this.responseLock) {
try {
if (isClosed()) {
response.getBody().write(SockJsFrame.closeFrameGoAway().getContentBytes());
String formattedFrame = frameFormat.format(SockJsFrame.closeFrameGoAway());
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
return;
}
this.response = response;