On Thu, 14 May 2020 12:38:36 +0200 Gilles Filippini <p...@debian.org> wrote: > Package: src:i2p > Version: 0.9.45-1 > Severity: normal > Tags: patch > > Hi, > > I'd like to transition json-simple 3.1.1 to unstable, but i2p is a blocker > since it builds against libjson-simple-java << 3 only. > > The json-simple classes used by i2p were deprecated in version 2.0.0 [1]. > There were removed in versions 3.x [2]. > > [1] > https://github.com/cliftonlabs/json-simple/blob/json-simple-2.0.0/README.txt > [2] > https://github.com/cliftonlabs/json-simple/blob/json-simple-3.0.1/CHANGELOG > > Please find attached a patch proposal to use the current json-simple classes. > I've tested that the package builds correctly against libjson-simple-java > version 2.3.0-1 from unstable and version 3.1.1-1~exp2 currently in > experimental. But I don't known how to test the package afterward. > > Thanks in advance for considering.
Updated patch fixing a few misunderstandings. _g.
diff -Nru i2p-0.9.45/debian/changelog i2p-0.9.45/debian/changelog --- i2p-0.9.45/debian/changelog 2020-04-12 16:50:00.000000000 +0200 +++ i2p-0.9.45/debian/changelog 2020-05-13 11:12:38.000000000 +0200 @@ -1,3 +1,10 @@ +i2p (0.9.45-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Tentative support for json-simple >= 3 + + -- Gilles Filippini <p...@debian.org> Wed, 13 May 2020 11:12:38 +0200 + i2p (0.9.45-1) unstable; urgency=medium * New upstream release. diff -Nru i2p-0.9.45/debian/control i2p-0.9.45/debian/control --- i2p-0.9.45/debian/control 2020-04-12 16:50:00.000000000 +0200 +++ i2p-0.9.45/debian/control 2020-05-13 11:12:38.000000000 +0200 @@ -17,7 +17,7 @@ ,bash-completion ,gettext ,libgetopt-java - ,libjson-simple-java (<< 3) + ,libjson-simple-java ,libgmp-dev (>= 2:5.0.5) ,libservice-wrapper-java ,po-debconf diff -Nru i2p-0.9.45/debian/patches/0003-json-simple-3.patch i2p-0.9.45/debian/patches/0003-json-simple-3.patch --- i2p-0.9.45/debian/patches/0003-json-simple-3.patch 1970-01-01 01:00:00.000000000 +0100 +++ i2p-0.9.45/debian/patches/0003-json-simple-3.patch 2020-05-13 11:12:38.000000000 +0200 @@ -0,0 +1,431 @@ +Description: Migrate away from deprecated json-simple 1.x classes + See json-simple 2.0.0 changelog: + > * Deprecated JSONParse and JSONValue in favor of Jsoner. + > * Deprecated JSONStreamAware and JSONAware in favor of Jsonable. + > * Deprecated JSONObject in favor of JsonObject. + > * Deprecated JSONArray in favor of JsonArray. + . + This patch uses the new json-simple Json* classes. It is compatible with + both 2.x and 3.x json-simple releases, with a few ajustments regarding + backward incompatible changes in json-simple 3.x: + - The package name, changed to com.github.cliftonlabs.json_simple + - The exception DeserializationExcetpion renamed as JsonException + These two changes are handled using place-holders @JSON_SIMPLE@ and + @JSON_EXCETPION@ which are substituted at build time by debian/rules. + . + With these tricks the package is compatible with json-simple 2.x and 3.x. +Author: Gilles Filippini <p...@debian.org> +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Error.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Error.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Error.java +@@ -1,7 +1,7 @@ + package com.thetransactioncompany.jsonrpc2; + + +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE@.JsonObject; + + + /** +@@ -220,7 +220,7 @@ public class JSONRPC2Error extends Excep + * @see #toJSONObject + */ + @Deprecated +- public JSONObject toJSON() { ++ public JsonObject toJSON() { + + return toJSONObject(); + } +@@ -231,9 +231,9 @@ public class JSONRPC2Error extends Excep + * + * @return A JSON object representing this error object. + */ +- public JSONObject toJSONObject() { ++ public JsonObject toJSONObject() { + +- JSONObject out = new JSONObject(); ++ JsonObject out = new JsonObject(); + + out.put("code", code); + out.put("message", super.getMessage()); +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Message.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Message.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Message.java +@@ -4,9 +4,11 @@ package com.thetransactioncompany.jsonrp + import java.util.HashMap; + import java.util.List; + import java.util.Map; ++import java.io.Writer; ++import java.io.IOException; + +-import org.json.simple.JSONAware; +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE@.Jsonable; ++import @JSON_SIMPLE@.JsonObject; + + + /** +@@ -54,7 +56,7 @@ import org.json.simple.JSONObject; + * + * @author Vladimir Dzhuvinov + */ +-public abstract class JSONRPC2Message implements JSONAware { ++public abstract class JSONRPC2Message implements Jsonable { + + + /** +@@ -220,7 +222,7 @@ public abstract class JSONRPC2Message im + * + * @return The JSON object. + */ +- public abstract JSONObject toJSONObject(); ++ public abstract JsonObject toJSONObject(); + + + /** +@@ -231,10 +233,14 @@ public abstract class JSONRPC2Message im + * @return The JSON object string representing this JSON-RPC 2.0 + * message. + */ +- public String toJSONString() { ++ public String toJson() { + + return toString(); + } ++ public void toJson(Writer writer) throws IOException { ++ ++ writer.write(toString()); ++ } + + + /** +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Notification.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Notification.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Notification.java +@@ -4,7 +4,7 @@ package com.thetransactioncompany.jsonrp + import java.util.List; + import java.util.Map; + +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE@.JsonObject; + + + /** +@@ -414,9 +414,9 @@ public class JSONRPC2Notification extend + + + @Override +- public JSONObject toJSONObject() { ++ public JsonObject toJSONObject() { + +- JSONObject notf = new JSONObject(); ++ JsonObject notf = new JsonObject(); + + notf.put("method", method); + +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Parser.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Parser.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Parser.java +@@ -4,9 +4,8 @@ package com.thetransactioncompany.jsonrp + import java.util.List; + import java.util.Map; + +-import org.json.simple.parser.ContainerFactory; +-import org.json.simple.parser.JSONParser; +-import org.json.simple.parser.ParseException; ++import @JSON_SIMPLE@.Jsoner; ++import @JSON_SIMPLE@.@JSON_EXCEPTION@; + + + /** +@@ -56,11 +55,6 @@ import org.json.simple.parser.ParseExcep + public class JSONRPC2Parser { + + +- /** +- * Reusable JSON parser. Not thread-safe! +- */ +- private final JSONParser parser; +- + + /** + * If {@code true} the order of the parsed JSON object members must be +@@ -154,9 +148,6 @@ public class JSONRPC2Parser { + final boolean ignoreVersion, + final boolean parseNonStdAttributes) { + +- // Numbers parsed as long/double, requires JSON Smart 1.0.9+ +- parser = new JSONParser(); +- + this.preserveOrder = preserveOrder; + this.ignoreVersion = ignoreVersion; + this.parseNonStdAttributes = parseNonStdAttributes; +@@ -189,13 +180,9 @@ public class JSONRPC2Parser { + + // Parse the JSON string + try { +- //if (preserveOrder) +- // json = parser.parse(jsonString, ContainerFactory.FACTORY_ORDERED); +- +- //else +- json = parser.parse(jsonString); ++ json = Jsoner.deserialize(jsonString); + +- } catch (ParseException e) { ++ } catch (@JSON_EXCEPTION@ e) { + + // Terse message, do not include full parse exception message + throw new JSONRPC2ParseException("Invalid JSON", +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Request.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Request.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Request.java +@@ -4,7 +4,7 @@ package com.thetransactioncompany.jsonrp + import java.util.List; + import java.util.Map; + +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE@.JsonObject; + + + /** +@@ -472,9 +472,9 @@ public class JSONRPC2Request extends JSO + + + @Override +- public JSONObject toJSONObject() { ++ public JsonObject toJSONObject() { + +- JSONObject req = new JSONObject(); ++ JsonObject req = new JsonObject(); + + req.put("method", method); + +Index: i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Response.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Response.java ++++ i2p-0.9.45/apps/i2pcontrol/java/com/thetransactioncompany/jsonrpc2/JSONRPC2Response.java +@@ -3,7 +3,7 @@ package com.thetransactioncompany.jsonrp + + import java.util.Map; + +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE@.JsonObject; + + + /** +@@ -384,9 +384,9 @@ public class JSONRPC2Response extends JS + + + @Override +- public JSONObject toJSONObject() { ++ public JsonObject toJSONObject() { + +- JSONObject out = new JSONObject(); ++ JsonObject out = new JsonObject(); + + // Result and error are mutually exclusive + if (error != null) { +Index: i2p-0.9.45/apps/i2pcontrol/java/net/i2p/i2pcontrol/SocketController.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/net/i2p/i2pcontrol/SocketController.java ++++ i2p-0.9.45/apps/i2pcontrol/java/net/i2p/i2pcontrol/SocketController.java +@@ -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 @JSON_SIMPLE@.Jsoner; ++import @JSON_SIMPLE@.@JSON_EXCEPTION@; + + import net.i2p.i2pcontrol.security.KeyStoreProvider; + import net.i2p.i2pcontrol.security.SecurityManager; +@@ -194,13 +194,12 @@ public class SocketController implements + 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 (@JSON_EXCEPTION@ pe) { + _log.error("i2pcontrol handler", pe); + return; + } catch (IOException ioe) { +Index: i2p-0.9.45/apps/i2pcontrol/java/net/i2p/i2pcontrol/servlets/jsonrpc2handlers/JSONRPC2ExtendedError.java +=================================================================== +--- i2p-0.9.45.orig/apps/i2pcontrol/java/net/i2p/i2pcontrol/servlets/jsonrpc2handlers/JSONRPC2ExtendedError.java ++++ i2p-0.9.45/apps/i2pcontrol/java/net/i2p/i2pcontrol/servlets/jsonrpc2handlers/JSONRPC2ExtendedError.java +@@ -1,7 +1,6 @@ + package net.i2p.i2pcontrol.servlets.jsonrpc2handlers; + + import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; +-import org.json.simple.JSONObject; + + /* + * Copyright 2011 hottuna (d...@robertfoss.se) +Index: i2p-0.9.45/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java +=================================================================== +--- i2p-0.9.45.orig/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java ++++ i2p-0.9.45/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java +@@ -30,9 +30,8 @@ import java.util.concurrent.atomic.Atomi + + import edu.internet2.ndt.Tcpbw100; + +-import org.json.simple.JSONObject; +-import org.json.simple.parser.JSONParser; +-import org.json.simple.parser.ParseException; ++import @JSON_SIMPLE@.JsonObject; ++import @JSON_SIMPLE@.Jsoner; + + import net.i2p.I2PAppContext; + import net.i2p.data.DataHelper; +@@ -153,10 +152,9 @@ public class MLabRunner { + int code = eepget.getStatusCode(); + if (code != 200) + throw new IOException("ns fetch failed: " + code); +- JSONParser parser = new JSONParser(); + byte[] b = baos.toByteArray(); + String s = new String(b, "ISO-8859-1"); +- JSONObject map = (JSONObject) parser.parse(s); ++ JsonObject map = (JsonObject) Jsoner.deserialize(s); + if (map == null) { + throw new IOException("no map"); + } +Index: i2p-0.9.45/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java +=================================================================== +--- i2p-0.9.45.orig/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java ++++ i2p-0.9.45/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java +@@ -1,9 +1,10 @@ + package edu.internet2.ndt; + +-import org.json.simple.JSONObject; +-import org.json.simple.JSONValue; ++import @JSON_SIMPLE@.JsonObject; ++import @JSON_SIMPLE@.Jsoner; + import java.util.Iterator; + import java.util.Map; ++import java.io.IOException; + + /** + * Created by Sebastian Malecki on 13.05.14. +@@ -27,8 +28,7 @@ public class JSONUtils { + * @return {int} obtained value from JSON map + */ + public static String getValueFromJsonObj(String jsonTxt, String key) { +- JSONValue jsonParser = new JSONValue(); +- Map json = (Map)jsonParser.parse(new String(jsonTxt)); ++ Map json = (Map)Jsoner.deserialize(new String(jsonTxt), (JsonObject)null); + if (json == null) + return null; + Iterator iter = json.entrySet().iterator(); +@@ -49,11 +49,12 @@ public class JSONUtils { + * @return {String} json object with added value. + */ + public static String addValueToJsonObj(String jsonTxt, String key, String value) { +- JSONValue jsonParser = new JSONValue(); +- JSONObject json = (JSONObject)jsonParser.parse(new String(jsonTxt)); ++ JsonObject json = Jsoner.deserialize(new String(jsonTxt), (JsonObject)null); ++ if (json == null) ++ json = new JsonObject(); + json.put(key, value); + +- return json.toJSONString(); ++ return json.toJson(); + } + + /** +@@ -63,10 +64,10 @@ public class JSONUtils { + * @return {byte[]} json object represented by jsontext and encodes into a sequence of bytes + */ + public static byte[] createJsonObj(byte[] msg) { +- JSONObject obj = new JSONObject(); ++ JsonObject obj = new JsonObject(); + obj.put("msg", new String(msg)); + +- return obj.toJSONString().getBytes(); ++ return obj.toJson().getBytes(); + } + + /** +@@ -77,9 +78,9 @@ public class JSONUtils { + * @since 0.9.45 + */ + public static byte[] createJsonLoginObj(byte[] msg, byte tests) { +- JSONObject obj = new JSONObject(); ++ JsonObject obj = new JsonObject(); + obj.put("msg", new String(msg)); + obj.put("tests", Integer.toString(tests & 0xff)); +- return obj.toJSONString().getBytes(); ++ return obj.toJson().getBytes(); + } + } +Index: i2p-0.9.45/core/java/src/net/i2p/util/DNSOverHTTPS.java +=================================================================== +--- i2p-0.9.45.orig/core/java/src/net/i2p/util/DNSOverHTTPS.java ++++ i2p-0.9.45/core/java/src/net/i2p/util/DNSOverHTTPS.java +@@ -12,9 +12,9 @@ import java.util.Map; + + import gnu.getopt.Getopt; + +-import org.json.simple.JSONArray; +-import org.json.simple.JSONObject; +-import org.json.simple.parser.JSONParser; ++import @JSON_SIMPLE@.JsonArray; ++import @JSON_SIMPLE@.JsonObject; ++import @JSON_SIMPLE@.Jsoner; + + import net.i2p.I2PAppContext; + import net.i2p.data.DataHelper; +@@ -31,7 +31,6 @@ import net.i2p.data.DataHelper; + public class DNSOverHTTPS implements EepGet.StatusListener { + private final I2PAppContext ctx; + private final Log _log; +- private final JSONParser parser; + private final ByteArrayOutputStream baos; + private SSLEepGet.SSLState state; + private long fetchStart; +@@ -105,7 +104,6 @@ public class DNSOverHTTPS implements Eep + _log = ctx.logManager().getLog(DNSOverHTTPS.class); + state = sslState; + baos = new ByteArrayOutputStream(512); +- parser = new JSONParser(); + } + + public enum Type { V4_ONLY, V6_ONLY, V4_PREFERRED, V6_PREFERRED } +@@ -263,7 +261,7 @@ public class DNSOverHTTPS implements Eep + byte[] b = baos.toByteArray(); + try { + String s = new String(b, "ISO-8859-1"); +- JSONObject map = (JSONObject) parser.parse(s); ++ JsonObject map = (JsonObject) Jsoner.deserialize(s); + if (map == null) { + log("No map"); + return null; +@@ -273,7 +271,7 @@ public class DNSOverHTTPS implements Eep + log("Bad status: " + status); + return null; + } +- JSONArray list = (JSONArray) map.get("Answer"); ++ JsonArray list = (JsonArray) map.get("Answer"); + if (list == null || list.isEmpty()) { + log("No answer"); + return null; +@@ -282,7 +280,7 @@ public class DNSOverHTTPS implements Eep + String hostAnswer = host + '.'; + for (Object o : list) { + try { +- JSONObject a = (JSONObject) o; ++ JsonObject a = (JsonObject) o; + String data = (String) a.get("data"); + if (data == null) { + log("no data"); diff -Nru i2p-0.9.45/debian/patches/series i2p-0.9.45/debian/patches/series --- i2p-0.9.45/debian/patches/series 2020-04-12 16:50:00.000000000 +0200 +++ i2p-0.9.45/debian/patches/series 2020-05-13 11:12:38.000000000 +0200 @@ -1,2 +1,3 @@ 0001-path-substitution.patch 0002-jetty-compatibility.patch +0003-json-simple-3.patch diff -Nru i2p-0.9.45/debian/rules i2p-0.9.45/debian/rules --- i2p-0.9.45/debian/rules 2020-04-12 16:50:00.000000000 +0200 +++ i2p-0.9.45/debian/rules 2020-05-13 11:12:38.000000000 +0200 @@ -40,6 +40,17 @@ export BITS := $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS) #export DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) +# debian: bullseye - transitioning +JSON_SIMPLE_VERSION = $(shell dpkg -l libjson-simple-java | grep '^ii' | awk '{print $$3}') +JSON_SIMPLE_3 = $(shell dpkg --compare-versions '$(JSON_SIMPLE_VERSION)' '>' '3.1.1-1~' && echo yes || echo no) +ifeq (yes,$(JSON_SIMPLE_3)) +JSON_SIMPLE_PACKAGE = com.github.cliftonlabs.json_simple +JSON_EXCEPTION = JsonException +else +JSON_SIMPLE_PACKAGE = org.json.simple +JSON_EXCEPTION = DeserializationException +endif + %: dh $@ --with systemd,bash-completion @@ -59,6 +70,8 @@ rm -f $(CURDIR)/apps/susidns/src/lib/jstlel.jar rm -f $(CURDIR)/apps/i2pcontrol/build/jsonrpc.war debconf-updatepo + find . -type f -name \*.java.json-simple \ + -exec sh -c 'file={} && mv $$file $${file%.json-simple}' \; -print override_dh_auto_build: @@ -161,6 +174,13 @@ @mkdir -p $(CURDIR)/core/java/build ln -sf /usr/share/java/json-simple.jar $(CURDIR)/core/java/build/json-simple.jar + @# debian: bullseye - transitioning + find . -type f -name \*.java -exec grep -q 'import @JSON_SIMPLE@' {} \; \ + -exec sed -i.json-simple \ + -e 's,@JSON_SIMPLE@,$(JSON_SIMPLE_PACKAGE),' \ + -e 's/@JSON_EXCEPTION@/$(JSON_EXCEPTION)/' \ + {} \; -print + @# debian: everywhere; ubuntu: trusty+ @/bin/echo -e "with-famfamfam-flag-png=true" >> $(CURDIR)/override.properties
signature.asc
Description: OpenPGP digital signature