[ 
https://issues.apache.org/jira/browse/GOBBLIN-2097?focusedWorklogId=924035&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-924035
 ]

ASF GitHub Bot logged work on GOBBLIN-2097:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Jun/24 19:59
            Start Date: 23/Jun/24 19:59
    Worklog Time Spent: 10m 
      Work Description: umustafi commented on code in PR #3984:
URL: https://github.com/apache/gobblin/pull/3984#discussion_r1650176276


##########
gobblin-service/src/test/java/org/apache/gobblin/service/modules/orchestration/FlowLaunchHandlerTest.java:
##########
@@ -67,15 +67,34 @@ public void testUpdatePropsInJobDataMap() {
     
originalProperties.setProperty(ConfigurationKeys.SCHEDULER_PRESERVED_CONSENSUS_EVENT_TIME_MILLIS_KEY,
 "1");
     oldJobDataMap.put(GobblinServiceJobScheduler.PROPERTIES_KEY, 
originalProperties);
 
-    JobDataMap newJobDataMap = 
FlowLaunchHandler.updatePropsInJobDataMap(oldJobDataMap, leasedToAnotherStatus,
-        schedulerBackOffMillis);
+    JobDataMap newJobDataMap =
+        FlowLaunchHandler.updatePropsInJobDataMap(oldJobDataMap, 
leasedToAnotherStatus, schedulerBackOffMillis);
     Properties newProperties = (Properties) 
newJobDataMap.get(GobblinServiceJobScheduler.PROPERTIES_KEY);
     
Assert.assertTrue(newProperties.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY).endsWith(cronExpressionSuffix));
     Assert.assertNotEquals("0",
         
newProperties.getProperty(ConfigurationKeys.SCHEDULER_EXPECTED_REMINDER_TIME_MILLIS_KEY));
     
Assert.assertEquals(String.valueOf(leasedToAnotherStatus.getEventTimeMillis()),
         
newProperties.getProperty(ConfigurationKeys.SCHEDULER_PRESERVED_CONSENSUS_EVENT_TIME_MILLIS_KEY));
     
Assert.assertTrue(Boolean.parseBoolean(newProperties.getProperty(ConfigurationKeys.FLOW_IS_REMINDER_EVENT_KEY)));
+    // Note these objects refer to the same object because the original map is 
passed to updatePropsInJobDataMap
+    Assert.assertSame(oldJobDataMap, newJobDataMap);
+  }
+
+  /**
+   * Assert that the JobDataMap and Properties objects do not reference the 
same memory location if using
+   */
+  @Test
+  public void testDeepCopyJobDataMap() {
+    JobDataMap originalJobDataMap = new JobDataMap();
+    Properties properties = new Properties();
+    properties.setProperty("key", "value");
+    originalJobDataMap.put(GobblinServiceJobScheduler.PROPERTIES_KEY, 
properties);
+
+    JobDataMap newJobDataMap = 
FlowLaunchHandler.deepCopyJobDataMap(originalJobDataMap);
+
+    Assert.assertNotSame(originalJobDataMap, newJobDataMap);

Review Comment:
   see above comment





Issue Time Tracking
-------------------

    Worklog Id:     (was: 924035)
    Time Spent: 0.5h  (was: 20m)

> Use unique JobDataMaps and Properties to use for reminder events
> ----------------------------------------------------------------
>
>                 Key: GOBBLIN-2097
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-2097
>             Project: Apache Gobblin
>          Issue Type: Bug
>          Components: gobblin-service
>            Reporter: Urmi Mustafi
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> We notice that after deploying the service all subsequent scheduler triggers 
> after the very first one are incorrectly marked as reminders even when they 
> are for "original" events. This is a result of re-using the same JobDataMap 
> and Properties object between the original and reminder Jobs for the 
> Scheduler. The following changes create deep copies of both to use for the 
> reminders so adding a reminder flag in one will not affect the other. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to