[
https://issues.apache.org/jira/browse/TEXT-211?focusedWorklogId=750906&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-750906
]
ASF GitHub Bot logged work on TEXT-211:
---------------------------------------
Author: ASF GitHub Bot
Created on: 31/Mar/22 10:59
Start Date: 31/Mar/22 10:59
Worklog Time Spent: 10m
Work Description: garydgregory commented on a change in pull request #281:
URL: https://github.com/apache/commons-text/pull/281#discussion_r836796333
##########
File path: src/main/java/org/apache/commons/text/TextStringBuilder.java
##########
@@ -1850,7 +1850,25 @@ public boolean equals(final Object obj) {
* @return true if the builders contain the same characters in the same
order
*/
public boolean equals(final TextStringBuilder other) {
- return other != null && Arrays.equals(buffer, other.buffer);
+ if(this == other) {
Review comment:
Add a space before the open parenthesis.
##########
File path: src/main/java/org/apache/commons/text/TextStringBuilder.java
##########
@@ -1850,7 +1850,25 @@ public boolean equals(final Object obj) {
* @return true if the builders contain the same characters in the same
order
*/
public boolean equals(final TextStringBuilder other) {
- return other != null && Arrays.equals(buffer, other.buffer);
+ if(this == other) {
+ return true;
+ }
+ if(other == null) {
Review comment:
Add a space before the open parenthesis.
##########
File path: src/test/java/org/apache/commons/text/TextStringBuilderTest.java
##########
@@ -2276,4 +2289,4 @@ public void testWrap_CharArray_Int_Exceptions() {
assertThrows(IllegalArgumentException.class, () ->
TextStringBuilder.wrap(ArrayUtils.EMPTY_CHAR_ARRAY, 1));
}
-}
+}
Review comment:
@sebx59
MIssing blank line as the last line (see red icon warning from GitHub above).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 750906)
Time Spent: 5h 20m (was: 5h 10m)
> TextStringBuilder equals method changed behaviour from 1.8 to 1.9
> -----------------------------------------------------------------
>
> Key: TEXT-211
> URL: https://issues.apache.org/jira/browse/TEXT-211
> Project: Commons Text
> Issue Type: Bug
> Affects Versions: 1.9
> Reporter: Nikolaos Georgiou
> Priority: Major
> Time Spent: 5h 20m
> Remaining Estimate: 0h
>
> We found a regression (or breaking compatibility change) in the
> TextStringBuilder equals method when upgrading commons-text from 1.8 to 1.9
>
> The 1.8 version (
> [https://github.com/apache/commons-text/blob/commons-text-1.8/src/main/java/org/apache/commons/text/TextStringBuilder.java#L2915]
> ) would only compare the parts of the buffer that fall within the range
> 0..size.
> The 1.9 version (
> [https://github.com/apache/commons-text/blob/rel/commons-text-1.9/src/main/java/org/apache/commons/text/TextStringBuilder.java#L1855]
> ) compares the entire buffer arrays.
> If a TextStringBuilder has extra capacity in the buffer, comparison fails.
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)