Skip to content

Document that Job objects are immutable#6

Open
kwin wants to merge 1 commit into
masterfrom
feature/document-immutability-of-jobs
Open

Document that Job objects are immutable#6
kwin wants to merge 1 commit into
masterfrom
feature/document-immutability-of-jobs

Conversation

@kwin
Copy link
Copy Markdown
Member

@kwin kwin commented Aug 13, 2025

No description provided.

@kwin kwin requested review from klcodanr and stefan-egli August 13, 2025 10:03
@kwin kwin force-pushed the feature/document-immutability-of-jobs branch from a867120 to 415496a Compare August 13, 2025 10:06
@kwin kwin force-pushed the feature/document-immutability-of-jobs branch from 415496a to 3684a5d Compare August 13, 2025 10:10
@sonarqubecloud
Copy link
Copy Markdown

Comment on lines +31 to +32
* (In the edge case of the job being processed on the same instance some properties of the job instance might be updated
* but you should not rely on it).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the case? IIUC then a Job - that can be retrieved via getJobById / findJobs or created by addJob contain a snapshot of the properties at that time. After that moment, the particular Job instance indeed no longer changes. You'd have to get the Job afresh to get any update. Or am I missing something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was confused by the fact that JobImpl has methods which modify the state like https://github.com/apache/sling-org-apache-sling-event/blob/c704d540570319e73301afdade23f4543ef034ff/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java#L255 or https://github.com/apache/sling-org-apache-sling-event/blob/c704d540570319e73301afdade23f4543ef034ff/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java#L315 but due to the fact that JobImpl objects are never shared but always newly created by the JobManager I think we can safely remove this sentence.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants