Skip to content

Commit 5d856dd

Browse files
author
Timothy O'Brien
committed
Addresses issue 37894. Order of static initialization causes
an NPE when trying to use static US_ENGLISH in Soundex. Issue was found by Reggie Riser. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/codec/trunk@366897 13f79535-47bb-0310-9956-ffa450edef68
1 parent 252f8e7 commit 5d856dd

3 files changed

Lines changed: 26 additions & 39 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The commons-codec team is pleased to announce the Codec 1.3 release!
1+
The commons-codec team is pleased to announce the Codec 1.3.1 release!
22

33
http://jakarta.apache.org/commons/codec/
44

@@ -11,42 +11,16 @@ Changes in this version include:
1111

1212
New Features:
1313

14-
o BinaryCodec: Encodes and decodes binary to and from Strings of 0s and 1s.
15-
Issue: 27813. Thanks to Alex Karasulu.
16-
o QuotedPrintableCodec: Codec for RFC 1521 MIME (Multipurpose Internet Mail
17-
Extensions) Part One. Rules #3, #4, and #5 of the quoted-printable spec are
18-
not implemented yet. See also issue 27789. Issue: 26617. Thanks to Oleg
19-
Kalnichevski.
20-
o BCodec: Identical to the Base64 encoding defined by RFC 1521 and allows a
21-
character set to be specified. Issue: 26617. Thanks to Oleg Kalnichevski.
22-
o QCodec: Similar to the Quoted-Printable content-transfer-encoding defined
23-
in RFC 1521 and designed to allow text containing mostly ASCII characters
24-
to be decipherable on an ASCII terminal without decoding. Issue: 26617.
25-
Thanks to Oleg Kalnichevski.
26-
o Soundex: Implemented the DIFFERENCE algorithm. Issue: 25243. Thanks to
27-
Matthew Inger.
28-
o RefinedSoundex: Implemented the DIFFERENCE algorithm. Issue: 25243. Thanks
29-
to Matthew Inger.
30-
14+
o
3115
Fixed bugs:
3216

33-
o The default URL encoding logic was broken. Issue: 25995. Thanks to Oleg
34-
Kalnichevski.
35-
o Base64 chunked encoding not compliant with RFC 2045 section 2.1 CRLF.
36-
Issue: 27781. Thanks to Gary D. Gregory.
37-
o Hex converts illegal characters to 255. Issue: 28455.
38-
o Metaphone now correctly handles a silent B in a word that ends in MB.
39-
"COMB" is encoded as "KM", before this fix "COMB" was encoded as "KMB".
40-
Issue: 28457.
41-
o Added missing tags in Javadoc comments.
42-
o General Javadoc improvements.
17+
o Using US_ENGLISH in Soundex causes an NPE. Issue addressed and
18+
test case added to SoundexTest.
19+
Issue: 37894. Thanks to Reggie Riser.
4320

4421
Changes:
4522

46-
o This version is relesed under the Apache License 2.0 , please see
47-
LICENSE.txt. Previous versions were released under the Apache License 1.1.
48-
o The Board recommendation to remove Javadoc author tags has been
49-
implemented. All author tags are now "Apache Software Foundation".
23+
o
5024

5125
Have fun!
5226
-The commons-codec team

src/java/org/apache/commons/codec/language/Soundex.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
*/
2929
public class Soundex implements StringEncoder {
3030

31-
/**
32-
* An instance of Soundex using the US_ENGLISH_MAPPING mapping.
33-
*
34-
* @see #US_ENGLISH_MAPPING
35-
*/
36-
public static final Soundex US_ENGLISH = new Soundex();
37-
3831
/**
3932
* This is a default mapping of the 26 letters used in US English. A value of <code>0</code> for a letter position
4033
* means do not encode.
@@ -55,6 +48,14 @@ public class Soundex implements StringEncoder {
5548
*/
5649
public static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray();
5750

51+
/**
52+
* An instance of Soundex using the US_ENGLISH_MAPPING mapping.
53+
*
54+
* @see #US_ENGLISH_MAPPING
55+
*/
56+
public static final Soundex US_ENGLISH = new Soundex();
57+
58+
5859
/**
5960
* Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. This
6061
* return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or

src/test/org/apache/commons/codec/language/SoundexTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,16 @@ public void testUsMappingEWithAcute() {
367367
// expected
368368
}
369369
}
370+
371+
// This test fails.
372+
public void testUsEnglishStatic()
373+
{
374+
assertEquals( Soundex.US_ENGLISH.soundex( "Williams" ), "W452" );
375+
}
376+
377+
// This test succeeds.
378+
public void testNewInstance()
379+
{
380+
assertEquals( new Soundex().soundex( "Williams" ), "W452" );
381+
}
370382
}

0 commit comments

Comments
 (0)