You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:26:47 UTC

[sling-org-apache-sling-discovery-base] annotated tag org.apache.sling.discovery.base-1.1.8 created (now d66171e)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git.


      at d66171e  (tag)
 tagging 9274fb38dfbf1b580c1d5385facf1de58556e903 (commit)
      by Karl Pauls
      on Sun May 7 21:37:56 2017 +0000

- Log -----------------------------------------------------------------
org.apache.sling.discovery.base-1.1.8
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 976d955  SLING-5173 : introducing discovery.base which is the sharable parts of discovery.impl for discovery.oak - eg it includes topology connectors and base classes - plus it also includes many it-kind tests of discovery.impl
     new 973f209  SLING-5173 : fixed getSocketConnectionTimeout to a more proper getSocketConnectTimeout
     new e375668  SLING-5173 : rename commons impl packages to base as they are meant for reuse by discovery.impl and discovery.oak - plus avoid using abstract component class with scr annotations - use abstract getters instead - plus some more fine-tuning of log messages - plus make discovery.impl's Config also implement DiscoveryLiteConfig - plus properly handle binds happening before activate in DiscoveryServiceImpl
     new 117b474  SLING-5173 related : minor wording fix
     new c854b64  SLING-5173 : fixed test logic
     new c2d2fec  SLING-5196 : using maven-bundle-plugin 2.5.3 to remain backwards-compatibility
     new 64c9956  SLING-5173 : using discovery.commons 1.0.0
     new a40c75a  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.0
     new 2341062  [maven-release-plugin] prepare for next development iteration
     new 4a397a1  update discovery dependencies to next snapshot versions until release versions available in maven central
     new d54675c  @no-jira : improve test stability
     new 246e567  SLING-5214: include millis in testing log formats
     new 6e20b46  SLING-5200 : add possibility of injecting delays into particular places during simulation, eg in resourceResolver.commit
     new 3e1f21d  SLING-5126 : another test variant added
     new 479ea55  SLING-5126 / SLING-5195 related: fixing a test
     new 65362f2  SLING-5216 / SLING-5195 : more test cases added
     new 568f6d9  SLING-5216 / SLING-5195 : more test cases added
     new f129180  SLING-5224 : increasing wait time from 100ms to 1000ms to avoid test failure on jenkins
     new b9c1fd9  SLING-5224 : more logging for testBoostrap
     new c49512e  SLING-5216 : another VotingHandler test case added - changed analyzeVotings return value for this - but no other changes to the analyzeVotings algo or code
     new 3279a2c  SLING-5241 : increasing wait time for receiving an event from 0.5s to 1.0s
     new 632c604  @no-jira using discovery.commons 1.0.2
     new 983e345  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.2
     new f6cffe9  [maven-release-plugin] prepare for next development iteration
     new e892c3d  @no-jira : moved discovery.commons to 1.0.3-SNAPSHOT
     new ac39af5  SLING-5256 : change in localClusterSyncTokenId should always trigger a TOPOLOGY_CHANGED - ensured by adjusting ViewStateManager.onlyDiffersInProperties and DefaultTopologyView.compareTopology accordingly including new tests for both - plus added OakDiscoveryServiceTest.testDescriptorSeqNumChange to verify that discovery.oak now properly detects otherwise-equal topologies when their sequence_number==localClusterSyncTokenId differs (unlikely to happen under normal load sit [...]
     new c7ead9e  SLING-5260 : made loop in testConnectorSwitching4139 last 15-20sec to cope with 10sec timeout
     new acd97d3  no-jira : added a 2sec wait time to increase test stability of testLongRunningListener
     new 61c247c  SLING-5264 : increasing timeouts to account for slowness of jenkins
     new a55019d  no-jira : increasing sleeps to account for another apache jenkins slowness - sling-trunk-1.7 2661
     new a04c6ca  no-jira : added another safety sleep of 2sec for testConnectorSwitching4139 to make sure those heartbeats/votings going on there have enough time to settle
     new 0371ca6  SLING-5264 follow-up : adding more logging to analyzeVotings/promote and AbstractDiscoveryServiceTest to track down still existing issue
     new 37ae575  SLING-5279 : tests made more stable wrt stopping a VirtualInstance that was likely not done yet and interfered with subsequent test runs
     new 1804fd3  no-jira : just some logger.debug messages fixed
     new ccd3ba5  no-jira : fixed a logger.info
     new a581e02  SLING-5284 : use dedicated PeriodicBackgroundJob-thread instead of scheduler
     new 717806c  SLING-5286 : re-activate fast topology change propagation
     new 7d02f0e  SLING-5284 : new PeriodicBackgroundJob requires upping the version to 1.1.0
     new c6e5b4b  SLING-5287 : lowering the testThirtyInstances test to be a testTwentyFourInstances - that should use less memory - lets see if that's enough
     new e171131  SLING-5251 : add config parameter useSyncTokenService that enables usage of a SyncTokenService if available. This increases synchronization QoS when for topology changes
     new d1b5f01  @no-jira using discovery.commons 1.0.4
     new cbc913d  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.0
     new c00f863  [maven-release-plugin] prepare for next development iteration
     new 8239aae  @no-jira using discovery.commons 1.0.5-SNAPSHOT
     new f2183ef  SLING-5303 : adding a few more loops to avoid a failure that happened on jenkins due to the fact that heartbeatsAndCheckView can throw exceptions when invoked during promotion/other repository changes in a test environment. More loops should help work around that.
     new 9a0e1e9  SLING-5313 : using jcr-commons 2.10.1 instead of the one referenced by sling.commons.testing which is 2.2.9
     new f120875  SLING-5326 : adding time-difference health-check 'ClocksInSyncHealthCheck'
     new f6bb466  no-jira : switching to discovery.commons 1.0.6
     new c571e7c  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.2
     new e1a75e2  [maven-release-plugin] prepare for next development iteration
     new f35f1c5  no-jira : switching to discovery.commons 1.0.7-SNAPSHOT
     new 923cb3d  Remove type from bundle dependencies
     new f7a5bdc  Switch to parent pom 26
     new 5faa5a7  SLING-5485 Remove Launchpad API dependency from Discovery Base
     new 4246578  SLING-5598 : exclude slow running test by newly introduced Slow junit category - to run them nevertheless use -PincludeSlowTests
     new 4a9ac3d  use org.apache.sling.commons.testing 2.0.26
     new 5d6933c  use org.apache.sling.discovery.commons 1.0.12
     new 7fcaa11  align Jackrabbit versions
     new 61dbee4  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.4
     new d7dda34  [maven-release-plugin] prepare for next development iteration
     new 2e4b045  SLING-5732 : discovery : avoid empty commit when nothing has changed
     new e88cbac  SLING-5231 : remove getAdministrativeResourceResolver from discovery components : merged patches from Carsten
     new db99b6b  SLING-5231 : remove getAdministrativeResourceResolver from discovery components : adjusted dependency on discovery.commons
     new 26383aa  no-jira : switching to in-release discovery.commons 1.0.18
     new f7d5374  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.6
     new 8b6f5ef  [maven-release-plugin] prepare for next development iteration
     new 2e64d05  no-jira : switching to next discovery.commons 1.0.19-SNAPSHOT
     new aea97dd  SLING-6689: Replace commons.json usage in org.apache.sling.discovery.base
     new ae43559  SLING-6689: Switch to geronimo provider for javax.json api.
     new 2a7093c  update to org.apache.sling.commons.johnzon 1.0.0
     new fe51cdd  SLING-6809 : toString improved to enlist more details - including a paranoia fallback that goes to the previous output in case of any Exception
     new d16b968  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.8
     new 9274fb3  [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.1.8

The 73 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-discovery-base] 03/08: SLING-6689: Replace commons.json usage in org.apache.sling.discovery.base

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit aea97dd275c7e527cdde0542243ee5176df609b5
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Tue Mar 28 13:02:58 2017 +0000

    SLING-6689: Replace commons.json usage in org.apache.sling.discovery.base
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1789117 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  18 ++-
 .../base/connectors/announcement/Announcement.java | 169 ++++++++++++---------
 .../announcement/AnnouncementRegistryImpl.java     |  11 +-
 .../base/connectors/announcement/package-info.java |   2 +-
 .../connectors/ping/TopologyConnectorClient.java   |   4 +-
 .../connectors/ping/TopologyConnectorServlet.java  |   4 +-
 .../connectors/ping/TopologyRequestValidator.java  |  38 +++--
 7 files changed, 144 insertions(+), 102 deletions(-)

diff --git a/pom.xml b/pom.xml
index 28871fe..b2fc7b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,6 +130,12 @@
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.johnzon</artifactId>
+            <version>0.1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
 		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.jcr.api</artifactId>
@@ -215,12 +221,6 @@
 			<version>4.3.5</version>
 			<scope>provided</scope>
 		</dependency>
-		<dependency>
-			<groupId>org.apache.sling</groupId>
-			<artifactId>org.apache.sling.commons.json</artifactId>
-			<version>2.0.6</version>
-            <scope>provided</scope>
-		</dependency>
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
@@ -319,6 +319,12 @@
           <artifactId>org.apache.sling.testing.sling-mock</artifactId>
           <version>1.2.0</version>
           <scope>test</scope>
+          <exclusions>
+          <exclusion>
+          <groupId>org.apache.sling</groupId>
+          <artifactId>org.apache.sling.commons.json</artifactId>
+          </exclusion>
+          </exclusions>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/Announcement.java b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/Announcement.java
index 95df6fc..4878e6f 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/Announcement.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/Announcement.java
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.discovery.base.connectors.announcement;
 
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -26,13 +28,18 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonReaderFactory;
+import javax.json.JsonValue;
+
 import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.commons.providers.DefaultClusterView;
@@ -83,6 +90,13 @@ public class Announcement {
     private long originallyCreatedAt = -1;
     
     private long receivedAt = System.currentTimeMillis();
+    
+    private static final JsonReaderFactory jsonReaderFactory;
+    static {
+        Map<String, Object> config = new HashMap<String, Object>();
+        config.put("org.apache.johnzon.supports-comments", true);
+        jsonReaderFactory = Json.createReaderFactory(config);
+    }
 
     public Announcement(final String ownerId) {
         this(ownerId, PROTOCOL_VERSION);
@@ -226,88 +240,95 @@ public class Announcement {
     }
 
     /** Convert this announcement into a json object **/
-    public JSONObject asJSONObject() throws JSONException {
+    public JsonObject asJSONObject() {
         return asJSONObject(false);
     }
     
     /** Convert this announcement into a json object **/
-    private JSONObject asJSONObject(boolean filterTimes) throws JSONException {
-        JSONObject announcement = new JSONObject();
-        announcement.put("ownerId", ownerId);
-        announcement.put("protocolVersion", protocolVersion);
+    private JsonObject asJSONObject(boolean filterTimes) {
+        JsonObjectBuilder announcement = Json.createObjectBuilder();
+        announcement.add("ownerId", ownerId);
+        announcement.add("protocolVersion", protocolVersion);
         // SLING-3389: leaving the 'created' property in the announcement
         // for backwards compatibility!
         if (!filterTimes) {
-            announcement.put("created", System.currentTimeMillis());
+            announcement.add("created", System.currentTimeMillis());
         }
-        announcement.put("inherited", inherited);
+        announcement.add("inherited", inherited);
         if (loop) {
-            announcement.put("loop", loop);
+            announcement.add("loop", loop);
         }
         if (serverInfo != null) {
-            announcement.put("serverInfo", serverInfo);
+            announcement.add("serverInfo", serverInfo);
         }
         if (localCluster!=null) {
-            announcement.put("localClusterView", asJSON(localCluster));
+            announcement.add("localClusterView", asJSON(localCluster));
         }
         if (!filterTimes && backoffInterval>0) {
-            announcement.put("backoffInterval", backoffInterval);
+            announcement.add("backoffInterval", backoffInterval);
         }
         if (resetBackoff) {
-            announcement.put("resetBackoff", resetBackoff);
+            announcement.add("resetBackoff", resetBackoff);
         }
-        JSONArray incomingAnnouncements = new JSONArray();
+        JsonArrayBuilder incomingAnnouncements = Json.createArrayBuilder();
         for (Iterator<Announcement> it = incomings.iterator(); it.hasNext();) {
             Announcement incoming = it.next();
-            incomingAnnouncements.put(incoming.asJSONObject(filterTimes));
+            incomingAnnouncements.add(incoming.asJSONObject(filterTimes));
         }
-        announcement.put("topologyAnnouncements", incomingAnnouncements);
-        return announcement;
+        announcement.add("topologyAnnouncements", incomingAnnouncements);
+        return announcement.build();
     }
 
     /** Create an announcement form json **/
-    public static Announcement fromJSON(final String topologyAnnouncementJSON)
-            throws JSONException {
-        JSONObject announcement = new JSONObject(topologyAnnouncementJSON);
+    public static Announcement fromJSON(final String topologyAnnouncementJSON) {
+        
+        JsonObject announcement = jsonReaderFactory.createReader(new StringReader(topologyAnnouncementJSON)).readObject();
         final String ownerId = announcement.getString("ownerId");
         final int protocolVersion;
-        if (!announcement.has("protocolVersion")) {
+        if (!announcement.containsKey("protocolVersion")) {
             protocolVersion = -1;
         } else {
             protocolVersion = announcement.getInt("protocolVersion");
         }
         final Announcement result = new Announcement(ownerId, protocolVersion);
-        if (announcement.has("created")) {
-            result.originallyCreatedAt = announcement.getLong("created");
+        if (announcement.containsKey("created")) {
+            result.originallyCreatedAt = announcement.getJsonNumber("created").longValue();
         }
-        if (announcement.has("backoffInterval")) {
-            long backoffInterval = announcement.getLong("backoffInterval");
+        if (announcement.containsKey("backoffInterval")) {
+            long backoffInterval = announcement.getJsonNumber("backoffInterval").longValue();
             result.backoffInterval = backoffInterval;
         }
-        if (announcement.has("resetBackoff")) {
+        if (announcement.containsKey("resetBackoff")) {
             boolean resetBackoff = announcement.getBoolean("resetBackoff");
             result.resetBackoff = resetBackoff;
         }
-        if (announcement.has("loop") && announcement.getBoolean("loop")) {
+        if (announcement.containsKey("loop") && announcement.getBoolean("loop")) {
             result.setLoop(true);
             return result;
         }
-        final String localClusterViewJSON = announcement
-                .getString("localClusterView");
-        final ClusterView localClusterView = asClusterView(localClusterViewJSON);
-        final JSONArray subAnnouncements = announcement
-                .getJSONArray("topologyAnnouncements");
+        if (announcement.containsKey("localClusterView"))
+        {
+            final String localClusterViewJSON = asJSON(announcement
+                    .getJsonObject("localClusterView"));
+            
+            final ClusterView localClusterView = asClusterView(localClusterViewJSON);
+    
+            result.setLocalCluster(localClusterView);
+        }
 
-        if (announcement.has("inherited")) {
+        if (announcement.containsKey("inherited")) {
             final Boolean inherited = announcement.getBoolean("inherited");
             result.inherited = inherited;
         }
-        if (announcement.has("serverInfo")) {
+        if (announcement.containsKey("serverInfo")) {
             String serverInfo = announcement.getString("serverInfo");
             result.serverInfo = serverInfo;
         }
-        result.setLocalCluster(localClusterView);
-        for (int i = 0; i < subAnnouncements.length(); i++) {
+
+        final JsonArray subAnnouncements = announcement
+                .getJsonArray("topologyAnnouncements");
+        
+        for (int i = 0; i < subAnnouncements.size(); i++) {
             String subAnnouncementJSON = subAnnouncements.getString(i);
             result.addIncomingTopologyAnnouncement(fromJSON(subAnnouncementJSON));
         }
@@ -315,15 +336,14 @@ public class Announcement {
     }
 
     /** create a clusterview from json **/
-    private static ClusterView asClusterView(final String localClusterViewJSON)
-            throws JSONException {
-        JSONObject obj = new JSONObject(localClusterViewJSON);
+    private static ClusterView asClusterView(final String localClusterViewJSON) {
+        JsonObject obj = jsonReaderFactory.createReader(new StringReader(localClusterViewJSON)).readObject();
         DefaultClusterView clusterView = new DefaultClusterView(
                 obj.getString("id"));
-        JSONArray instancesObj = obj.getJSONArray("instances");
+        JsonArray instancesObj = obj.getJsonArray("instances");
 
-        for (int i = 0; i < instancesObj.length(); i++) {
-            JSONObject anInstance = instancesObj.getJSONObject(i);
+        for (int i = 0; i < instancesObj.size(); i++) {
+            JsonObject anInstance = instancesObj.getJsonObject(i);
             clusterView.addInstanceDescription(asInstance(anInstance));
         }
 
@@ -331,29 +351,27 @@ public class Announcement {
     }
 
     /** convert a clusterview into json **/
-    private static JSONObject asJSON(final ClusterView clusterView)
-            throws JSONException {
-        JSONObject obj = new JSONObject();
-        obj.put("id", clusterView.getId());
-        JSONArray instancesObj = new JSONArray();
+    private static JsonObject asJSON(final ClusterView clusterView) {
+        JsonObjectBuilder obj = Json.createObjectBuilder();
+        obj.add("id", clusterView.getId());
+        JsonArrayBuilder instancesObj = Json.createArrayBuilder();
         List<InstanceDescription> instances = clusterView.getInstances();
         for (Iterator<InstanceDescription> it = instances.iterator(); it
                 .hasNext();) {
             InstanceDescription instanceDescription = it.next();
-            instancesObj.put(asJSON(instanceDescription));
+            instancesObj.add(asJSON(instanceDescription));
         }
-        obj.put("instances", instancesObj);
-        return obj;
+        obj.add("instances", instancesObj);
+        return obj.build();
     }
 
     /** create an instancedescription from json **/
-    private static DefaultInstanceDescription asInstance(
-            final JSONObject anInstance) throws JSONException {
+    private static DefaultInstanceDescription asInstance(final JsonObject anInstance) {
         final boolean isLeader = anInstance.getBoolean("isLeader");
         final String slingId = anInstance.getString("slingId");
 
-        final JSONObject propertiesObj = anInstance.getJSONObject("properties");
-        Iterator<String> it = propertiesObj.keys();
+        final JsonObject propertiesObj = anInstance.getJsonObject("properties");
+        Iterator<String> it = propertiesObj.keySet().iterator();
         Map<String, String> properties = new HashMap<String, String>();
         while (it.hasNext()) {
             String key = it.next();
@@ -366,24 +384,23 @@ public class Announcement {
     }
 
     /** convert an instance description into a json object **/
-    private static JSONObject asJSON(final InstanceDescription instanceDescription)
-            throws JSONException {
-        JSONObject obj = new JSONObject();
-        obj.put("slingId", instanceDescription.getSlingId());
-        obj.put("isLeader", instanceDescription.isLeader());
+    private static JsonObject asJSON(final InstanceDescription instanceDescription) {
+        JsonObjectBuilder obj = Json.createObjectBuilder();
+        obj.add("slingId", instanceDescription.getSlingId());
+        obj.add("isLeader", instanceDescription.isLeader());
         ClusterView cluster = instanceDescription.getClusterView();
         if (cluster != null) {
-            obj.put("cluster", cluster.getId());
+            obj.add("cluster", cluster.getId());
         }
-        JSONObject propertiesObj = new JSONObject();
+        JsonObjectBuilder propertiesObj = Json.createObjectBuilder();
         Map<String, String> propertiesMap = instanceDescription.getProperties();
         for (Iterator<Entry<String, String>> it = propertiesMap.entrySet()
                 .iterator(); it.hasNext();) {
             Entry<String, String> entry = it.next();
-            propertiesObj.put(entry.getKey(), entry.getValue());
+            propertiesObj.add(entry.getKey(), entry.getValue());
         }
-        obj.put("properties", propertiesObj);
-        return obj;
+        obj.add("properties", propertiesObj);
+        return obj.build();
     }
 
     /** sets the local clusterview **/
@@ -398,8 +415,14 @@ public class Announcement {
     }
 
     /** Convert this announcement into json **/
-    public String asJSON() throws JSONException {
-        return asJSONObject().toString();
+    public String asJSON() {
+        return asJSON(asJSONObject());
+    }
+    
+    private static String asJSON(JsonValue json) {
+        StringWriter writer = new StringWriter();
+        Json.createGenerator(writer).write(json).close();
+        return writer.toString();
     }
 
     /** the key which is unique to this announcement **/
@@ -424,7 +447,7 @@ public class Announcement {
      * under which a node with the primary key is created
      **/
     public void persistTo(Resource announcementsResource)
-            throws PersistenceException, JSONException {
+            throws PersistenceException {
         Resource announcementChildResource = announcementsResource.getChild(getPrimaryKey());
         
         // SLING-2967 used to introduce 'resetting the created time' here
@@ -466,10 +489,10 @@ public class Announcement {
      * to SLING-3389 wire-backwards-compatibility - and backoffInterval
      * introduced as part of SLING-3382
      */
-    public boolean correspondsTo(Announcement announcement) throws JSONException {
-        final JSONObject myJson = asJSONObject(true);
-        final JSONObject otherJson = announcement.asJSONObject(true);
-        return myJson.toString().equals(otherJson.toString());
+    public boolean correspondsTo(Announcement announcement) {
+        final JsonObject myJson = asJSONObject(true);
+        final JsonObject otherJson = announcement.asJSONObject(true);
+        return asJSON(myJson).equals(asJSON(otherJson));
     }
 
     public void registerPing(Announcement incomingAnnouncement) {
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java
index c13d4ab..a4f3957 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/AnnouncementRegistryImpl.java
@@ -25,6 +25,8 @@ import java.util.LinkedList;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import javax.json.JsonException;
+
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
@@ -35,7 +37,6 @@ import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.base.connectors.BaseConfig;
@@ -243,7 +244,7 @@ public class AnnouncementRegistryImpl implements AnnouncementRegistry {
             logger.error("listAnnouncementsInSameCluster: got a PersistenceException: " + e, e);
             throw new RuntimeException(
                     "Exception while talking to repository (" + e + ")", e);
-        } catch (JSONException e) {
+        } catch (JsonException e) {
             logger.error("listAnnouncementsInSameCluster: got a JSONException: " + e, e);
             throw new RuntimeException("Exception while converting json (" + e
                     + ")", e);
@@ -327,7 +328,7 @@ public class AnnouncementRegistryImpl implements AnnouncementRegistry {
                 }
                 logger.debug("registerAnnouncement: incoming announcement differs from existing one!");
 
-            } catch(JSONException e) {
+            } catch(JsonException e) {
                 logger.error("registerAnnouncement: got JSONException while converting incoming announcement to JSON: "+e, e);
             }
             // otherwise the repository and the cache require to be updated
@@ -395,7 +396,7 @@ public class AnnouncementRegistryImpl implements AnnouncementRegistry {
                     + e, e);
             throw new RuntimeException(
                     "Exception while talking to repository (" + e + ")", e);
-        } catch (JSONException e) {
+        } catch (JsonException e) {
             logger.error("registerAnnouncement: got a JSONException: " + e, e);
             throw new RuntimeException("Exception while converting json (" + e
                     + ")", e);
@@ -467,7 +468,7 @@ public class AnnouncementRegistryImpl implements AnnouncementRegistry {
             logger.error("handleEvent: got a PersistenceException: " + e, e);
             throw new RuntimeException(
                     "Exception while talking to repository (" + e + ")", e);
-        } catch (JSONException e) {
+        } catch (JsonException e) {
             logger.error("handleEvent: got a JSONException: " + e, e);
             throw new RuntimeException("Exception while converting json (" + e
                     + ")", e);
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/package-info.java b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/package-info.java
index 207191e..b1e3218 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/announcement/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/announcement/package-info.java
@@ -23,7 +23,7 @@
  *
  * @version 1.1.2
  */
-@Version("1.1.2")
+@Version("2.0.0")
 package org.apache.sling.discovery.base.connectors.announcement;
 
 import aQute.bnd.annotation.Version;
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorClient.java b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorClient.java
index a5db553..9cb6e2c 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorClient.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorClient.java
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.UUID;
 import java.util.zip.GZIPOutputStream;
 
+import javax.json.JsonException;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.http.Header;
@@ -44,7 +45,6 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.base.commons.ClusterViewService;
@@ -322,7 +322,7 @@ public class TopologyConnectorClient implements
     			logger.warn("ping: got IOException [suppressing further warns]: " + e + ", uri=" + uri);
         	}
             statusDetails = e.toString();
-        } catch (JSONException e) {
+        } catch (JsonException e) {
             logger.warn("ping: got JSONException: " + e);
             statusDetails = e.toString();
         } catch (RuntimeException re) {
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorServlet.java b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorServlet.java
index 4211cf3..037bc3f 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorServlet.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyConnectorServlet.java
@@ -28,6 +28,7 @@ import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.zip.GZIPOutputStream;
 
+import javax.json.JsonException;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -38,7 +39,6 @@ import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.discovery.ClusterView;
 import org.apache.sling.discovery.base.commons.ClusterViewHelper;
 import org.apache.sling.discovery.base.commons.ClusterViewService;
@@ -320,7 +320,7 @@ public class TopologyConnectorServlet extends HttpServlet {
                 pw.print(p);
                 pw.flush();
             }
-        } catch (JSONException e) {
+        } catch (JsonException e) {
             logger.error("doPost: Got a JSONException: " + e, e);
             response.sendError(500);
         } catch (UndefinedClusterViewException e) {
diff --git a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyRequestValidator.java b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyRequestValidator.java
index fee273c..833e995 100644
--- a/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyRequestValidator.java
+++ b/src/main/java/org/apache/sling/discovery/base/connectors/ping/TopologyRequestValidator.java
@@ -18,6 +18,8 @@
 package org.apache.sling.discovery.base.connectors.ping;
 
 import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.security.AlgorithmParameters;
 import java.security.InvalidAlgorithmParameterException;
@@ -46,6 +48,12 @@ import javax.crypto.SecretKeyFactory;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.PBEKeySpec;
 import javax.crypto.spec.SecretKeySpec;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -54,9 +62,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.discovery.base.connectors.BaseConfig;
 
 /**
@@ -138,9 +143,16 @@ public class TopologyRequestValidator {
         checkActive();
         if (encryptionEnabled) {
             try {
-                JSONObject json = new JSONObject();
-                json.put("payload", new JSONArray(encrypt(body)));
-                return json.toString();
+                JsonObjectBuilder json = Json.createObjectBuilder();
+                JsonArrayBuilder array = Json.createArrayBuilder();
+                for (String value : encrypt(body))
+                {
+                    array.add(value);
+                }
+                json.add("payload", array);
+                StringWriter writer = new StringWriter();
+                Json.createGenerator(writer).write(json.build()).close();
+                return writer.toString();
             } catch (InvalidKeyException e) {
                 e.printStackTrace();
                 throw new IOException("Unable to Encrypt Message " + e.getMessage());
@@ -154,7 +166,7 @@ public class TopologyRequestValidator {
                 throw new IOException("Unable to Encrypt Message " + e.getMessage());
             } catch (NoSuchPaddingException e) {
                 throw new IOException("Unable to Encrypt Message " + e.getMessage());
-            } catch (JSONException e) {
+            } catch (JsonException e) {
                 throw new IOException("Unable to Encrypt Message " + e.getMessage());
             } catch (InvalidKeySpecException e) {
                 throw new IOException("Unable to Encrypt Message " + e.getMessage());
@@ -211,11 +223,11 @@ public class TopologyRequestValidator {
             if (bodyHash.equals(requestHash)) {
                 if (encryptionEnabled) {
                     try {
-                        JSONObject json = new JSONObject(body);
-                        if (json.has("payload")) {
-                            return decrypt(json.getJSONArray("payload"));
+                        JsonObject json = Json.createReader(new StringReader(body)).readObject();
+                        if (json.containsKey("payload")) {
+                            return decrypt(json.getJsonArray("payload"));
                         }
-                    } catch (JSONException e) {
+                    } catch (JsonException e) {
                         throw new IOException("Encrypted Message is in the correct json format");
                     } catch (InvalidKeyException e) {
                         throw new IOException("Encrypted Message is in the correct json format");
@@ -418,9 +430,9 @@ public class TopologyRequestValidator {
      * @throws InvalidAlgorithmParameterException
      * @throws JSONException
      */
-    private String decrypt(JSONArray jsonArray) throws IllegalBlockSizeException,
+    private String decrypt(JsonArray jsonArray) throws IllegalBlockSizeException,
             BadPaddingException, UnsupportedEncodingException, InvalidKeyException,
-            NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeySpecException, JSONException {
+            NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeySpecException {
         Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
         cipher.init(Cipher.DECRYPT_MODE, getCiperKey(Base64.decodeBase64(jsonArray.getString(0).getBytes("UTF-8"))), new IvParameterSpec(Base64.decodeBase64(jsonArray.getString(1).getBytes("UTF-8"))));
         return new String(cipher.doFinal(Base64.decodeBase64(jsonArray.getString(2).getBytes("UTF-8"))));

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 02/08: no-jira : switching to next discovery.commons 1.0.19-SNAPSHOT

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 2e64d0510f888dd3307461af782ea358ae06f6dd
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Nov 15 12:54:25 2016 +0000

    no-jira : switching to next discovery.commons 1.0.19-SNAPSHOT
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1769814 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5a13ad8..28871fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,7 +169,7 @@
  		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.discovery.commons</artifactId>
-			<version>1.0.18</version>
+			<version>1.0.19-SNAPSHOT</version>
   		</dependency>
         <!-- besides including discovery.commons' normal jar above, 
               for testing a few test helper classes are also reused.
@@ -177,7 +177,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.discovery.commons</artifactId>
-            <version>1.0.18</version>
+            <version>1.0.19-SNAPSHOT</version>
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 01/08: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 8b6f5efb7b7d32ec3d673070876aae6646b11c52
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Nov 15 12:49:36 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1769811 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index ad78c83..5a13ad8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
 
     <artifactId>org.apache.sling.discovery.base</artifactId>
     <packaging>bundle</packaging>
-    <version>1.1.6</version>
+    <version>1.1.7-SNAPSHOT</version>
 
     <name>Apache Sling Discovery Base</name>
     <description>Contains Connector and Properties support that some implementations might choose to build upon</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.1.6</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.1.6</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.base-1.1.6</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 08/08: [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.1.8

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 9274fb38dfbf1b580c1d5385facf1de58556e903
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Sun May 7 21:37:56 2017 +0000

    [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.1.8
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.1.8@1794268 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 05/08: update to org.apache.sling.commons.johnzon 1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 2a7093c6c6da14ef6c3eae459d5c93906df2ef4c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed May 3 14:35:24 2017 +0000

    update to org.apache.sling.commons.johnzon 1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1793655 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a2b1875..ff73087 100644
--- a/pom.xml
+++ b/pom.xml
@@ -139,7 +139,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.johnzon</artifactId>
-            <version>0.1.0-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
 		<dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 07/08: [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.8

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit d16b96898488bf0441c48ab5a6a3f7a8b23ab59d
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Sun May 7 21:37:42 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.1.8
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1794267 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index ff73087..248257d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
 
     <artifactId>org.apache.sling.discovery.base</artifactId>
     <packaging>bundle</packaging>
-    <version>1.1.7-SNAPSHOT</version>
+    <version>1.1.8</version>
 
     <name>Apache Sling Discovery Base</name>
     <description>Contains Connector and Properties support that some implementations might choose to build upon</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.1.8</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.1.8</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.base-1.1.8</url>
     </scm>
 
     <properties>
@@ -181,7 +181,7 @@
  		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.discovery.commons</artifactId>
-			<version>1.0.19-SNAPSHOT</version>
+			<version>1.0.20</version>
   		</dependency>
         <!-- besides including discovery.commons' normal jar above, 
               for testing a few test helper classes are also reused.
@@ -189,7 +189,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.discovery.commons</artifactId>
-            <version>1.0.19-SNAPSHOT</version>
+            <version>1.0.20</version>
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 04/08: SLING-6689: Switch to geronimo provider for javax.json api.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit ae435599a79dd40989bf5d57c13decb7c792e27a
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Tue Mar 28 21:17:22 2017 +0000

    SLING-6689: Switch to geronimo provider for javax.json api.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1789230 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index b2fc7b8..a2b1875 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,10 +131,16 @@
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-json_1.0_spec</artifactId>
+            <version>1.0-alpha-1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.johnzon</artifactId>
             <version>0.1.0-SNAPSHOT</version>
-            <scope>provided</scope>
+            <scope>test</scope>
         </dependency>
 		<dependency>
 			<groupId>org.apache.sling</groupId>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 06/08: SLING-6809 : toString improved to enlist more details - including a paranoia fallback that goes to the previous output in case of any Exception

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit fe51cdd4d6b4b01114b553a015417bf75d90c776
Author: Stefan Egli <st...@apache.org>
AuthorDate: Fri May 5 12:29:57 2017 +0000

    SLING-6809 : toString improved to enlist more details - including a paranoia fallback that goes to the previous output in case of any Exception
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1794027 13f79535-47bb-0310-9956-ffa450edef68
---
 .../base/commons/DefaultTopologyView.java          | 26 +++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
index a85c20b..978ebaf 100644
--- a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
+++ b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
@@ -243,8 +243,32 @@ public class DefaultTopologyView extends BaseTopologyView {
 
     @Override
     public String toString() {
+        StringBuilder sb = new StringBuilder();
+        try{
+            boolean firstCluster = true;
+            for (ClusterView clusterView : getClusterViews()) {
+                if (!firstCluster) {
+                    sb.append(", ");
+                }
+                firstCluster = false;
+                sb.append("[clusterId=" + clusterView.getId() + ", instances=");
+                boolean firstInstance = true;
+                for (InstanceDescription id : clusterView.getInstances()) {
+                    if (!firstInstance) {
+                        sb.append(", ");
+                    }
+                    firstInstance = false;
+                    sb.append("[id=" + id.getSlingId() + ", isLeader=" + id.isLeader() + 
+                            ", isLocal=" + id.isLocal() + "]");
+                }
+                sb.append("]");
+            }
+        } catch(Exception e) {
+            // paranoia fallback
+            sb = new StringBuilder(instances.toString());
+        }
         return "DefaultTopologyView[current=" + isCurrent() + ", num=" + instances.size() + ", instances="
-                + instances + "]";
+                + sb + "]";
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.