gong opened a new pull request, #17646:
URL: https://github.com/apache/iceberg/pull/17646

   ## Problem
   When creating a table or adding a column through the REST catalog, non-ASCII 
characters in comments (e.g. table comment property or column doc) are garbled 
on the server side.
   ## Root Cause
   In HTTPClient#execute, the serialized request body is attached using the 
default StringEntity(String) constructor:
   ```java
   
   request.setEntity(new StringEntity(encodedBody));
   
   ```
   Apache HttpClient 5's StringEntity(String) defaults to text/plain; 
charset=ISO-8859-1. Although the body was correctly serialized to a UTF-8 
String by Jackson, the entity encodes those bytes using ISO-8859-1. Non-ASCII 
characters cannot be represented in ISO-8859-1 and are irreversibly replaced 
with ?, so the server decodes garbled comments.
   ## Fix
   Explicitly specify UTF-8 when constructing the entity:
   ```java
   
   request.setEntity(new StringEntity(encodedBody, StandardCharsets.UTF_8));
   
   ```
   This applies to both JSON bodies (create table, update table, etc.) and 
form-encoded bodies. The Content-Type header is unaffected because it is 
already set explicitly in buildRequest.
   
   ## Tests
   Added TestHTTPClient#testPostUnicodeBody and related cases in 
TestHTTPClient, covering:
   * testPostUnicodeBody – generic round-trip guard
   * testPostCreateTableUnicodeColumnComment – non-ASCII column comment (doc) 
in a CreateTableRequest
   * testPostUpdateTableUnicodeColumnComment – non-ASCII column comment added 
via an add-column MetadataUpdate


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to