blob: 78d215e89b474bd41a30b5d10931742429d68d08 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.util;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
/**
* The Jettison json object class has an interface issue where it hides null pointer exceptions
* as checked json exceptions. Consequently one has to create catch clauses that code cannot get
* into. This class hides those exceptions.
*
* (Add functions to this wrapper for new functions needing to hide exceptions like this as they are
* needed)
*/
public class JSONObjectWrapper extends JSONObject {
@Override
public JSONObjectWrapper put(String key, Object value) {
try{
super.put(key, value);
return this;
} catch (JSONException e) {
throw new NullPointerException(e.getMessage());
}
}
}
|