Issue
I've got the UnmappableCharacterException in fabric8/java-alpine-openjdk11-jre:1.6.5
container. How can I fix this exception?
java.nio.charset.UnmappableCharacterException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:275)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:306)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:281)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
Application Context:
My app is web api app with Quarkus Framework and basically I'm using UTF-8 encoding, but in some point I need to use the other encoding like MS932 (Windows-31j)
.
When I run the app on the machine(not in the container, with ./gradlew quarkusDev
), I can get my response with these specific encoding, but in the container, I've got the exception on the above.
Recently I've changed the framework Jersey to Quarkus and tomcat:8.5-jdk11-openjdk-slim
container to fabric8/java-alpine-openjdk11-jre:1.6.5
container.
I'm sure that Jersey with tomcat:8.5-jdk11-openjdk-slim
responded without exception, so I'll try with openjdk11-slim image later, but I love fabric8's container, so I want to fix this issue and continue to use it.
Detected Findings:
I tried to change these specific encoding to UTF-8
or UTF-16
, the responses are OK, but not only MS932
, also SJIS
, GBK
and other Extended Encoding Set return the exception.
In this context, I guess these exceptions are related to Extended Encoding Set
and fabric8's container image.
Environment Info and Dockerfile:
Here is the portion of my Dockerfile(it is based on Quarkus generated Dockerfile):
FROM fabric8/java-alpine-openjdk11-jre:1.6.5
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
# Be prepared for running in OpenShift too
RUN adduser -G root --no-create-home --disabled-password 1001 \
&& chown -R 1001 /deployments \
&& chmod -R "g+rwX" /deployments \
&& chown -R 1001:root /deployments
COPY --from=build /home/gradle/project/build/lib/* /deployments/lib/
COPY --from=build /home/gradle/project/build/*-runner.jar /deployments/app.jar
EXPOSE 8080
# run with user 1001
USER 1001
- OS: Debian GNU/Linux 10
- Docker version: 18.09.1
References
Solution
We found the solution for this.
Unfortunately, it is not the Quarkus, Fabric8 and Java's issues, it is just only the data(character).
Recently the data was updated. It contains some characters what MS932
or the other encodings can't show up, but UTF-8
can. It makes the issue as a result.
Embarrassing, but the issue was resolved.
Answered By - tkhm
Answer Checked By - Willingham (JavaFixing Volunteer)