incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1489965 - in /sling/trunk/bundles/extensions/discovery/impl/src: main/java/org/apache/sling/discovery/impl/ main/java/org/apache/sling/discovery/impl/cluster/voting/ main/java/org/apache/sling/discovery/impl/common/resource/ main/java/org/...
Date Wed, 05 Jun 2013 17:11:11 GMT
Author: cziegeler
Date: Wed Jun  5 17:11:10 2013
New Revision: 1489965

URL: http://svn.apache.org/r1489965
Log:
SLING-2908 :  Replace StringBuffer with StringBuilder 

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/resource/ResourceHelper.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/announcement/Announcement.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorServlet.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/TopologyWebConsolePlugin.java
Wed Jun  5 17:11:10 2013
@@ -495,7 +495,7 @@ public class TopologyWebConsolePlugin ex
 
             Set<InstanceDescription> newInstances = event.getNewView()
                     .getInstances();
-            StringBuffer sb = new StringBuffer();
+            StringBuilder sb = new StringBuilder();
             for (Iterator<InstanceDescription> it = newInstances.iterator(); it
                     .hasNext();) {
                 final InstanceDescription newInstanceDescription = it.next();
@@ -514,7 +514,7 @@ public class TopologyWebConsolePlugin ex
                         .getProperties();
                 Map<String, String> newProps = newInstanceDescription
                         .getProperties();
-                StringBuffer diff = diff(oldProps, newProps);
+                StringBuilder diff = diff(oldProps, newProps);
                 if (diff.length() > 0) {
                     if (sb.length() != 0) {
                         sb.append(", ");
@@ -527,7 +527,7 @@ public class TopologyWebConsolePlugin ex
             addEventLog(event.getType(), sb.toString());
         } else if (event.getType() == Type.TOPOLOGY_INIT) {
             this.currentView = event.getNewView();
-            StringBuffer details = new StringBuffer();
+            StringBuilder details = new StringBuilder();
             for (Iterator<InstanceDescription> it = event.getNewView()
                     .getInstances().iterator(); it.hasNext();) {
                 InstanceDescription newInstance = it.next();
@@ -549,7 +549,7 @@ public class TopologyWebConsolePlugin ex
                 addEventLog(event.getType(),
                         "new view: " + shortViewInfo(event.getNewView()));
             } else {
-                StringBuffer details = new StringBuffer();
+                StringBuilder details = new StringBuilder();
                 for (Iterator<InstanceDescription> it = event.getNewView()
                         .getInstances().iterator(); it.hasNext();) {
                     InstanceDescription newInstance = it.next();
@@ -637,12 +637,12 @@ public class TopologyWebConsolePlugin ex
     /**
      * calculate the difference between two sets of properties
      */
-    private StringBuffer diff(final Map<String, String> oldProps,
+    private StringBuilder diff(final Map<String, String> oldProps,
             final Map<String, String> newProps) {
         final Set<String> oldKeys = new HashSet<String>(oldProps.keySet());
         final Set<String> newKeys = new HashSet<String>(newProps.keySet());
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         for (Iterator<String> it = oldKeys.iterator(); it.hasNext();) {
             String oldKey = it.next();

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingView.java
Wed Jun  5 17:11:10 2013
@@ -49,7 +49,7 @@ public class VotingView extends View {
             .getLogger(VotingView.class);
 
     /**
-     * Create a new voting with the given list of instances, the given 
+     * Create a new voting with the given list of instances, the given
      * voting/view id and the given slingid of the initiator.
      * @param newViewId the new voting/view id
      * @param initiatorId the slingid of the initiator
@@ -78,7 +78,7 @@ public class VotingView extends View {
             String leaderElectionId = instanceResource.adaptTo(ValueMap.class)
                     .get("leaderElectionId", String.class);
             properties.put("leaderElectionId", leaderElectionId);
-            
+
             resourceResolver.create(membersResource, memberId, properties);
         }
         resourceResolver.commit();
@@ -97,7 +97,7 @@ public class VotingView extends View {
     public String toString() {
         final Resource members = getResource().getChild("members");
         String initiatorId = null;
-        final StringBuffer sb = new StringBuffer();
+        final StringBuilder sb = new StringBuilder();
         if (members != null) {
             Iterator<Resource> it = members.getChildren().iterator();
             while (it.hasNext()) {
@@ -256,7 +256,7 @@ public class VotingView extends View {
             return;
         }
         final ModifiableValueMap memberMap = memberResource.adaptTo(ModifiableValueMap.class);
-        
+
         if (vote == null) {
             memberMap.remove("vote");
         } else {

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/resource/ResourceHelper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/resource/ResourceHelper.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/resource/ResourceHelper.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/resource/ResourceHelper.java
Wed Jun  5 17:11:10 2013
@@ -40,31 +40,32 @@ public class ResourceHelper {
     public static Resource getOrCreateResource(
             final ResourceResolver resourceResolver, final String path)
             throws PersistenceException {
-    	return ResourceUtil.getOrCreateResource(resourceResolver, path, 
+    	return ResourceUtil.getOrCreateResource(resourceResolver, path,
     			(String)null, null, true);
     }
-    
+
     /**
      * @deprecated use {@link #getOrCreateResource(ResourceResolver, String)} instead
      */
+    @Deprecated
     public static Resource createResource(final ResourceResolver resourceResolver,
             final String path) throws PersistenceException {
     	return getOrCreateResource(resourceResolver, path);
     }
 
-    /** Compile a stringbuffer containing the properties of a resource - used for logging
**/
-    public static StringBuffer getPropertiesForLogging(final Resource resource) {
+    /** Compile a string builder containing the properties of a resource - used for logging
**/
+    public static StringBuilder getPropertiesForLogging(final Resource resource) {
         ValueMap valueMap;
         try{
             valueMap = resource.adaptTo(ValueMap.class);
         } catch(RuntimeException re) {
-            return new StringBuffer("non-existing resource: "+resource+" ("+re.getMessage()+")");
+            return new StringBuilder("non-existing resource: "+resource+" ("+re.getMessage()+")");
         }
         if (valueMap==null) {
-            return new StringBuffer("non-existing resource: "+resource+" (no ValueMap)");
+            return new StringBuilder("non-existing resource: "+resource+" (no ValueMap)");
         }
         final Set<Entry<String, Object>> entrySet = valueMap.entrySet();
-        final StringBuffer sb = new StringBuffer();
+        final StringBuilder sb = new StringBuilder();
         for (Iterator<Entry<String, Object>> it = entrySet.iterator(); it
                 .hasNext();) {
             Entry<String, Object> entry = it.next();

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/announcement/Announcement.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/announcement/Announcement.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/announcement/Announcement.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/announcement/Announcement.java
Wed Jun  5 17:11:10 2013
@@ -53,7 +53,7 @@ public class Announcement {
 
     private final static Logger logger = LoggerFactory
             .getLogger(Announcement.class);
-    
+
     /** the protocol version this announcement currently represents. Mismatching protocol
versions are
      * used to detect incompatible topology connectors
      */
@@ -61,16 +61,16 @@ public class Announcement {
 
     /** the sling id of the owner of this announcement. the owner is where this announcement
comes from **/
     private final String ownerId;
-    
+
     /** announcement protocol version **/
     private final int protocolVersion;
-    
+
     /** the local cluster view **/
     private ClusterView localCluster;
-    
+
     /** the incoming instances **/
     private List<Announcement> incomings = new LinkedList<Announcement>();
-    
+
     /** time this announcement was received **/
     private long created = System.currentTimeMillis();
 
@@ -79,14 +79,14 @@ public class Announcement {
 
     /** some information about the server where this announcement came from **/
     private String serverInfo;
-    
+
     /** whether or not this announcement represents a loop detected in the topology connectors
**/
     private boolean loop = false;
 
     public Announcement(final String ownerId) {
         this(ownerId, PROTOCOL_VERSION);
     }
-    
+
     public Announcement(final String ownerId, int protocolVersion) {
         if (ownerId==null || ownerId.length()==0) {
             throw new IllegalArgumentException("ownerId must not be null or empty");
@@ -94,10 +94,10 @@ public class Announcement {
         this.ownerId = ownerId;
         this.protocolVersion = protocolVersion;
     }
-    
+
     @Override
     public String toString() {
-        StringBuffer incomingList = new StringBuffer();
+        StringBuilder incomingList = new StringBuilder();
         for (Iterator<Announcement> it = incomings.iterator(); it.hasNext();) {
             Announcement anIncomingAnnouncement = it.next();
             if (incomingList.length()!=0) {
@@ -112,7 +112,7 @@ public class Announcement {
                 ", loop="+loop+
                 ", incomings="+incomingList+"]";
     }
-    
+
     /** check whether this is announcement contains the valid protocol version **/
     public boolean isCorrectVersion() {
         return (protocolVersion==PROTOCOL_VERSION);
@@ -152,17 +152,17 @@ public class Announcement {
     public boolean isInherited() {
         return inherited;
     }
-    
+
     /** Sets the loop falg - set true when this announcement should represent a loop detected
in the topology connectors **/
     public void setLoop(final boolean loop) {
         this.loop = loop;
     }
-    
+
     /** Returns the loop flag - set when this announcement represents a loop detected in
the topology connectors **/
     public boolean isLoop() {
         return loop;
     }
-    
+
     /** Returns the protocolVersion of this announcement **/
     public int getProtocolVersion() {
         return protocolVersion;
@@ -178,7 +178,7 @@ public class Announcement {
         return serverInfo;
     }
 
-    /** 
+    /**
      * Returns the slingid of the owner of this announcement.
      * <p>
      * The owner is the instance which initiated the topology connection
@@ -364,7 +364,7 @@ public class Announcement {
         return instances;
     }
 
-    /** 
+    /**
      * Persists this announcement using the given 'announcements' resource,
      * under which a node with the primary key is created
      **/
@@ -382,7 +382,7 @@ public class Announcement {
         }
     }
 
-    /** 
+    /**
      * Remove all announcements that match the given owner Id
      */
     public void removeInherited(final String ownerId) {

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorServlet.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorServlet.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorServlet.java
Wed Jun  5 17:11:10 2013
@@ -82,19 +82,19 @@ public class TopologyConnectorServlet ex
             whitelist.add(aWhitelistEntry);
         }
     }
-    
+
     @Override
     protected void doDelete(SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws ServletException,
             IOException {
-        
+
         if (!isWhitelisted(request)) {
-            // in theory it would be 403==forbidden, but that would reveal that 
+            // in theory it would be 403==forbidden, but that would reveal that
             // a resource would exist there in the first place
-            response.sendError(HttpServletResponse.SC_NOT_FOUND); 
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
-        
+
         final RequestPathInfo pathInfo = request.getRequestPathInfo();
         final String extension = pathInfo.getExtension();
         if (!"json".equals(extension)) {
@@ -102,22 +102,22 @@ public class TopologyConnectorServlet ex
             return;
         }
         final String selector = pathInfo.getSelectorString();
-        
+
         announcementRegistry.unregisterAnnouncement(selector);
     }
-    
+
     @Override
     protected void doPut(SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws ServletException,
             IOException {
 
         if (!isWhitelisted(request)) {
-            // in theory it would be 403==forbidden, but that would reveal that 
+            // in theory it would be 403==forbidden, but that would reveal that
             // a resource would exist there in the first place
-            response.sendError(HttpServletResponse.SC_NOT_FOUND); 
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
-        
+
         final RequestPathInfo pathInfo = request.getRequestPathInfo();
         final String extension = pathInfo.getExtension();
         if (!"json".equals(extension)) {
@@ -125,9 +125,9 @@ public class TopologyConnectorServlet ex
             return;
         }
         final String selector = pathInfo.getSelectorString();
-        
+
         final BufferedReader reader = request.getReader();
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         while(true) {
             final String line = reader.readLine();
             if (line==null) {
@@ -146,12 +146,12 @@ public class TopologyConnectorServlet ex
         try {
             incomingTopologyAnnouncement = Announcement
                     .fromJSON(topologyAnnouncementJSON);
-            
+
             if (!incomingTopologyAnnouncement.getOwnerId().equals(selector)) {
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST);
                 return;
             }
-            
+
             String slingId = clusterViewService.getSlingId();
             if (slingId==null) {
             	response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -198,7 +198,7 @@ public class TopologyConnectorServlet ex
                         .getClusterView());
                 announcementRegistry.addAllExcept(replyAnnouncement,
                         new AnnouncementFilter() {
-    
+
                             public boolean accept(final String receivingSlingId, Announcement
announcement) {
                                 if (announcement.getPrimaryKey().equals(
                                         incomingTopologyAnnouncement

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java?rev=1489965&r1=1489964&r2=1489965&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
Wed Jun  5 17:11:10 2013
@@ -87,9 +87,9 @@ public class Instance {
     private ResourceResolver resourceResolver;
 
     private int serviceId = 999;
-    
+
     private static Scheduler singletonScheduler = null;
-    
+
     private static Scheduler getSingletonScheduler() throws Exception {
     	if (singletonScheduler!=null) {
     		return singletonScheduler;
@@ -122,13 +122,13 @@ public class Instance {
             public long getHeartbeatTimeout() {
                 return 20;
             }
-            
+
             @Override
             public int getMinEventDelay() {
             	return 1;
             }
         };
-        
+
         clusterViewService = OSGiFactory.createClusterViewServiceImpl(slingId,
                 resourceResolverFactory, config);
         announcementRegistry = OSGiFactory.createITopologyAnnouncementRegistry(
@@ -140,7 +140,7 @@ public class Instance {
                 connectorRegistry, config,
                 resourceResolverFactory.getAdministrativeResourceResolver(null)
                         .adaptTo(Repository.class), getSingletonScheduler());
-        
+
 		discoveryService = OSGiFactory.createDiscoverService(slingId,
                 heartbeatHandler, clusterViewService, announcementRegistry,
                 resourceResolverFactory, config, connectorRegistry, getSingletonScheduler());
@@ -275,7 +275,7 @@ public class Instance {
         }
 
         PropertyIterator pi = node.getProperties();
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         while (pi.hasNext()) {
             Property p = pi.nextProperty();
             sb.append(" ");



Mime
View raw message