Uploaded image for project: 'Hibernate Validator'
  1. HV-1585

Omit the cache lookup in AbstractMessageInterpolator for the simple text messages

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects versions: None
    • Fix versions: 6.0.9.Final
    • Components: engine
    • Labels:
      None

      Description

      In case of simple custom string message defined by the user we should not cache it and just return an unescaped version of it.

      An example of such message:

      public class Person {
          @NotNull(message = "name should not be `null`")
          String name;
      }
      

      Benchmarks for such a change:

      6.0.8:
      Benchmark                                                Mode  Cnt     Score     Error   Units
      SimpleValidation.testSimpleBeanValidation               thrpt   20  1020.530 ±  29.516  ops/ms
      SimpleValidation.testSimpleBeanValidationCustomMessage  thrpt   20  1140.450 ± 111.788  ops/ms
      
      changes:
      Benchmark                                                Mode  Cnt     Score    Error   Units
      SimpleValidation.testSimpleBeanValidation               thrpt   20  1087.163 ± 30.949  ops/ms
      SimpleValidation.testSimpleBeanValidationCustomMessage  thrpt   20  1339.740 ± 26.829  ops/ms
      

        Attachments

          Activity

            People

            • Assignee:
              markob Marko Bekhta
              Reporter:
              markob Marko Bekhta
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: