[ https://issues.apache.org/jira/browse/LANG-1472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16905799#comment-16905799 ]
Silence Tai edited comment on LANG-1472 at 8/13/19 4:11 AM: ------------------------------------------------------------ -Hi!- -XDD- -Execute the *env* command on your machine to get the environment variables.- 在你的服务器上执行 *env* 命令你会获得环境变量列表。 was (Author: tai): Hi! XDD Execute the *env* command on your machine to get the environment variables. > 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)