You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/09/21 10:17:25 UTC

[GitHub] [commons-lang] stawirej opened a new pull request, #953: Handle error messages with special characters.

stawirej opened a new pull request, #953:
URL: https://github.com/apache/commons-lang/pull/953

   Currently Validate.isTrue(false, MESSAGE) when MESSAGE  contains special characters, which are part of the message and should not be interpreted as the placeholders for parameters used in String.format() it throws e.g. UnknownFormatConversionException when desired behaviour should be to throw IllegalArgumentException with message containing special characters.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1255165118

   @stawirej I am not sure of the release schedule. There are a lot of fixes in lang 3.13-SNAPSHOT so a release may be done within a few months.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] codecov-commenter commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253753176

   # [Codecov](https://codecov.io/gh/apache/commons-lang/pull/953?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#953](https://codecov.io/gh/apache/commons-lang/pull/953?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (34b77c8) into [master](https://codecov.io/gh/apache/commons-lang/commit/e81855a208c909f46e1bf346d7982bd77be13476?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e81855a) will **increase** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@            Coverage Diff            @@
   ##             master     #953   +/-   ##
   =========================================
     Coverage     91.98%   91.99%           
   - Complexity     7423     7426    +3     
   =========================================
     Files           189      189           
     Lines         15666    15669    +3     
     Branches       2913     2913           
   =========================================
   + Hits          14411    14415    +4     
     Misses          677      677           
   + Partials        578      577    -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/commons-lang/pull/953?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Ξ” | |
   |---|---|---|
   | [...c/main/java/org/apache/commons/lang3/Validate.java](https://codecov.io/gh/apache/commons-lang/pull/953/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvbGFuZzMvVmFsaWRhdGUuamF2YQ==) | `99.31% <100.00%> (+0.01%)` | :arrow_up: |
   | [...apache/commons/lang3/reflect/ConstructorUtils.java](https://codecov.io/gh/apache/commons-lang/pull/953/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvbGFuZzMvcmVmbGVjdC9Db25zdHJ1Y3RvclV0aWxzLmphdmE=) | `86.00% <0.00%> (+2.00%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] asfgit closed pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #953: Handle error messages with special characters.
URL: https://github.com/apache/commons-lang/pull/953


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976496823


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +155,29 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception with the specified message. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * @param expression  the boolean expression to check
+     * @param message  the exception message if invalid
+     * @throws IllegalArgumentException if expression is {@code false}
+     * @see #isTrue(boolean, String, long)
+     * @see #isTrue(boolean, String, double)
+     * @see #isTrue(boolean, String, Object...)
+     */

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1255446932

   Right, before the end of the year for certain, much before that I hope. I have a couple of other releases to push through first.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253608662

   New public and protected APIs must have Javadoc since tags.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976350961


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>
+     *
+     * @param expression  the boolean expression to check

Review Comment:
   There is no `@param` tag for `message`.



##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>
+     *
+     * @param expression  the boolean expression to check
+     * @throws IllegalArgumentException if expression is {@code false}
+     * @see #isTrue(boolean, String, long)
+     * @see #isTrue(boolean, String, double)
+     * @see #isTrue(boolean, String, Object...)
+     */
+    public static void isTrue(final boolean expression, final String message) {
+        if (!expression) {
+            throw new IllegalArgumentException(String.valueOf(message));

Review Comment:
   `String.valueOf(String)` is not required. Note that String.valueOf(null) will return null and that is handled fine by the IllegalArgumentException constructor. So just pass through the String message argument (which can be null).
   



##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according

Review Comment:
   `an exception with the specified message`
   
   Note: This change makes the code example on line 143 invalid. Please update the javadoc in the preceding method to remove:
   ```Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>```
   



##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>

Review Comment:
   This is not required.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976396311


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>
+     *
+     * @param expression  the boolean expression to check

Review Comment:
   Done.



##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handle error messages with special characters. [commons-lang]

Posted by "php-coder (via GitHub)" <gi...@apache.org>.
php-coder commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1788431876

   This change was backward incompatible by the way. Previously, in order to have `%` character in a message, we doubled it (`%%`). After update, both percentage are shown, so the (trivial) changes in code are required.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976396618


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253760398

   Why just this one method and not all of the message/vargs methods in the Validate class? 
   Alternatively, we could deprecate the class and move it to Commons Validator and complete the task there.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976855201


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -1265,7 +1264,11 @@ public static void isAssignableFrom(final Class<?> superType, final Class<?> typ
     public static void isAssignableFrom(final Class<?> superType, final Class<?> type, final String message, final Object... values) {
         // TODO when breaking BC, consider returning type
         if (!superType.isAssignableFrom(type)) {
-            throw new IllegalArgumentException(String.format(message, values));
+            throw new IllegalArgumentException(getMessage(message, values));
         }
     }
+
+    private static String getMessage(final String message, final Object... values) {

Review Comment:
   This all looks fine. Please add a comment to the private method, e.g. 
   ```
   Get the message using {@link String#format(String, Object...) String.format(message, values)}
   if the values are not empty, otherwise return the message unformatted.
   This method exists to allow validation methods declaring a String message and varargs parameters
   to be used without any message parameters when the message contains special characters,
   e.g. {@code Validate.isTrue(false, "%Failed%")}.
   @param ...
   @return ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1254216490

   @stawirej Thanks for the contribution


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976395832


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +156,30 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression.
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * <p>The exception message will be converted to a string using String.valueOf(Object).</p>
+     *
+     * @param expression  the boolean expression to check
+     * @throws IllegalArgumentException if expression is {@code false}
+     * @see #isTrue(boolean, String, long)
+     * @see #isTrue(boolean, String, double)
+     * @see #isTrue(boolean, String, Object...)
+     */
+    public static void isTrue(final boolean expression, final String message) {
+        if (!expression) {
+            throw new IllegalArgumentException(String.valueOf(message));

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976491454


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -156,6 +155,29 @@ public static void isTrue(final boolean expression, final String message, final
         }
     }
 
+    /**
+     * Validate that the argument condition is {@code true}; otherwise
+     * throwing an exception with the specified message. This method is useful when validating according
+     * to an arbitrary boolean expression, such as validating a
+     * primitive number or using your own custom validation expression
+     *
+     * <pre>
+     * Validate.isTrue(i &gt; 0, "The value must be greater than 0");
+     * Validate.isTrue(myObject.isOk(), "The object is not okay");</pre>
+     *
+     * @param expression  the boolean expression to check
+     * @param message  the exception message if invalid
+     * @throws IllegalArgumentException if expression is {@code false}
+     * @see #isTrue(boolean, String, long)
+     * @see #isTrue(boolean, String, double)
+     * @see #isTrue(boolean, String, Object...)
+     */

Review Comment:
   Add a `@Since 3.13.0`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253922374

   > IIUC the fix should remove the new public method and then add a private function:
   > 
   > ```java
   > private static String getMessage(final String message, final Object... values) {
   >     return values.length == 0 ? message : String.format(message, values);
   > }
   > ```
   > 
   > for use as:
   > 
   > ```java
   > public static void isTrue(final boolean expression, final String message, final Object... values) {
   >     if (!expression) {
   >         throw new IllegalArgumentException(getMessage(message, values));
   >     }
   > }
   > ```
   > 
   > This can be used in all call sites that have a varargs.
   
   Clever! πŸ‘πŸ˜€
   And call it from the other vararg methods.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253975022

   > > IIUC the fix should remove the new public method and then add a private function:
   > > ```java
   > > private static String getMessage(final String message, final Object... values) {
   > >     return values.length == 0 ? message : String.format(message, values);
   > > }
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > for use as:
   > > ```java
   > > public static void isTrue(final boolean expression, final String message, final Object... values) {
   > >     if (!expression) {
   > >         throw new IllegalArgumentException(getMessage(message, values));
   > >     }
   > > }
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > This can be used in all call sites that have a varargs.
   > 
   > Clever! πŸ‘πŸ˜€ And call it from the other vararg methods.
   
   Done. Please review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] aherbert commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
aherbert commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253767801

   IIUC the fix should remove the new public method and then add a private function:
   ```Java
   private static String getMessage(final String message, final Object... values) {
       return values.length == 0 ? message : String.format(message, values);
   }
   ```
   for use as:
   ```Java
   public static void isTrue(final boolean expression, final String message, final Object... values) {
       if (!expression) {
           throw new IllegalArgumentException(getMessage(message, values));
       }
   }
   ```
   This can be used in all call sites that have a varargs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on a diff in pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on code in PR #953:
URL: https://github.com/apache/commons-lang/pull/953#discussion_r976937060


##########
src/main/java/org/apache/commons/lang3/Validate.java:
##########
@@ -1265,7 +1264,11 @@ public static void isAssignableFrom(final Class<?> superType, final Class<?> typ
     public static void isAssignableFrom(final Class<?> superType, final Class<?> type, final String message, final Object... values) {
         // TODO when breaking BC, consider returning type
         if (!superType.isAssignableFrom(type)) {
-            throw new IllegalArgumentException(String.format(message, values));
+            throw new IllegalArgumentException(getMessage(message, values));
         }
     }
+
+    private static String getMessage(final String message, final Object... values) {

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1253583268

   > Adding this method will change source compatibility to use this method in place of the varargs method when there are no supplied args. This should be reflected in a javadoc change to that method.
   
   Done. Could you please review if javadoc is updated as you had in mind?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] stawirej commented on pull request #953: Handle error messages with special characters.

Posted by GitBox <gi...@apache.org>.
stawirej commented on PR #953:
URL: https://github.com/apache/commons-lang/pull/953#issuecomment-1255053677

   @aherbert  Thank you for your help! When do you plan to release it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org