You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@causeway.apache.org by "Andi Huber (Jira)" <ji...@apache.org> on 2024/12/03 09:02:00 UTC

[jira] [Closed] (CAUSEWAY-3835) [Commons] Internal _DocumentFactories has unnecessary String to Bytes Conversion Step

     [ https://issues.apache.org/jira/browse/CAUSEWAY-3835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Huber closed CAUSEWAY-3835.
--------------------------------
    Resolution: Fixed

> [Commons] Internal _DocumentFactories has unnecessary String to Bytes Conversion Step
> -------------------------------------------------------------------------------------
>
>                 Key: CAUSEWAY-3835
>                 URL: https://issues.apache.org/jira/browse/CAUSEWAY-3835
>             Project: Causeway
>          Issue Type: Improvement
>          Components: Commons
>            Reporter: PJ Fanning
>            Assignee: Andi Huber
>            Priority: Minor
>             Fix For: 2.2.0, 3.2.0
>
>
> https://github.com/apache/causeway/blob/982de018229db2a097080ade53ccfbb4cceffd12/commons/src/main/java/org/apache/causeway/commons/internal/codec/_DocumentFactories.java
> 1. In `public Document parseDocument(final @Nullable String xml)`, you can avoid the getBytes call that wastes memory and that could be an incorrect assumption about the char encoding - not all XML originates as UTF-8 and if you already have it in String format, you don't need to convert it back to bytes (forcing the XML parser to turn into back into chars).
> ```
>         try(var sw = new StringWriter(xml)) {
>             var doc = documentBuilder.parse(new InputSource(sw));
>             return doc;
>         }
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)