Skip to content

Commit 031fa64

Browse files
code review fixes
1 parent 92f0eca commit 031fa64

File tree

1 file changed

+7
-3
lines changed
  • util/src/main/java/io/kubernetes/client/util

1 file changed

+7
-3
lines changed

util/src/main/java/io/kubernetes/client/util/Yaml.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static Object load(File f) throws IOException {
166166
*/
167167
public static Object load(Reader reader) throws IOException {
168168
Map<String, Object> data = getSnakeYaml().load(reader);
169-
return ModelMapper(data);
169+
return modelMapper(data);
170170
}
171171

172172
/**
@@ -251,7 +251,11 @@ public static List<Object> loadAll(Reader reader) throws IOException {
251251
List<Object> list = new ArrayList<Object>();
252252
for (Object object : iterable) {
253253
if (object != null) {
254-
list.add(ModelMapper((Map<String, Object>) object));
254+
try {
255+
list.add(modelMapper((Map<String, Object>) object));
256+
} catch (ClassCastException ex) {
257+
logger.error("Unexpected exception while casting: " + ex);
258+
}
255259
}
256260
}
257261

@@ -287,7 +291,7 @@ public static org.yaml.snakeyaml.Yaml getSnakeYaml() {
287291
* @return An instantiation of the object.
288292
* @throws IOException
289293
*/
290-
private static Object ModelMapper(Map<String, Object> data) throws IOException {
294+
private static Object modelMapper(Map<String, Object> data) throws IOException {
291295
String kind = (String) data.get("kind");
292296
if (kind == null) {
293297
throw new IOException("Missing kind in YAML file!");

0 commit comments

Comments
 (0)