Skip to content

Commit c75601d

Browse files
committed
Use final
1 parent 76981db commit c75601d

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
7878
* @param charset the character set for encoding, or {@code null} if not applicable.
7979
* @param enableByteTracking {@code true} to enable byte tracking; {@code false} to disable it.
8080
*/
81-
ExtendedBufferedReader(final Reader reader, Charset charset, boolean enableByteTracking) {
81+
ExtendedBufferedReader(final Reader reader, final Charset charset, final boolean enableByteTracking) {
8282
super(reader);
8383
if (charset != null && enableByteTracking) {
8484
encoder = charset.newEncoder();
@@ -133,22 +133,21 @@ long getBytesRead() {
133133
* @return the byte length of the character.
134134
* @throws CharacterCodingException if the character cannot be encoded.
135135
*/
136-
private int getEncodedCharLength(int current) throws CharacterCodingException {
136+
private int getEncodedCharLength(final int current) throws CharacterCodingException {
137137
final char cChar = (char) current;
138138
final char lChar = (char) lastChar;
139139
if (!Character.isSurrogate(cChar)) {
140140
return encoder.encode(
141141
CharBuffer.wrap(new char[] {cChar})).limit();
142+
}
143+
if (Character.isHighSurrogate(cChar)) {
144+
// Move on to the next char (low surrogate)
145+
return 0;
146+
} else if (Character.isSurrogatePair(lChar, cChar)) {
147+
return encoder.encode(
148+
CharBuffer.wrap(new char[] {lChar, cChar})).limit();
142149
} else {
143-
if (Character.isHighSurrogate(cChar)) {
144-
// Move on to the next char (low surrogate)
145-
return 0;
146-
} else if (Character.isSurrogatePair(lChar, cChar)) {
147-
return encoder.encode(
148-
CharBuffer.wrap(new char[] {lChar, cChar})).limit();
149-
} else {
150-
throw new CharacterCodingException();
151-
}
150+
throw new CharacterCodingException();
152151
}
153152
}
154153

src/test/java/org/apache/commons/csv/JiraCsv196Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class JiraCsv196Test {
3131

32-
private Reader getTestInput(String path) {
32+
private Reader getTestInput(final String path) {
3333
return new InputStreamReader(ClassLoader.getSystemClassLoader().getResourceAsStream(path));
3434
}
3535

0 commit comments

Comments
 (0)