Skip to content

Commit aa54a5a

Browse files
committed
Upgraded Jackson from 2.x to 3.0.0-rc5
1 parent 0aeb58c commit aa54a5a

File tree

14 files changed

+45
-52
lines changed

14 files changed

+45
-52
lines changed

log4j-config-jackson/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</dependency>
3737

3838
<dependency>
39-
<groupId>com.fasterxml.jackson.core</groupId>
39+
<groupId>tools.jackson.core</groupId>
4040
<artifactId>jackson-databind</artifactId>
4141
</dependency>
4242

log4j-config-jackson/src/main/java/org/apache/logging/log4j/config/jackson/AbstractJacksonConfiguration.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
*/
1717
package 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;
2319
import java.io.ByteArrayInputStream;
2420
import java.io.IOException;
2521
import java.io.InputStream;
2622
import java.util.ArrayList;
27-
import java.util.Iterator;
2823
import java.util.List;
2924
import java.util.Map;
30-
import java.util.Map.Entry;
3125
import java.util.TreeMap;
3226
import org.apache.logging.log4j.core.LoggerContext;
3327
import org.apache.logging.log4j.core.config.AbstractConfiguration;
@@ -38,6 +32,10 @@
3832
import org.apache.logging.log4j.core.config.status.StatusConfiguration;
3933
import org.apache.logging.log4j.plugins.Node;
4034
import 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()) {

log4j-config-properties/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</dependency>
3939

4040
<dependency>
41-
<groupId>com.fasterxml.jackson.dataformat</groupId>
41+
<groupId>tools.jackson.dataformat</groupId>
4242
<artifactId>jackson-dataformat-properties</artifactId>
4343
</dependency>
4444

log4j-config-properties/src/main/java/org/apache/logging/log4j/config/properties/JavaPropsConfiguration.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
*/
1717
package org.apache.logging.log4j.config.properties;
1818

19-
import com.fasterxml.jackson.core.JsonParser;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
21-
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper;
2219
import org.apache.logging.log4j.config.jackson.AbstractJacksonConfiguration;
2320
import org.apache.logging.log4j.core.LoggerContext;
2421
import org.apache.logging.log4j.core.config.Configuration;
2522
import org.apache.logging.log4j.core.config.ConfigurationSource;
23+
import tools.jackson.databind.ObjectMapper;
24+
import tools.jackson.dataformat.javaprop.JavaPropsMapper;
2625

2726
/**
2827
* Creates a Node hierarchy from a properties file.
@@ -41,7 +40,6 @@ protected Configuration createConfiguration(
4140

4241
protected ObjectMapper getObjectMapper() {
4342
return JavaPropsMapper.builder()
44-
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
4543
.nodeFactory(SortingNodeFactory.INSTANCE)
4644
.build();
4745
}

log4j-config-yaml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</dependency>
3939

4040
<dependency>
41-
<groupId>com.fasterxml.jackson.dataformat</groupId>
41+
<groupId>tools.jackson.dataformat</groupId>
4242
<artifactId>jackson-dataformat-yaml</artifactId>
4343
</dependency>
4444

log4j-config-yaml/src/main/java/org/apache/logging/log4j/config/yaml/YamlConfiguration.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
*/
1717
package org.apache.logging.log4j.config.yaml;
1818

19-
import com.fasterxml.jackson.core.JsonParser;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
21-
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
2219
import org.apache.logging.log4j.config.jackson.AbstractJacksonConfiguration;
2320
import org.apache.logging.log4j.core.LoggerContext;
2421
import org.apache.logging.log4j.core.config.Configuration;
2522
import org.apache.logging.log4j.core.config.ConfigurationSource;
23+
import tools.jackson.databind.ObjectMapper;
24+
import tools.jackson.dataformat.yaml.YAMLMapper;
2625

2726
/**
2827
* Creates a Node hierarchy from a YAML file.
@@ -41,8 +40,6 @@ protected Configuration createConfiguration(
4140

4241
@Override
4342
protected ObjectMapper getObjectMapper() {
44-
return YAMLMapper.builder()
45-
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
46-
.build();
43+
return YAMLMapper.builder().build();
4744
}
4845
}

log4j-core-test/pom.xml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,28 @@
156156

157157
<!-- Required for JSON support -->
158158
<dependency>
159-
<groupId>com.fasterxml.jackson.core</groupId>
159+
<groupId>tools.jackson.core</groupId>
160160
<artifactId>jackson-core</artifactId>
161161
<optional>true</optional>
162162
</dependency>
163163

164164
<!-- Required for JSON support -->
165165
<dependency>
166-
<groupId>com.fasterxml.jackson.core</groupId>
166+
<groupId>tools.jackson.core</groupId>
167167
<artifactId>jackson-databind</artifactId>
168168
<optional>true</optional>
169169
</dependency>
170170

171171
<!-- Required for XML layout and receiver support -->
172172
<dependency>
173-
<groupId>com.fasterxml.jackson.dataformat</groupId>
173+
<groupId>tools.jackson.dataformat</groupId>
174174
<artifactId>jackson-dataformat-xml</artifactId>
175175
<optional>true</optional>
176176
</dependency>
177177

178178
<!-- Required for YAML support (including JSON requirements) -->
179179
<dependency>
180-
<groupId>com.fasterxml.jackson.dataformat</groupId>
180+
<groupId>tools.jackson.dataformat</groupId>
181181
<artifactId>jackson-dataformat-yaml</artifactId>
182182
<optional>true</optional>
183183
</dependency>
@@ -315,6 +315,14 @@
315315
<scope>test</scope>
316316
</dependency>
317317

318+
<!-- Needed by wiremock for testing -->
319+
<dependency>
320+
<groupId>com.fasterxml.jackson.core</groupId>
321+
<artifactId>jackson-databind</artifactId>
322+
<version>${jackson2.test.version}</version>
323+
<scope>test</scope>
324+
</dependency>
325+
318326
<dependency>
319327
<groupId>org.xmlunit</groupId>
320328
<artifactId>xmlunit-core</artifactId>

log4j-docker/pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
<!--
3737
~ OSGi and JPMS options
3838
-->
39-
<bnd-extra-module-options>
40-
<!-- Non detected module names -->
41-
com.fasterxml.jackson.core;substitute="jackson-core",
42-
com.fasterxml.jackson.databind;substitute="jackson-databind"
43-
</bnd-extra-module-options>
4439
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
4540
</properties>
4641

@@ -59,11 +54,11 @@
5954
<artifactId>jackson-annotations</artifactId>
6055
</dependency>
6156
<dependency>
62-
<groupId>com.fasterxml.jackson.core</groupId>
57+
<groupId>tools.jackson.core</groupId>
6358
<artifactId>jackson-core</artifactId>
6459
</dependency>
6560
<dependency>
66-
<groupId>com.fasterxml.jackson.core</groupId>
61+
<groupId>tools.jackson.core</groupId>
6762
<artifactId>jackson-databind</artifactId>
6863
</dependency>
6964
<dependency>

log4j-docker/src/main/java/org/apache/logging/log4j/docker/DockerLookup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
package org.apache.logging.log4j.docker;
1818

19-
import com.fasterxml.jackson.core.type.TypeReference;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
2119
import java.io.IOException;
2220
import java.net.URI;
2321
import java.net.URL;
@@ -33,6 +31,8 @@
3331
import org.apache.logging.log4j.kit.env.PropertyEnvironment;
3432
import org.apache.logging.log4j.plugins.Plugin;
3533
import org.apache.logging.log4j.status.StatusLogger;
34+
import tools.jackson.core.type.TypeReference;
35+
import tools.jackson.databind.ObjectMapper;
3636

3737
/**
3838
* Looks up keys for a Docker container.

log4j-layout-template-json-test/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@
9797
<scope>test</scope>
9898
</dependency>
9999

100+
<!-- Needed by elasticsearch-java for testing -->
100101
<dependency>
101102
<groupId>com.fasterxml.jackson.core</groupId>
102103
<artifactId>jackson-databind</artifactId>
104+
<version>${jackson2.test.version}</version>
103105
<scope>test</scope>
104106
</dependency>
105107

0 commit comments

Comments
 (0)