Skip to content

Commit

Permalink
managed thread factory - make context setup provider private with pro…
Browse files Browse the repository at this point in the history
…tected getter

Based on Arjan's comment, keep field private and provide protected
getter allows access to the field, but not changing it.
  • Loading branch information
aubi authored and Petr Aubrecht committed May 19, 2022
1 parent 68a3703 commit 62aad6f
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ManagedThreadFactoryImpl implements ManagedThreadFactory {
private Lock lock; // protects threads and stopped

private String name;
final protected ContextSetupProvider contextSetupProvider;
final private ContextSetupProvider contextSetupProvider;
// A non-null ContextService should be provided if thread context should
// be setup before running the Runnable passed in through the newThread
// method.
Expand Down Expand Up @@ -230,6 +230,16 @@ public void stop() {
}
}

/**
* Make contextSetupProvider available for extending classes if necessary to implement context saving in other
* moments than this implemention expects.
*
* @return contextSetupProvider
*/
protected ContextSetupProvider getContextSetupProvider() {
return contextSetupProvider;
}

@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
lock.lock();
Expand Down

0 comments on commit 62aad6f

Please sign in to comment.