sonatype-lift[bot] commented on code in PR #1891: URL: https://github.com/apache/zookeeper/pull/1891#discussion_r888454397
########## zookeeper-server/src/main/java/org/apache/zookeeper/common/StringConvertUtil.java: ########## @@ -0,0 +1,89 @@ +package org.apache.zookeeper.common; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +public class StringConvertUtil { + public final static String EMPTY_STRING = ""; + + public final static String COMMA = ","; + + public static List<String> parseList(String str, String splitStr) { + List<String> list = new ArrayList<String>(); + if (StringConvertUtil.isBlank(str) || StringConvertUtil.isBlank(splitStr)) { + return list; + } + return StringConvertUtil.toArrayList(str.split(splitStr)); + + } + + public static Map<String, String> parseMap(String str, String splitStr) { + Map<String, String> map = new LinkedHashMap<String, String>(); + if (StringConvertUtil.isBlank(str) || StringConvertUtil.isBlank(splitStr)) + return map; + List<String> list = StringConvertUtil.toArrayList(str.split(splitStr)); + for (String ip : list) { + ip = trimToEmpty(ip); + map.put(ip, ip); + + } + return map; + + } + + public static boolean isBlank(String str) { + if (null == str || trimToEmpty(str).isEmpty()) + return true; + return false; + } + + public static String trimToEmpty(String str) { + + if (null == str || str.isEmpty()) { + return EMPTY_STRING; + } + return str.trim(); + } + + public static ArrayList<String> toArrayList(String[] array) { + ArrayList<String> arrayList = new ArrayList<String>(); + if (null == array || 0 == array.length) { + return arrayList; + } + for (int i = 0; i < array.length; i++) { + arrayList.add(array[i]); + } + return arrayList; + } + + public static void startThread(Runnable runnable) { + if (null == runnable) { + return; + } + try { + Thread thread = new Thread(runnable); + thread.start(); + + } catch (Exception e) { Review Comment: *[EmptyCatch](https://google.github.io/styleguide/javaguide.html#s6.2-caught-exceptions):* Caught exceptions should not be ignored (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`) --- Was this a good recommendation? [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=261994646&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=261994646&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=261994646&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=261994646&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=261994646&lift_comment_rating=5) ] -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org