Skip to content

Commit 7f5b241

Browse files
committed
Remove unnecessary checked exceptions and clean up code
DEVSIX-1058
1 parent 108ccc2 commit 7f5b241

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

io/src/main/java/com/itextpdf/io/font/cmap/CMapToUnicode.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,19 @@ void addChar(int cid, char[] uni) {
166166

167167
@Override
168168
void addChar(String mark, CMapObject code) {
169-
try {
170-
if (mark.length() == 1) {
171-
char[] dest = createCharsFromDoubleBytes((byte[]) code.getValue());
172-
byteMappings.put((int) mark.charAt(0), dest);
173-
} else if (mark.length() == 2) {
174-
char[] dest = createCharsFromDoubleBytes((byte[]) code.getValue());
175-
byteMappings.put((mark.charAt(0) << 8) + mark.charAt(1), dest);
176-
} else {
177-
Logger logger = LoggerFactory.getLogger(CMapToUnicode.class);
178-
logger.warn(LogMessageConstant.TOUNICODE_CMAP_MORE_THAN_2_BYTES_NOT_SUPPORTED);
179-
}
180-
} catch (java.io.IOException e) {
181-
throw new RuntimeException();
169+
if (mark.length() == 1) {
170+
char[] dest = createCharsFromDoubleBytes((byte[]) code.getValue());
171+
byteMappings.put((int) mark.charAt(0), dest);
172+
} else if (mark.length() == 2) {
173+
char[] dest = createCharsFromDoubleBytes((byte[]) code.getValue());
174+
byteMappings.put((mark.charAt(0) << 8) + mark.charAt(1), dest);
175+
} else {
176+
Logger logger = LoggerFactory.getLogger(CMapToUnicode.class);
177+
logger.warn(LogMessageConstant.TOUNICODE_CMAP_MORE_THAN_2_BYTES_NOT_SUPPORTED);
182178
}
183179
}
184180

185-
private char[] createCharsFromSingleBytes(byte[] bytes) throws java.io.IOException {
181+
private char[] createCharsFromSingleBytes(byte[] bytes) {
186182
if (bytes.length == 1) {
187183
return new char[]{(char) (bytes[0] & 0xff)};
188184
} else {
@@ -194,7 +190,7 @@ private char[] createCharsFromSingleBytes(byte[] bytes) throws java.io.IOExcepti
194190
}
195191
}
196192

197-
private char[] createCharsFromDoubleBytes(byte[] bytes) throws java.io.IOException {
193+
private char[] createCharsFromDoubleBytes(byte[] bytes) {
198194
char[] chars = new char[bytes.length / 2];
199195
for (int i = 0; i < bytes.length; i+=2) {
200196
chars[i/2] = (char)(((bytes[i] & 0xff) << 8) + (bytes[i+1] & 0xff));

0 commit comments

Comments
 (0)