Util: Update json-simple lib to 2.3.0 2017-10-04

Bundle 2.0 API only; remove 1.1 API
Convert DoH, NDT, and i2pcontrol to the 2.x API
Fix i2pcontrol handling of number values and serialization for 2.x API
Remove xenial dependency on libjson-simple-java, it has only 1.1
Set min and max version constraint on libjson-simple-java for bionic+
Based on patch from Gilles Filippini
ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901827
This does not support 3.x but the patch for that will be smaller.
This commit is contained in:
zzz
2020-05-31 12:37:37 +00:00
parent 4fd834d13e
commit f985004be0
38 changed files with 3525 additions and 2275 deletions

View File

@@ -37,8 +37,8 @@ import net.i2p.util.I2PSSLSocketFactory;
import net.i2p.util.Log;
import net.i2p.util.PortMapper;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.json.simple.Jsoner;
import org.json.simple.DeserializationException;
import net.i2p.i2pcontrol.security.KeyStoreProvider;
import net.i2p.i2pcontrol.security.SecurityManager;
@@ -194,13 +194,12 @@ public class SocketController implements RouterApp {
public void run() {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream(), "UTF-8"));
final JSONParser parser = new JSONParser();
while (true) {
Object o = parser.parse(reader);
Object o = Jsoner.deserialize(reader);
// TODO
System.out.println("i2pcontrol got: " + o);
}
} catch (ParseException pe) {
} catch (DeserializationException pe) {
_log.error("i2pcontrol handler", pe);
return;
} catch (IOException ioe) {

View File

@@ -86,7 +86,7 @@ public class AuthenticateHandler implements RequestHandler {
Integer apiVersion;
try {
apiVersion = ((Long) api).intValue();
apiVersion = ((Number) api).intValue();
} catch (ClassCastException e) {
e.printStackTrace();
return JSONRPC2ExtendedError.UNSPECIFIED_API_VERSION;

View File

@@ -56,12 +56,10 @@ public class GetRateHandler implements RequestHandler {
if (input == null) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
}
long period;
try {
period = (Long) inParams.get("Period");
} catch (NumberFormatException e) {
Number p = (Number) inParams.get("Period");
if (p == null)
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
}
long period = p.longValue();
RateStat rateStat = I2PAppContext.getGlobalContext().statManager().getRate(input);

View File

@@ -1,7 +1,6 @@
package net.i2p.i2pcontrol.servlets.jsonrpc2handlers;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error;
import org.json.simple.JSONObject;
/*
* Copyright 2011 hottuna (dev@robertfoss.se)