[
https://issues.apache.org/jira/browse/CXF-6189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275075#comment-14275075
]
Sergey Beryozkin commented on CXF-6189:
---------------------------------------
I have this code working:
{code:java}
private static String urlDecode(String value, String enc, boolean isPath) {
final byte[] valueBytes = StringUtils.toBytes(value, enc);
ByteBuffer in = ByteBuffer.wrap(valueBytes);
ByteBuffer out = ByteBuffer.allocate(in.capacity());
while (in.hasRemaining()) {
final int b = in.get();
if (!isPath && b == PLUS_CHAR) {
out.put((byte) ' ');
} else if (b == ESCAPE_CHAR) {
try {
final int u = digit16((byte) in.get());
final int l = digit16((byte) in.get());
out.put((byte) ((u << 4) + l));
} catch (final ArrayIndexOutOfBoundsException e) {
throw new RuntimeException("Invalid URL encoding: ", e);
}
} else {
out.put((byte) b);
}
}
out.flip();
return Charset.forName(enc).decode(out).toString();
}
{code}
The test I referred to uses chinese symbols, each of them in this case is 3
bytes, converting String into CharArray loses that info, each char is assumed
to have 2 bytes
> Improve memory usage of UrlUtils
> --------------------------------
>
> Key: CXF-6189
> URL: https://issues.apache.org/jira/browse/CXF-6189
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.0.3
> Reporter: Lucas Pouzac
> Labels: performance
> Attachments: jmh.tar.gz, screenshot-1.png
>
>
> When I run load test, I find that the management of encoding parameters of
> the urls is consumer memory.
> I do not know if it is possible to optimize this part.
> Throughput of load test : 400 query/s
> ~80% GET query with 6 parameters
> ~20% POST query with 6 parameters GET and 1 payload
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)