This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 95ccef20bc Issue 5694: Log a warning if 'u' is found in time functions 
format string
95ccef20bc is described below

commit 95ccef20bcf845a937ba242a0f9b2e1790aadefa
Author: Felix Schumacher <[email protected]>
AuthorDate: Mon Feb 20 15:07:13 2023 +0100

    Issue 5694: Log a warning if 'u' is found in time functions format string
    
    A warning will be logged,  if the code 'u' is found in the format string,
    as the meaning for that code has changed from day-of-week to year.
    
    Part of #5694
---
 .../main/resources/org/apache/jmeter/resources/messages.properties | 1 +
 .../resources/org/apache/jmeter/resources/messages_fr.properties   | 1 +
 .../src/main/java/org/apache/jmeter/functions/TimeFunction.java    | 7 +++++++
 xdocs/changes.xml                                                  | 4 +++-
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
index 4b81a58301..dc93ac77c1 100644
--- 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
+++ 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
@@ -1331,6 +1331,7 @@ throughput_control_perthread_label=Per User
 throughput_control_title=Throughput Controller
 throughput_control_tplabel=Throughput
 time_format=Format string for SimpleDateFormat (optional)
+time_format_changed=Formatters for time function has been changed from 
SimpleDateFormat to DateTimeFormatter. Especially the meaning of 'u' has 
changed from day-of-week to year. Please check and update your format strings 
accordingly
 time_format_random=Format string for DateTimeFormatter (optional) (default 
yyyy-MM-dd)
 time_format_shift=Format string for DateTimeFormatter (optional) (default unix 
timestamp in millisecond)
 timelim=Time limit
diff --git 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
index 729648defc..5a68c3ebd5 100644
--- 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
+++ 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
@@ -1320,6 +1320,7 @@ throughput_control_perthread_label=Par utilisateur
 throughput_control_title=Contrôleur Débit
 throughput_control_tplabel=Débit \:
 time_format=Chaîne de formatage sur le modèle SimpleDateFormat (optionnel)
+time_format_changed=Les formateurs pour la fonction de temps ont été modifiés 
de SimpleDateFormat à DateTimeFormatter. En particulier, la signification de 
'u' a changé du jour de la semaine à l'année. Veuillez vérifier et mettre à 
jour vos chaînes de format en conséquence
 time_format_random=Chaîne de formatage sur le modèle DateTimeFormatter 
(optionnel) ( défaut \: yyyy-MM-dd )
 time_format_shift=Chaîne de formatage sur le modèle DateTimeFormatter 
(optionnel) ( défaut \: unix timestamp en millisecondes )
 timelim=Limiter le temps de réponses à (ms)
diff --git 
a/src/functions/src/main/java/org/apache/jmeter/functions/TimeFunction.java 
b/src/functions/src/main/java/org/apache/jmeter/functions/TimeFunction.java
index 69c90be61d..65e6c01a9d 100644
--- a/src/functions/src/main/java/org/apache/jmeter/functions/TimeFunction.java
+++ b/src/functions/src/main/java/org/apache/jmeter/functions/TimeFunction.java
@@ -32,6 +32,8 @@ import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.threads.JMeterVariables;
 import org.apache.jmeter.util.JMeterUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 // See org.apache.jmeter.functions.TestTimeFunction for unit tests
 
@@ -50,6 +52,8 @@ public class TimeFunction extends AbstractFunction {
     // Only modified in class init
     private static final Map<String, String> aliases = new HashMap<>();
 
+    private static final Logger log = 
LoggerFactory.getLogger(TimeFunction.class);
+
     static {
         desc.add(JMeterUtils.getResString("time_format")); //$NON-NLS-1$
         desc.add(JMeterUtils.getResString("function_name_paropt")); 
//$NON-NLS-1$
@@ -92,6 +96,9 @@ public class TimeFunction extends AbstractFunction {
                 long div = Long.parseLong(fmt.substring(1)); // should never 
case NFE
                 datetime = Long.toString(System.currentTimeMillis() / div);
             } else {
+                if (fmt.contains("u")) {
+                    log.warn(JMeterUtils.getResString("time_format_changed"));
+                }
                 DateTimeFormatter df = DateTimeFormatter // Not synchronised, 
so can't be shared
                         .ofPattern(fmt)
                         .withZone(ZoneId.systemDefault());
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index dcc7b18e6b..508296c40a 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -160,7 +160,9 @@ Summary
 
 <h3>Documentation</h3>
 <ul>
-  <li><issue>5694</issue>Document changed formatter for <funclink 
name="__time()"/></li>
+  <li><issue>5694</issue>Document changed formatter for <funclink 
name="__time()"/>. A warning will be logged,
+  if the code <code>u</code> is found in the format string, as the meaning for 
that code has changed from <em>day-of-week</em>
+  to <em>year</em>.</li>
 </ul>
 
 <h3>General</h3>

Reply via email to