Skip to content

Commit 0d64d4c

Browse files
committed
Maintenance update
- replaced joda-time by JDK Date and Time API - updated dependencies - removed unused dependencies
1 parent 094ecdf commit 0d64d4c

File tree

5 files changed

+65
-49
lines changed

5 files changed

+65
-49
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ PART 2: https://blogs.mulesoft.com/dev/api-dev/json-logging-in-mule-4/
8181

8282
## Release notes
8383

84+
### 2.2.2 version - Release notes
85+
86+
* Replaced joda-time by JDK Date and Time API
87+
* Upgraded depdendencies
88+
* Removed unused dependencies
89+
8490
### 2.2.1 version - Release notes
8591

8692
* Reorganized folder structure

pom.xml

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
35

46
<modelVersion>4.0.0</modelVersion>
57
<groupId>cloud.anypoint</groupId>
@@ -29,7 +31,7 @@
2931

3032
<properties>
3133
<munit.extensions.maven.plugin.version>1.3.1</munit.extensions.maven.plugin.version>
32-
<munit.version>3.2.1</munit.version>
34+
<munit.version>3.3.0</munit.version>
3335
</properties>
3436

3537
<distributionManagement>
@@ -43,6 +45,16 @@
4345
</repository>
4446
</distributionManagement>
4547

48+
<developers>
49+
<developer>
50+
<id>mtransier</id>
51+
<name>Matthias Transier</name>
52+
<roles>
53+
<role>Maintainer</role>
54+
</roles>
55+
</developer>
56+
</developers>
57+
4658
<build>
4759
<testResources>
4860
<testResource>
@@ -77,6 +89,13 @@
7789
</execution>
7890
</executions>
7991
</plugin>
92+
<plugin>
93+
<groupId>com.mulesoft.munit</groupId>
94+
<artifactId>munit-extensions-maven-plugin</artifactId>
95+
<configuration>
96+
<runtimeProduct>MULE_EE</runtimeProduct>
97+
</configuration>
98+
</plugin>
8099
</plugins>
81100
</build>
82101

@@ -88,60 +107,38 @@
88107
</scm>
89108

90109
<dependencies>
91-
<dependency>
92-
<artifactId>snakeyaml</artifactId>
93-
<groupId>org.yaml</groupId>
94-
<version>2.2</version>
95-
</dependency>
96-
<dependency>
97-
<groupId>org.json</groupId>
98-
<artifactId>json</artifactId>
99-
<version>20240303</version>
100-
</dependency>
101110
<dependency>
102111
<groupId>com.fasterxml.jackson.core</groupId>
103112
<artifactId>jackson-databind</artifactId>
104-
<version>2.17.0</version>
105-
</dependency>
106-
<dependency>
107-
<groupId>commons-lang</groupId>
108-
<artifactId>commons-lang</artifactId>
109-
<version>2.6</version>
113+
<version>2.18.0</version>
110114
</dependency>
111115
<dependency>
112116
<groupId>commons-beanutils</groupId>
113117
<artifactId>commons-beanutils</artifactId>
114118
<version>1.9.4</version>
115119
</dependency>
116-
<dependency>
117-
<groupId>joda-time</groupId>
118-
<artifactId>joda-time</artifactId>
119-
<version>2.12.7</version>
120-
</dependency>
121120
<dependency>
122121
<groupId>org.mule.connectors</groupId>
123122
<artifactId>mule-jms-connector</artifactId>
124-
<version>1.9.3</version>
123+
<version>1.9.7</version>
125124
<classifier>mule-plugin</classifier>
126-
<scope>provided</scope>
127125
</dependency>
128126
<dependency>
129127
<groupId>org.mule.connectors</groupId>
130128
<artifactId>mule-jms-client</artifactId>
131-
<version>1.13.12</version>
129+
<version>1.13.17</version>
132130
<scope>provided</scope>
133131
</dependency>
134132
<dependency>
135133
<groupId>com.mulesoft.connectors</groupId>
136134
<artifactId>mule-amqp-connector</artifactId>
137-
<version>1.7.7</version>
135+
<version>1.8.1</version>
138136
<classifier>mule-plugin</classifier>
139-
<scope>provided</scope>
140137
</dependency>
141138
<dependency>
142139
<groupId>com.mulesoft.muleesb.modules</groupId>
143140
<artifactId>anypoint-mq-rest-client</artifactId>
144-
<version>4.0.6</version>
141+
<version>4.0.13-1.fix-race-condition</version>
145142
<exclusions>
146143
<exclusion>
147144
<artifactId>async-http-client</artifactId>
@@ -158,11 +155,6 @@
158155
</exclusions>
159156
<scope>compile</scope>
160157
</dependency>
161-
<dependency>
162-
<groupId>com.google.code.gson</groupId>
163-
<artifactId>gson</artifactId>
164-
<version>2.10.1</version>
165-
</dependency>
166158
<dependency>
167159
<groupId>com.jayway.jsonpath</groupId>
168160
<artifactId>json-path</artifactId>
@@ -177,12 +169,12 @@
177169
<dependency>
178170
<groupId>com.lmax</groupId>
179171
<artifactId>disruptor</artifactId>
180-
<version>3.4.4</version>
172+
<version>4.0.0</version>
181173
</dependency>
182174
<dependency>
183175
<groupId>com.mulesoft.munit</groupId>
184176
<artifactId>munit-tools</artifactId>
185-
<version>3.2.1</version>
177+
<version>3.3.0</version>
186178
<classifier>mule-plugin</classifier>
187179
<scope>test</scope>
188180
</dependency>

src/main/java/org/mule/extension/jsonlogger/internal/JsonloggerOperations.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.fasterxml.jackson.databind.node.ObjectNode;
66
import org.apache.commons.beanutils.BeanUtils;
77
import org.apache.commons.beanutils.PropertyUtils;
8-
import org.joda.time.DateTime;
98
import org.mule.extension.jsonlogger.api.pojos.LoggerProcessor;
109
import org.mule.extension.jsonlogger.api.pojos.Priority;
1110
import org.mule.extension.jsonlogger.api.pojos.ScopeTracePoint;
@@ -38,6 +37,10 @@
3837

3938
import javax.inject.Inject;
4039
import java.io.InputStream;
40+
import java.time.Instant;
41+
import java.time.ZoneId;
42+
import java.time.ZonedDateTime;
43+
import java.time.format.DateTimeFormatter;
4144
import java.util.*;
4245

4346
import static org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED;
@@ -74,6 +77,9 @@ public class JsonloggerOperations {
7477
@Inject
7578
private TransformationService transformationService;
7679

80+
// Date Formatter for log entries
81+
private static DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(System.getProperty("json.logger.dateformat", ""));
82+
7783
/**
7884
* Log a new entry
7985
*/
@@ -139,7 +145,8 @@ public void logger(@ParameterGroup(name = "Logger") @Expression(value = NOT_SUPP
139145
}
140146
if (v.getClass().getCanonicalName().equals("org.mule.runtime.api.metadata.TypedValue")) {
141147
LOGGER.debug("org.mule.runtime.api.metadata.TypedValue type was found for field: " + k);
142-
TypedValue<InputStream> typedVal = (TypedValue<InputStream>) v;
148+
@SuppressWarnings("unchecked")
149+
TypedValue<InputStream> typedVal = (TypedValue<InputStream>) v;
143150
LOGGER.debug("Parsing TypedValue for field " + k);
144151

145152
LOGGER.debug("TypedValue MediaType: " + typedVal.getDataType().getMediaType());
@@ -402,7 +409,7 @@ private Map<String, String> locationInfoToMap(ComponentLocation location) {
402409
locationInfo.put("rootContainer", location.getRootContainerName());
403410
locationInfo.put("component", location.getComponentIdentifier().getIdentifier().toString());
404411
locationInfo.put("fileName", location.getFileName().orElse(""));
405-
locationInfo.put("lineInFile", String.valueOf(location.getLineInFile().orElse(null)));
412+
locationInfo.put("lineInFile", String.valueOf(location.getLine().orElse(-1)));
406413
return locationInfo;
407414
}
408415

@@ -412,10 +419,11 @@ private String getFormattedTimestamp(Long loggerTimestamp) {
412419
- DateTime: Defaults to ISO format
413420
- TimeZone: Defaults to UTC. Refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for valid timezones
414421
*/
415-
DateTime dateTime = new DateTime(loggerTimestamp).withZone(org.joda.time.DateTimeZone.forID(System.getProperty("json.logger.timezone", "UTC")));
422+
ZonedDateTime dateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(loggerTimestamp),
423+
ZoneId.of(System.getProperty("json.logger.timezone", "UTC")));
416424
String timestamp = dateTime.toString();
417425
if (System.getProperty("json.logger.dateformat") != null && !System.getProperty("json.logger.dateformat").equals("")) {
418-
timestamp = dateTime.toString(System.getProperty("json.logger.dateformat"));
426+
timestamp = dateTimeFormatter.format(dateTime);
419427
}
420428
return timestamp;
421429
}

src/test/resources/json-logger.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
json.logger.application.name=${project.name}
77
json.logger.application.version=${project.version}
88

9-
json.logger.disabledFields=content
9+
json.logger.disabledFields=
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
<mule xmlns:json-logger="http://www.mulesoft.org/schema/mule/json-logger"
2-
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
1+
<mule
2+
xmlns:json-logger="http://www.mulesoft.org/schema/mule/json-logger"
3+
xmlns="http://www.mulesoft.org/schema/mule/core"
4+
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
35
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
57
http://www.mulesoft.org/schema/mule/json-logger http://www.mulesoft.org/schema/mule/json-logger/current/mule-json-logger.xsd">
68

7-
<json-logger:config name="JSON_Logger_Config" doc:name="JSON Logger Config"
8-
doc:id="d3c3b8c7-8417-4545-9e60-9c914261d272" environment="MUnit" />
9-
<configuration-properties file="json-logger.properties" />
9+
<json-logger:config name="JSON_Logger_Config"
10+
doc:name="JSON Logger Config"
11+
doc:id="d3c3b8c7-8417-4545-9e60-9c914261d272"
12+
environment="MUnit" />
13+
<configuration-properties
14+
file="json-logger.properties" />
1015

11-
<flow name="test-logger" doc:id="457201a2-e5c5-4ac6-ab29-ab63bc517a7b">
16+
<flow name="test-logger"
17+
doc:id="457201a2-e5c5-4ac6-ab29-ab63bc517a7b">
18+
<set-payload
19+
value='#[output application/json --- [{"A": 1, "B": 1}, {"A": 2}]]'
20+
doc:name="Test"
21+
doc:id="7941661a-16da-4271-9657-1d9580ab4c77" />
1222
<json-logger:logger doc:name="Logger" doc:id="8909da6b-5806-4001-a9d4-6593ee473743"
1323
message="another dummy" config-ref="JSON_Logger_Config" tracePoint="FLOW">
1424
</json-logger:logger>
15-
<set-payload value="all good" doc:name="Set Payload" doc:id="89ac164e-c37f-4b11-ad47-e30f4be9f09a" />
25+
<set-payload value="all good" doc:name="all good" doc:id="89ac164e-c37f-4b11-ad47-e30f4be9f09a" />
1626
</flow>
1727

1828
</mule>

0 commit comments

Comments
 (0)