< prev index next >

src/java.logging/share/classes/java/util/logging/LogManager.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 873                 int ix2 = name.indexOf('.', ix);
 874                 if (ix2 < 0) {
 875                     break;
 876                 }
 877                 String pname = name.substring(0, ix2);
 878                 if (owner.getProperty(pname + ".level") != null ||
 879                     owner.getProperty(pname + ".handlers") != null) {
 880                     // This pname has a level/handlers definition.
 881                     // Make sure it exists.
 882                     if (visited.test(demandLogger(pname, null, null))) {
 883                         break;
 884                     }
 885                 }
 886                 ix = ix2+1;
 887             }
 888         }
 889 
 890         // Gets a node in our tree of logger nodes.
 891         // If necessary, create it.
 892         LogNode getNode(String name) {
 893             if (name == null || name.equals("")) {
 894                 return root;
 895             }
 896             LogNode node = root;
 897             while (name.length() > 0) {
 898                 int ix = name.indexOf('.');
 899                 String head;
 900                 if (ix > 0) {
 901                     head = name.substring(0, ix);
 902                     name = name.substring(ix + 1);
 903                 } else {
 904                     head = name;
 905                     name = "";
 906                 }
 907                 if (node.children == null) {
 908                     node.children = new HashMap<>();
 909                 }
 910                 LogNode child = node.children.get(head);
 911                 if (child == null) {
 912                     child = new LogNode(node, this);
 913                     node.children.put(head, child);


1469             try {
1470                 h.close();
1471             } catch (Exception ex) {
1472                 // Problems closing a handler?  Keep going...
1473             } catch (Error e) {
1474                 // ignore Errors while shutting down
1475                 if (globalHandlersState != STATE_SHUTDOWN) {
1476                     throw e;
1477                 }
1478             }
1479         }
1480     }
1481 
1482     // Private method to reset an individual target logger.
1483     private void resetLogger(Logger logger) {
1484         // Close all the Logger handlers.
1485         closeHandlers(logger);
1486 
1487         // Reset Logger level
1488         String name = logger.getName();
1489         if (name != null && name.equals("")) {
1490             // This is the root logger.
1491             logger.setLevel(defaultLevel);
1492         } else {
1493             logger.setLevel(null);
1494         }
1495     }
1496 
1497     // get a list of whitespace separated classnames from a property.
1498     private String[] parseClassNames(String propertyName) {
1499         String hands = getProperty(propertyName);
1500         if (hands == null) {
1501             return new String[0];
1502         }
1503         hands = hands.trim();
1504         int ix = 0;
1505         final List<String> result = new ArrayList<>();
1506         while (ix < hands.length()) {
1507             int end = ix;
1508             while (end < hands.length()) {
1509                 if (Character.isWhitespace(hands.charAt(end))) {




 873                 int ix2 = name.indexOf('.', ix);
 874                 if (ix2 < 0) {
 875                     break;
 876                 }
 877                 String pname = name.substring(0, ix2);
 878                 if (owner.getProperty(pname + ".level") != null ||
 879                     owner.getProperty(pname + ".handlers") != null) {
 880                     // This pname has a level/handlers definition.
 881                     // Make sure it exists.
 882                     if (visited.test(demandLogger(pname, null, null))) {
 883                         break;
 884                     }
 885                 }
 886                 ix = ix2+1;
 887             }
 888         }
 889 
 890         // Gets a node in our tree of logger nodes.
 891         // If necessary, create it.
 892         LogNode getNode(String name) {
 893             if (name == null || name.isEmpty()) {
 894                 return root;
 895             }
 896             LogNode node = root;
 897             while (name.length() > 0) {
 898                 int ix = name.indexOf('.');
 899                 String head;
 900                 if (ix > 0) {
 901                     head = name.substring(0, ix);
 902                     name = name.substring(ix + 1);
 903                 } else {
 904                     head = name;
 905                     name = "";
 906                 }
 907                 if (node.children == null) {
 908                     node.children = new HashMap<>();
 909                 }
 910                 LogNode child = node.children.get(head);
 911                 if (child == null) {
 912                     child = new LogNode(node, this);
 913                     node.children.put(head, child);


1469             try {
1470                 h.close();
1471             } catch (Exception ex) {
1472                 // Problems closing a handler?  Keep going...
1473             } catch (Error e) {
1474                 // ignore Errors while shutting down
1475                 if (globalHandlersState != STATE_SHUTDOWN) {
1476                     throw e;
1477                 }
1478             }
1479         }
1480     }
1481 
1482     // Private method to reset an individual target logger.
1483     private void resetLogger(Logger logger) {
1484         // Close all the Logger handlers.
1485         closeHandlers(logger);
1486 
1487         // Reset Logger level
1488         String name = logger.getName();
1489         if (name != null && name.isEmpty()) {
1490             // This is the root logger.
1491             logger.setLevel(defaultLevel);
1492         } else {
1493             logger.setLevel(null);
1494         }
1495     }
1496 
1497     // get a list of whitespace separated classnames from a property.
1498     private String[] parseClassNames(String propertyName) {
1499         String hands = getProperty(propertyName);
1500         if (hands == null) {
1501             return new String[0];
1502         }
1503         hands = hands.trim();
1504         int ix = 0;
1505         final List<String> result = new ArrayList<>();
1506         while (ix < hands.length()) {
1507             int end = ix;
1508             while (end < hands.length()) {
1509                 if (Character.isWhitespace(hands.charAt(end))) {


< prev index next >