Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1472

SystemUtils.getHostName()获取系统hostname为null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Not A Problem
    • 3.9
    • None
    • lang.*
    • None

    Description

      SpringBoot 项目获取系统 hostname 为 null 导致 java.lang.NullPointerException 。

      部分代码:
      private static Long getDataCenterId(){
      int[] ints = StringUtils.toCodePoints(SystemUtils.getHostName());
      int sums = 0;
      for (int i: ints)

      { sums += i; }

      return (long)(sums % 32);
      }

      Attachments

        1. error.png
          55 kB
          wangrubao
        2. pom.xml
          4 kB
          wangrubao
        3. SnowflakeIdWorker.java
          8 kB
          wangrubao

        Activity

          People

            Unassigned Unassigned
            VioletKiss wangrubao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: