Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/java/org/apache/sling/event/jobs/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@


/**
* A job
* A job encapsulates a task processed by a job consumer. The job may already be finished at the time a Job object is created.
* It exposes metadata in form of properties.
* A job is <strong>immutable</strong>, meaning that once created the properties/state of the job will not change.
* (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).
Comment on lines +31 to +32
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.

* <p>
*
*
* Property Types
* <h1>Property Types</h1>
*
* In general all scalar types and all serializable classes are supported as
* property types. However, in order for deseralizing classes these must be
Expand All @@ -41,7 +45,7 @@
* for this behavior as it only supports long but neither integer nor short.
* Therefore if you are dealing with numbers, use the {@link #getProperty(String, Class)}
* method to get the correct type instead of directly casting it.
*
*
* @since 1.2
*/
@ProviderType
Expand Down