Skip to content

Commit ba60a8f

Browse files
authored
Merge branch 'apache:master' into eiriklt/damerau-levenshtein-distance
2 parents 34675b5 + 5d356fd commit ba60a8f

31 files changed

+248
-165
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ jobs:
4545

4646
steps:
4747
- name: Checkout repository
48-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4949
with:
5050
persist-credentials: false
51-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
51+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
5252
with:
5353
path: ~/.m2/repository
5454
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -57,7 +57,7 @@ jobs:
5757
5858
# Initializes the CodeQL tools for scanning.
5959
- name: Initialize CodeQL
60-
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
60+
uses: github/codeql-action/init@192325c86100d080feab897ff886c34abd4c83a3 # 3.29.5
6161
with:
6262
languages: ${{ matrix.language }}
6363
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -68,7 +68,7 @@ jobs:
6868
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6969
# If this step fails, then you should remove it and run the build manually (see below)
7070
- name: Autobuild
71-
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
71+
uses: github/codeql-action/autobuild@192325c86100d080feab897ff886c34abd4c83a3 # 3.29.5
7272

7373
# ℹ️ Command-line programs to run using the OS shell.
7474
# 📚 https://git.io/JvXDl
@@ -82,4 +82,4 @@ jobs:
8282
# make release
8383

8484
- name: Perform CodeQL Analysis
85-
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
85+
uses: github/codeql-action/analyze@192325c86100d080feab897ff886c34abd4c83a3 # 3.29.5

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: 'Checkout Repository'
29-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3030
- name: 'Dependency Review PR'
31-
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
31+
uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ jobs:
3434
experimental: true
3535

3636
steps:
37-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3838
with:
3939
persist-credentials: false
4040
- name: Set up JDK ${{ matrix.java }}
41-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
41+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
4242
with:
4343
distribution: 'temurin'
4444
java-version: ${{ matrix.java }}

.github/workflows/scorecards-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
steps:
4141

4242
- name: "Checkout code"
43-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4444
with:
4545
persist-credentials: false
4646

@@ -64,6 +64,6 @@ jobs:
6464
retention-days: 5
6565

6666
- name: "Upload to code-scanning"
67-
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
67+
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # 3.29.5
6868
with:
6969
sarif_file: results.sarif

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>org.apache.commons</groupId>
2222
<artifactId>commons-parent</artifactId>
23-
<version>85</version>
23+
<version>87</version>
2424
</parent>
2525
<artifactId>commons-text</artifactId>
2626
<version>1.14.1-SNAPSHOT</version>
@@ -48,7 +48,7 @@
4848
<commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-text</commons.scmPubUrl>
4949
<commons.scmPubCheckoutDirectory>site-content</commons.scmPubCheckoutDirectory>
5050
<commons.lang3.version>3.18.0</commons.lang3.version>
51-
<commons.bytebuddy.version>1.17.6</commons.bytebuddy.version>
51+
<commons.bytebuddy.version>1.17.7</commons.bytebuddy.version>
5252
<commons.rng.version>1.6</commons.rng.version>
5353
<japicmp.skip>false</japicmp.skip>
5454
<jmh.version>1.37</jmh.version>

src/changes/changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ The <action> type attribute can be add,update,fix,remove.
4747
<body>
4848
<release version="1.14.1" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
4949
<!-- FIX -->
50+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix exception message typo in XmlStringLookup.XmlStringLookup(Map, Path...).</action>
51+
<action type="fix" dev="ggregory" due-to="Pierre Post, Sumit Bera, Alex Herbert, Gary Gregory" issue="TEXT-236">Inserting at end of a TextStringBuilder throws a StringIndexOutOfBoundsException.</action>
5052
<!-- ADD -->
5153
<action type="add" dev="ggregory" due-to="Piotr P. Karwasz, Gary Gregory">Add experimental CycloneDX VEX file #683.</action>
5254
<!-- UPDATE -->
55+
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons.bytebuddy.version from 1.17.6 to 1.17.7 #696.</action>
56+
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 85 to 87.</action>
5357
</release>
5458
<release version="1.14.0" date="2025-07-20" description="Release 1.14.0. Requires Java 8 or above.">
5559
<!-- FIX -->
@@ -63,7 +67,6 @@ The <action> type attribute can be add,update,fix,remove.
6367
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD AvoidBranchingStatementAsLastInLoop in TextStringBuilder.</action>
6468
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD AvoidBranchingStatementAsLastInLoop in StrBuilder.</action>
6569
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.text.translate.LookupTranslator.LookupTranslator(Map CharSequence>) now throws NullPointerException instead of java.security.InvalidParameterException.</action>
66-
6770
<!-- ADD -->
6871
<action type="add" dev="ggregory" due-to="Gary Gregory">Interface StringLookup now extends UnaryOperator&lt;String&gt;.</action>
6972
<action type="add" dev="ggregory" due-to="Gary Gregory">Interface TextRandomProvider extends IntUnaryOperator.</action>

src/conf/spotbugs-exclude-filter.xml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,39 @@
1919
xmlns="https://github.com/spotbugs/filter/3.0.0"
2020
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2121
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
22-
2322
<Match>
2423
<Class name="org.apache.commons.text.ExtendedMessageFormat" />
2524
<Bug code="UR" />
2625
</Match>
27-
26+
<Match>
27+
<Class name="org.apache.commons.text.ExtendedMessageFormat" />
28+
<!-- False positives -->
29+
<!-- [lines 225-227] SF_SWITCH_FALLTHROUGH -->
30+
<!-- [lines 424-426] SF_SWITCH_FALLTHROUGH -->
31+
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
32+
</Match>
2833
<Match>
2934
<!-- False positives in regard to Locale property exposing inner implementation
3035
details of class. However, Locale is not mutable and therefore safe in this context. -->
3136
<Class name="org.apache.commons.text.similarity.FuzzyScore" />
3237
<Bug code="EI,EI2" />
3338
</Match>
34-
3539
<Match>
3640
<Class name="org.apache.commons.text.StrTokenizer" />
3741
<Method name="clone" />
3842
<Bug code="CN" />
3943
</Match>
40-
4144
<Match>
4245
<Class name="org.apache.commons.text.StringTokenizer" />
4346
<Method name="clone" />
4447
<Bug code="CN" />
4548
</Match>
46-
4749
<!-- BiFunctionStringLookup#lookup catches NPE to return null -->
4850
<Match>
4951
<Class name="org.apache.commons.text.lookup.BiFunctionStringLookup" />
5052
<Method name="lookup" />
5153
<Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
5254
</Match>
53-
5455
<!-- FunctionStringLookup#lookup catches NPE to return null -->
5556
<Match>
5657
<Class name="org.apache.commons.text.lookup.FunctionStringLookup" />
@@ -62,14 +63,20 @@
6263
<Class name="~.*" />
6364
<Bug pattern="CT_CONSTRUCTOR_THROW" />
6465
</Match>
65-
<!-- Can't make ctor private until next major release -->
66+
<!-- Can't make ctor private until next major release -->
6667
<Match>
6768
<Class name="org.apache.commons.text.similarity.LevenshteinDetailedDistance" />
6869
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
69-
</Match>
70-
<!-- Can't make ctor private until next major release -->
70+
</Match>
71+
<!-- Can't make ctor private until next major release -->
7172
<Match>
7273
<Class name="org.apache.commons.text.similarity.LevenshteinDistance" />
7374
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
74-
</Match>
75+
</Match>
76+
<!-- RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT false positive: Exceptions can be thrown -->
77+
<Match>
78+
<Class name="org.apache.commons.text.TextStringBuilder" />
79+
<Method name="insert" />
80+
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
81+
</Match>
7582
</FindBugsFilter>

src/main/java/org/apache/commons/text/ExtendedMessageFormat.java

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,52 +135,42 @@ public ExtendedMessageFormat(final String pattern, final Locale locale) {
135135
* Constructs a new ExtendedMessageFormat.
136136
*
137137
* @param pattern the pattern to use, not null
138-
* @param locale the locale to use, not null
139-
* @param registry the registry of format factories, may be null
138+
* @param locale the locale to use, not null
139+
* @param registry the registry of format factories, may be null
140140
* @throws IllegalArgumentException in case of a bad pattern.
141141
*/
142-
public ExtendedMessageFormat(final String pattern,
143-
final Locale locale,
144-
final Map<String, ? extends FormatFactory> registry) {
142+
public ExtendedMessageFormat(final String pattern, final Locale locale, final Map<String, ? extends FormatFactory> registry) {
145143
super(EMPTY_PATTERN);
146144
setLocale(locale);
147-
this.registry = registry != null
148-
? Collections.unmodifiableMap(new HashMap<>(registry))
149-
: null;
145+
this.registry = registry != null ? Collections.unmodifiableMap(new HashMap<>(registry)) : null;
150146
applyPattern(pattern);
151147
}
152148

153149
/**
154150
* Constructs a new ExtendedMessageFormat for the default locale.
155151
*
156152
* @param pattern the pattern to use, not null
157-
* @param registry the registry of format factories, may be null
153+
* @param registry the registry of format factories, may be null
158154
* @throws IllegalArgumentException in case of a bad pattern.
159155
*/
160-
public ExtendedMessageFormat(final String pattern,
161-
final Map<String, ? extends FormatFactory> registry) {
156+
public ExtendedMessageFormat(final String pattern, final Map<String, ? extends FormatFactory> registry) {
162157
this(pattern, Locale.getDefault(Category.FORMAT), registry);
163158
}
164159

165160
/**
166-
* Consumes a quoted string, adding it to {@code appendTo} if
167-
* specified.
161+
* Consumes a quoted string, adding it to {@code appendTo} if specified.
168162
*
169-
* @param pattern pattern to parse
170-
* @param pos current parse position
163+
* @param pattern pattern to parse
164+
* @param pos current parse position
171165
* @param appendTo optional StringBuilder to append
172166
*/
173-
private void appendQuotedString(final String pattern, final ParsePosition pos,
174-
final StringBuilder appendTo) {
175-
assert pattern.toCharArray()[pos.getIndex()] == QUOTE
176-
: "Quoted string must start with quote character";
177-
167+
private void appendQuotedString(final String pattern, final ParsePosition pos, final StringBuilder appendTo) {
168+
assert pattern.toCharArray()[pos.getIndex()] == QUOTE : "Quoted string must start with quote character";
178169
// handle quote character at the beginning of the string
179170
if (appendTo != null) {
180171
appendTo.append(QUOTE);
181172
}
182173
next(pos);
183-
184174
final int start = pos.getIndex();
185175
final char[] c = pattern.toCharArray();
186176
for (int i = pos.getIndex(); i < pattern.length(); i++) {
@@ -195,8 +185,7 @@ private void appendQuotedString(final String pattern, final ParsePosition pos,
195185
next(pos);
196186
}
197187
}
198-
throw new IllegalArgumentException(
199-
"Unterminated quoted string at position " + start);
188+
throw new IllegalArgumentException("Unterminated quoted string at position " + start);
200189
}
201190

202191
/**
@@ -214,7 +203,6 @@ public final void applyPattern(final String pattern) {
214203
final ArrayList<Format> foundFormats = new ArrayList<>();
215204
final ArrayList<String> foundDescriptions = new ArrayList<>();
216205
final StringBuilder stripCustom = new StringBuilder(pattern.length());
217-
218206
final ParsePosition pos = new ParsePosition(0);
219207
final char[] c = pattern.toCharArray();
220208
int fmtCount = 0;
@@ -233,8 +221,7 @@ public final void applyPattern(final String pattern) {
233221
Format format = null;
234222
String formatDescription = null;
235223
if (c[pos.getIndex()] == START_FMT) {
236-
formatDescription = parseFormatDescription(pattern,
237-
next(pos));
224+
formatDescription = parseFormatDescription(pattern, next(pos));
238225
format = getFormat(formatDescription);
239226
if (format == null) {
240227
stripCustom.append(START_FMT).append(formatDescription);
@@ -249,8 +236,7 @@ public final void applyPattern(final String pattern) {
249236
throw new IllegalArgumentException("The validated expression is false");
250237
}
251238
if (c[pos.getIndex()] != END_FE) {
252-
throw new IllegalArgumentException(
253-
"Unreadable format element at position " + start);
239+
throw new IllegalArgumentException("Unreadable format element at position " + start);
254240
}
255241
//$FALL-THROUGH$
256242
default:

0 commit comments

Comments
 (0)