1616 */
1717package org .apache .logging .log4j .config .jackson ;
1818
19- import com .fasterxml .jackson .databind .JsonNode ;
20- import com .fasterxml .jackson .databind .ObjectMapper ;
21- import com .fasterxml .jackson .databind .node .JsonNodeFactory ;
22- import com .fasterxml .jackson .databind .node .ObjectNode ;
2319import java .io .ByteArrayInputStream ;
2420import java .io .IOException ;
2521import java .io .InputStream ;
2622import java .util .ArrayList ;
27- import java .util .Iterator ;
2823import java .util .List ;
2924import java .util .Map ;
30- import java .util .Map .Entry ;
3125import java .util .TreeMap ;
3226import org .apache .logging .log4j .core .LoggerContext ;
3327import org .apache .logging .log4j .core .config .AbstractConfiguration ;
3832import org .apache .logging .log4j .core .config .status .StatusConfiguration ;
3933import org .apache .logging .log4j .plugins .Node ;
4034import org .apache .logging .log4j .plugins .model .PluginType ;
35+ import tools .jackson .databind .JsonNode ;
36+ import tools .jackson .databind .ObjectMapper ;
37+ import tools .jackson .databind .node .JsonNodeFactory ;
38+ import tools .jackson .databind .node .ObjectNode ;
4139
4240/**
4341 * Base class for all Jackson-based configurations.
@@ -116,10 +114,8 @@ protected abstract Configuration createConfiguration(
116114
117115 @ Override
118116 public void setup () {
119- final Iterator <Entry <String , JsonNode >> iter = root .fields ();
120117 final List <Node > children = rootNode .getChildren ();
121- while (iter .hasNext ()) {
122- final Map .Entry <String , JsonNode > entry = iter .next ();
118+ for (Map .Entry <String , JsonNode > entry : root .properties ()) {
123119 final JsonNode n = entry .getValue ();
124120 if (n .isObject ()) {
125121 LOGGER .debug ("Processing node for object {}" , entry .getKey ());
@@ -154,10 +150,8 @@ private Node constructNode(final String name, final Node parent, final JsonNode
154150 final PluginType <?> type = corePlugins .get (getType (jsonNode , name ));
155151 final Node node = new Node (parent , name , type );
156152 processAttributes (node , jsonNode );
157- final Iterator <Map .Entry <String , JsonNode >> iter = jsonNode .fields ();
158153 final List <Node > children = node .getChildren ();
159- while (iter .hasNext ()) {
160- final Map .Entry <String , JsonNode > entry = iter .next ();
154+ for (Map .Entry <String , JsonNode > entry : jsonNode .properties ()) {
161155 final JsonNode n = entry .getValue ();
162156 if (n .isArray () || n .isObject ()) {
163157 if (type == null ) {
@@ -195,9 +189,7 @@ private Node constructNode(final String name, final Node parent, final JsonNode
195189 }
196190
197191 private String getType (final JsonNode node , final String name ) {
198- final Iterator <Map .Entry <String , JsonNode >> iter = node .fields ();
199- while (iter .hasNext ()) {
200- final Map .Entry <String , JsonNode > entry = iter .next ();
192+ for (Map .Entry <String , JsonNode > entry : node .properties ()) {
201193 if ("type" .equalsIgnoreCase (entry .getKey ())) {
202194 final JsonNode n = entry .getValue ();
203195 if (n .isValueNode ()) {
@@ -210,9 +202,7 @@ private String getType(final JsonNode node, final String name) {
210202
211203 private void processAttributes (final Node parent , final JsonNode node ) {
212204 final Map <String , String > attrs = parent .getAttributes ();
213- final Iterator <Map .Entry <String , JsonNode >> iter = node .fields ();
214- while (iter .hasNext ()) {
215- final Map .Entry <String , JsonNode > entry = iter .next ();
205+ for (Map .Entry <String , JsonNode > entry : node .properties ()) {
216206 if (!"type" .equalsIgnoreCase (entry .getKey ())) {
217207 final JsonNode n = entry .getValue ();
218208 if (n .isValueNode ()) {
0 commit comments