apache / apache/servicecomb-toolkit

windows上cli 处理文件编码问题

Open
#61 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
440
Forks
35
Avg merge
1m
Merged PRs (30d)
1

Description

openapi yaml 文件有中文字符,文件编码格式是 utf-8 。当在windows cmd 下执行时会提示编码错误,需要加上 -Dfile.encoding=UTF-8。

错误信息如下:

```
`java -jar bin/cli-0.2.0-SNAPSHOT.jar checkstyle -r style-check-rules.properties -f openapi.yml
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.RuntimeException: java.io.CharConversionException: Invalid UTF-8 start byte 0xb5 (at char #35, byte #-1)
at [Source: (byte[])"openapi: '3.0.2'
info:
title: ?????POS???
version: '1.0.0'
description: ???POS???????
servers:
- url: 'https://xxxxxxxx'
description: ???????????????
- url: http://xxxxxxxxxx/{basePath}
description: ?????????????
variables:
basePath:
default: v2
description: api version

paths:
/pos/login.init:
$ref: commonapi.yml#/components/login.init
/pos/login:
$ref: commonapi.yml#/compo"[truncated 1336 bytes]; line: 1, column: 1]
at org.apache.servicecomb.toolkit.cli.CheckStyleBase.run(CheckStyleBase.java:84)
at org.apache.servicecomb.toolkit.cli.ToolkitMain.main(ToolkitMain.java:48)
... 8 more
make: *** [Makefile:28: verify] Error 1`
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the `java -jar ... checkstyle` command in Windows cmd with the UTF-8 `openapi.yml`, first comparing behavior with and without `-Dfile.encoding=UTF-8`. Trace the failure from `ToolkitMain.main` into `CheckStyleBase.run`; done means the CLI processes Chinese UTF-8 input without requiring the JVM encoding flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.