You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/06/07 07:26:29 UTC

[GitHub] [sling-org-apache-sling-event] cziegeler commented on a diff in pull request #22: SLING-11379 do not register the same job over and over

cziegeler commented on code in PR #22:
URL: https://github.com/apache/sling-org-apache-sling-event/pull/22#discussion_r890855478


##########
src/main/java/org/apache/sling/event/impl/jobs/scheduling/JobScheduleBuilderImpl.java:
##########
@@ -117,4 +126,31 @@ public ScheduleBuilder suspend() {
         this.suspend = true;
         return this;
     }
+
+    /**
+     * In case a scheduleName was not provided we calculate on based on the available
+     * data so we can detect duplicates.
+     * @return a value which is identical for identical jobs
+     */
+    private String deriveScheduleName() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("topic="+topic)
+            .append(",suspend=" + suspend)
+            .append(",");
+
+        if (properties != null) {
+            // sort the properties and flatten them into a string
+            List<String> keys = new ArrayList<>(properties.keySet());
+            Collections.sort(keys);
+            for (String key: keys) {
+                sb.append(key).append("=").append(properties.get(key)).append(",");
+            }
+        }
+        // append all schedules
+        sb.append("schedules=").append(schedules);
+
+        String hashCode = new String("" + sb.toString().hashCode());

Review Comment:
   String.valueOf ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org