Skip to content
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

PartitionSpec 抛异常 Invalid partition spec. #77

Open
ChaomingZhangCN opened this issue Dec 11, 2024 · 0 comments
Open

PartitionSpec 抛异常 Invalid partition spec. #77

ChaomingZhangCN opened this issue Dec 11, 2024 · 0 comments

Comments

@ChaomingZhangCN
Copy link

ChaomingZhangCN commented Dec 11, 2024

目前代码如下:

public PartitionSpec(String spec, boolean trim) {
    if (spec == null) {
      throw new IllegalArgumentException("Argument \'spec\' cannot be null");
    }
    String[] groups = spec.split("[,/]");
    for (String group : groups) {
      String[] kv = group.split("=");
      if (kv.length != 2) {
        throw new IllegalArgumentException("Invalid partition spec.");
      }

      String k = trim ? kv[0].trim() : kv[0];
      String v = (trim ? kv[1].trim() : kv[1])
          .replaceAll("'", "")
          .replaceAll("\"", "");
      if (k.length() == 0 || v.length() == 0) {
        throw new IllegalArgumentException("Invalid partition spec.");
      }

      set(k, v);
    }
  }
  1. 对于 value 是空或者带 = 会报错,增加更友好的异常提示?
  2. 是否需要将异常的 spec 放到异常里面,帮助排查问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants