You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "wangrubao (JIRA)" <ji...@apache.org> on 2019/08/13 02:15:00 UTC
[jira] [Comment Edited] (LANG-1472) SystemUtils.getHostName()获取系统hostname为null
[ https://issues.apache.org/jira/browse/LANG-1472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16905730#comment-16905730 ]
wangrubao edited comment on LANG-1472 at 8/13/19 2:14 AM:
----------------------------------------------------------
*operating system* :
LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
*java* :
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
*mysql* :
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapper
*maven* :
apache-maven-3.6.1\
was (Author: violetkiss):
*operating system* :
LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
*java* :
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
*mysql* :
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapper
> SystemUtils.getHostName()获取系统hostname为null
> ------------------------------------------
>
> Key: LANG-1472
> URL: https://issues.apache.org/jira/browse/LANG-1472
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.9
> Environment: * 操作系统:阿里云提供的Ubuntu 16.04
> root@iZwz99ibpdra8w3j3jcbw7Z:~# hostname
> iZwz99ibpdra8w3j3jcbw7Z
> root@iZwz99ibpdra8w3j3jcbw7Z:~# echo $HOSTNAME
> iZwz99ibpdra8w3j3jcbw7Z
> * 语言:Java 8
> root@iZwz99ibpdra8w3j3jcbw7Z:~# java -version
> java version "1.8.0_191"
> Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
> Reporter: wangrubao
> Priority: Critical
> Attachments: SnowflakeIdWorker.java, error.png, pom.xml
>
>
> 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);
> }
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)