This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch 1.2.X
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/1.2.X by this push:
new e5c5d2b Fix for FTPSERVER-499 applying Hai Zhang patch.
e5c5d2b is described below
commit e5c5d2bf13c120cef11ba575b00e2be3e7415c78
Author: emmanuel lecharny <[email protected]>
AuthorDate: Mon Mar 14 00:46:15 2022 +0100
Fix for FTPSERVER-499 applying Hai Zhang patch.
---
.../apache/ftpserver/listener/nio/FtpResponseEncoder.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git
a/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java
b/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java
index 4c4b884..b7b2057 100644
---
a/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java
+++
b/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java
@@ -37,16 +37,20 @@ import org.apache.mina.filter.codec.demux.MessageEncoder;
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class FtpResponseEncoder extends ProtocolEncoderAdapter {
- private static final CharsetEncoder ENCODER = Charset.forName("UTF-8")
- .newEncoder();
-
+ private static final ThreadLocal<CharsetEncoder> ENCODER = new
ThreadLocal<CharsetEncoder>() {
+ @Override
+ protected CharsetEncoder initialValue() {
+ return Charset.forName("UTF-8").newEncoder();
+ }
+ };
+
public void encode(IoSession session, Object message,
ProtocolEncoderOutput out) throws Exception {
String value = message.toString();
IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
- buf.putString(value, ENCODER);
+ buf.putString(value, ENCODER.get());
buf.flip();
out.write(buf);