From c59144cadba639dbe2b5105e0bc855e5952b3382 Mon Sep 17 00:00:00 2001 From: Pavel Antoshin Date: Thu, 11 Jun 2026 12:41:49 +0200 Subject: [PATCH 1/2] Do not set time zone on suco context clone when creating a log line --- Audit trail.mpr | Bin 6770688 -> 6770688 bytes gradle.properties | 2 +- .../audittrail/log/CreateLogObject.java | 32 ++++++++++-------- marketplace/release-notes/10.2.2.txt | 1 + 4 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 marketplace/release-notes/10.2.2.txt diff --git a/Audit trail.mpr b/Audit trail.mpr index 1e9aa31bdb94a7cac737bc7c9f1ee9fc8d9aea91..3d8fde6bb8db148e19c0802e0c5656214495361f 100644 GIT binary patch delta 602 zcmWm8OH&d70Kjnf6o#~vIy zIrbGAXWWa^hp-bTZ+-#4K>rTE`|tGEx%Cv^+=B7FB_bHVx2_bMIOFyDs<*|q`~f}`2)v<;Nq)O@kJi>}%~=3TEiXEFb_ ziS<*^qizi+0TiSxS}X|Z78}g$D{f1)J`m;%10-A2_rR{ zP3u1|WY>xiEZoa3)S(^^@d%I6fJQW-8E&-T37(=AZD>aaI?;u0^q?1gcm@yp;e`)= z3?Kjr{~ymWh#?Fkgb|El3@f3vHTzHF$Na^ delta 542 zcmWm8Ni#wL0KjoiDCwo_$`V;q-b0J*Bxxa(eTyuU8D@~qW*oXWFb+`v#wodQH6Vy;%$&f~M@&Zg*%7#hZLGn@;El|oT(+MkXF_Alg1`SCeyj0t_&->?xC zs6-X2QG;64p&llf(SSxYp&1smpcPiMp&cFQL>IbYLl5k5pcfKk{2%%;04H2 dateFormats = new LinkedList(); if (Constants.getLogServerTimeZoneDateNotation()) { - dateFormats.add(dateInZone(date, TimeZone.getTimeZone(Constants.getServerTimeZone()))); + dateFormats.add(dateInZone(date, Constants.getServerTimeZone())); } - if (Constants.getLogSessionTimeZoneDateNotation() && context.getSession() != null && context.getSession().getTimeZone() != null) { - dateFormats.add(dateInZone(date, context.getSession().getTimeZone())); + if (Constants.getLogSessionTimeZoneDateNotation()) { + dateFormats.add(dateInZone(date, getSessionTimeZone(context))); } return dateFormats.stream().collect(Collectors.joining(" / ")); } - private static String dateInZone(final Date date, final TimeZone zone) { + private static String getSessionTimeZone(final IContext context) { + if (context.getSession() != null && context.getSession().getTimeZone() != null) { + return context.getSession().getTimeZone().getID(); + } + + if (Constants.getServerTimeZone() != null && !Constants.getServerTimeZone().isEmpty()) { + return Constants.getServerTimeZone(); + } + + return "GMT"; + } + + private static String dateInZone(final Date date, final String zone) { final DateFormat dateFormat = new SimpleDateFormat(Constants.getLogLineDateFormat()); - dateFormat.setTimeZone(zone); - return dateFormat.format(date) + " (" + zone.getID() + ")"; + dateFormat.setTimeZone(TimeZone.getTimeZone(zone)); + return dateFormat.format(date) + " (" + zone + ")"; } } diff --git a/marketplace/release-notes/10.2.2.txt b/marketplace/release-notes/10.2.2.txt new file mode 100644 index 0000000..62e18e3 --- /dev/null +++ b/marketplace/release-notes/10.2.2.txt @@ -0,0 +1 @@ +We removed the usage of a deprecated method to make the module compatible with future releases of Studio Pro \ No newline at end of file From 837bf79133e868bebd7dea4a8207c3aa6ba65eaf Mon Sep 17 00:00:00 2001 From: Pavel Antoshin Date: Tue, 16 Jun 2026 11:18:16 +0200 Subject: [PATCH 2/2] Remove TestTimezone because we no longer change session time zone in the implementation --- .../mendix/audittrail/tests/TestTimezone.java | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/test/java/com/mendix/audittrail/tests/TestTimezone.java diff --git a/src/test/java/com/mendix/audittrail/tests/TestTimezone.java b/src/test/java/com/mendix/audittrail/tests/TestTimezone.java deleted file mode 100644 index 049b05b..0000000 --- a/src/test/java/com/mendix/audittrail/tests/TestTimezone.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mendix.audittrail.tests; - -import org.junit.Assert; -import org.junit.Test; -import test_crm.proxies.Company; - -import java.util.Calendar; -import java.util.TimeZone; - -public class TestTimezone extends TestAuditBase { - - private static Long createDate(Boolean isDST) { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.YEAR, 1991); - if (isDST) calendar.set(Calendar.MONTH, 6); - else calendar.set(Calendar.MONTH, 1); - calendar.set(Calendar.DATE, 4); - calendar.set(Calendar.HOUR, 4); - calendar.set(Calendar.MINUTE, 45); - calendar.setTimeZone(TimeZone.getTimeZone("Europe/Amsterdam")); - return calendar.getTimeInMillis(); - } - - @Test - public void testTimeZoneNotChanged() throws Exception { - // Set initial timezone - updateConstant("AuditTrail.ServerTimeZone", "Europe/Amsterdam"); - context.createSudoClone().getSession().setTimeZone("Europe/Amsterdam"); - - final Company company = new Company(context); - - TimeZone timezoneBeforeCommit = context.getSession().getTimeZone(); - - // Cause CreateLogObject.createAuditLogItems to be called - company.commit(); - - TimeZone timezoneAfterCommit = context.getSession().getTimeZone(); - - Assert.assertEquals(timezoneBeforeCommit.getOffset(createDate(false)), timezoneAfterCommit.getOffset(createDate(false))); - Assert.assertEquals(timezoneBeforeCommit.getOffset(createDate(true)), timezoneAfterCommit.getOffset(createDate(true))); - } -}