-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JVM default encoding is not set to UTF-8 #118
Comments
I'm not inclined to set this because I think it's more of a concern for an application developer. If the default works, great, but if not I think the application developer should choose what encoding to use. I'm also concerned about diverging from the default behavior in Java. Java has a defined behavior for how it determines the default character set. It's generally well-known, documented, and easy to search and find information about. If the buildpack changes this default behavior, that could create problems for someone also, someone expecting the default behavior. As you mentioned, you can set Beyond that, I would say let's keep this issue open and let it gather feedback. If there are enough people interested in the buildpack setting the default character set and none opposing it, then we can revisit making this change. If you're in favor of this, please 👍. If you think we should keep the JVM default, 👎 . Thanks |
@dmikusa-pivotal i can't find it in JVM documentation but i'm pretty sure that default encoding is set based on operating system, user locale running JVM and others. So default encoding other than UTF-8 comes from base docker image, not from JVM itself. |
The default behavior of the JVM on Linux is to use the locale. It's in the Javadoc, https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html and StackOverflow, and other places if you search for "java default character set". As always Baeldung has a great write-up.
Correct, but the buildpack doesn't provide the base image. The buildpack can run on any number of different base images and so the locale could differ depending on the base image. If we set this value in the buildpack and it'll squash the default behavior. That means that the buildpack is doing something unique and potentially unexpected to users (like if you set the locale in your base image and expected it to use that). Again, I'm not necessarily opposed to changing it. It's a default though, so we have to be particularly careful about changing defaults. Thus I'd like to get feedback before doing it. If this seems to be generally useful, then we can move ahead with it. |
Just FYI: Java 18 will use UTF-8 by default - see https://openjdk.java.net/jeps/400 |
I would like to close this out because I don't think we want to have special behavior for the buildpacks. We are also rolling out Java 18 support now, which defaults to UTF-8, and there are also multiple easy fixes if you want to force UTF-8 and are not able to use the latest version.
or
You could also use the environment-variables buildpack and embed
|
I ended up here, because this doesn't work for native images. Since it's not using a JVM, it's not honoring Passing them as environment variables to the container also doesn't work, as they're not used in the startup command that calls the native executable. The only way to work around that is either or
|
What happened?
Docker image prepared by
paketo-buildpacks/bellsoft-liberica
usingspring-boot-maven-plugin
in version2.3.12.RELEASE
is not usingUTF-8
as default encoding.UTF-8
encoding is most common encoding type and should be used as a default one.What were you attempting to do?
Integrate java spring-boot application with azure blob storage using
com.azure.azure-storage-blob
in version12.6.0
and list blobs which under the hood query azure backend for xml response.What did you expect to happen?
Default encoding of JVM is set to
UTF-8
because it's most common encoding.What was the actual behavior? Please provide log output, if possible.
Request listing blob return xml with BOM for UTF-8
<?xml version="1.0" encoding="utf-8"?>
which is then incorrectly parsed.Below log is from spring boot application at runtime (not from buildpack build process).
Build Configuration
default spring boot configuration in version
boot 2.3.12.RELEASE
Problem can be solved by passing
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
but it's not obvious at the beginningChecklist
The text was updated successfully, but these errors were encountered: