eclipse-emfcloud / emfcloud-modelserver

Modelserver component
Other
40 stars 21 forks source link

XMI post success depends on system default charset #260

Open MichelSc opened 1 year ago

MichelSc commented 1 year ago

I post an XMI to the modelserver.

If the system defaut charset is not UTF-8, we get the exception

ERROR org.eclipse.emfcloud.modelserver.emf.common.util.ContextResponse - An error occurred during data decoding
org.eclipse.emfcloud.modelserver.common.codecs.DecodingException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Invalid byte 2 of 3-byte UTF-8 sequence.

Error is on this line: https://github.com/eclipse-emfcloud/emfcloud-modelserver/blob/8e68e4c59159d5729cc3918d55150a2722285277/bundles/org.eclipse.emfcloud.modelserver.common/src/org/eclipse/emfcloud/modelserver/common/codecs/XmiCodec.java#L93

The code encodes the payload string using the default system charset with [String.getBytes](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes()): NOK.

Workaround: start the executable with -Dfile.encoding="UTF-8"

eneufeld commented 1 year ago

Thank you for raising this issue. We will take a look at this. Of course we still happily accept a contribution.