Skip to content

Commit d6d1180

Browse files
committed
Don't consume MissingResourceExceptions.
1 parent 4187be8 commit d6d1180

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

build.gradle

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

1515
subprojects {
1616
group = 'org.httprpc'
17-
version = '4.9.1'
17+
version = '4.9.2'
1818

1919
apply plugin: 'java-library'
2020

kilo-client/src/main/java/org/httprpc/kilo/io/CSVEncoder.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.HashMap;
2424
import java.util.List;
2525
import java.util.Map;
26-
import java.util.MissingResourceException;
2726
import java.util.ResourceBundle;
2827

2928
import static org.httprpc.kilo.util.Optionals.*;
@@ -123,11 +122,7 @@ private void encode(Iterable<?> rows, Writer writer) throws IOException {
123122
if (resourceBundle == null) {
124123
heading = key;
125124
} else {
126-
try {
127-
heading = resourceBundle.getObject(key).toString();
128-
} catch (MissingResourceException exception) {
129-
heading = key;
130-
}
125+
heading = resourceBundle.getObject(key).toString();
131126
}
132127

133128
encode(heading, writer);

kilo-client/src/main/java/org/httprpc/kilo/io/TemplateEncoder.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.util.LinkedList;
4141
import java.util.Locale;
4242
import java.util.Map;
43-
import java.util.MissingResourceException;
4443
import java.util.ResourceBundle;
4544
import java.util.Set;
4645
import java.util.TimeZone;
@@ -697,18 +696,11 @@ private void encode(Object root, Writer writer, Reader reader) throws IOExceptio
697696
return;
698697
}
699698
case RESOURCE -> {
700-
Object value;
701699
if (resourceBundle == null) {
702-
value = marker;
703-
} else {
704-
try {
705-
value = resourceBundle.getObject(marker);
706-
} catch (MissingResourceException exception) {
707-
value = marker;
708-
}
700+
throw new IllegalStateException("Resource bundle not specified.");
709701
}
710702

711-
value = defaultModifier.apply(value, null, locale, timeZone);
703+
var value = defaultModifier.apply(resourceBundle.getObject(marker), null, locale, timeZone);
712704

713705
writer.append(value.toString());
714706
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
a = a
2+
b = b
3+
c = c
4+
d = d
15
e = É
26
f = F
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
a = A1
22
b = B2
3+
c = c

0 commit comments

Comments
 (0)