Meituan-Dianping / Meituan-Dianping/Zebra

本地配置,打成jar包后运行,报空指针异常。远程配置也无法读取zookeepe.properties的内容

Open
#55 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.8k
Forks
705
PR merge metrics
No merged PRs in 30d

Description

public static File toFile(URL url) {
logger.info("*********url:"+url.getFile()+""+url.getProtocol());

    if (url == null || !url.getProtocol().equals("file")) {
        return null;
    } else {
        String filename = url.getFile().replace('/', File.separatorChar);
        int pos = 0;
        while ((pos = filename.indexOf('%', pos)) >= 0) {
            if (pos + 2 < filename.length()) {
                String hexStr = filename.substring(pos + 1, pos + 3);
                char ch = (char) Integer.parseInt(hexStr, 16);
                filename = filename.substring(0, pos) + ch + filename.substring(pos + 3);
            }
        }
        return new File(filename);
    }
}

打成jar后,url.getProtocol()=“jar”,然后报错,应该怎么解决呢

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the toFile(URL) method shown in the issue and reproduce configuration loading after packaging the application as a JAR. Check the behavior when the URL protocol is jar rather than file, including the reported zookeepe.properties lookup. Done means both local packaged configuration and remote configuration can be read without the reported null pointer failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.