bell-sw / Liberica

Free and 100% open source Progressive Java Runtime for modern Java™ deployments supported by a leading OpenJDK contributor
https://bell-sw.com/pages/libericajdk/
GNU General Public License v2.0
299 stars 28 forks source link

Wrong encoding in Debian based container #114

Closed HectorB-2020 closed 1 year ago

HectorB-2020 commented 1 year ago

Hello! Looks like we are observing issues similar to #7.

In our applications written with spring.io we use pristine container images taken from bellsoft/liberica-openjre-debian:11. Sadly the logs produced in these containerized apps contain question marks ? instead of meaningful text. We've double checked entire code - it's all written and kept in UTF-8. Whatever we've tried tuning in the container's environment - all in vain.

The only effective workaround is adding -Dfile.encoding=UTF-8. Can you please check from your side and comment on this issue?

morgion commented 1 year ago

Hello! Thanks for catching this, issue has been fixed, dockeghub images have been updated. Currently Debian based JRE images contains expected locale as JDK images. Dockerfiles also have been updated.

HectorB-2020 commented 1 year ago

@morgion, I beg you pardon, seems like this doesn't help. Non ASCII characters are still shown as ? in logs. The only feasible solution is to explicitly add extra variable _JAVA_OPTIONS=-Dfile.encoding=UTF-8

Here is how it looks inside container based on bellsoft/liberica-openjre-debian:11.

# env | grep JAVA
JAVA_HOME=/usr/lib/jvm/jre-11.0.18-bellsoft-x86_64
_JAVA_OPTIONS=-Dfile.encoding=UTF-8
# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
morgion commented 1 year ago

Hi @HectorB-2020 , Could you also please check some things:

  1. Do you use the latest image?

    docker inspect --format='{{index .RepoDigests 0}}' bellsoft/liberica-openjre-debian:11
    Output:
    bellsoft/liberica-openjre-debian@sha256:2f3227685b16c4bb4291953b1c1620a015f9f139f25d38cbc7d82879fc59b44a

    If you sha256 does not match this one, pull new image using docker pull bellsoft/liberica-openjre-debian:11

  2. Could you also please check the behavior of JDK in OpenJDK container - bellsoft/liberica-openjdk-debian:11 ? I'm a little bit confused, since in my env I can see:

    cmv@cmv-pc:~/work/liberica$ docker run -it bellsoft/liberica-openjre-debian:11
    root@7d891161cdc2:/# locale
    LANG=en_US.UTF-8
    LANGUAGE=en_US:en
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    root@7d891161cdc2:/# 

Thanks

HectorB-2020 commented 1 year ago

We cache images through Harbor but I've just double checked - it pulls the same sha. 2f3227685b16c4bb4291953b1c1620a015f9f139f25d38cbc7d82879fc59b44a And frankly speaking the set of variables above equals to your Dockefile. bellsoft/liberica-openjdk-debian:11 is still being checked, I'll update you a bit later.

HectorB-2020 commented 1 year ago

@morgion, I must apologize :crying_cat_face:, now it's working as expected. And I have to admit that an older image was cached in our build system. I still can't believe that happened. Thanks very much again! You certain may close this issue.

morgion commented 1 year ago

@HectorB-2020 , Glad to hear that problem is gone! Thanks!