Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't wrap JobRepository in a tracing representation #3899

Closed
marcingrzejszczak opened this issue Apr 30, 2021 · 1 comment
Closed

Can't wrap JobRepository in a tracing representation #3899

marcingrzejszczak opened this issue Apr 30, 2021 · 1 comment

Comments

@marcingrzejszczak
Copy link
Contributor

The problem

I can't wrap the JobRepository used by JobBuilderFactory or StepBuilderFactory, the default one is being used.

Same type of a problem as presented here #816 .

related Sleuth code:
https://github.com/spring-cloud/spring-cloud-sleuth/blob/issues_%231904_batch_with_job_repository/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/instrument/batch/TraceBatchAutoConfiguration.java#L57-L60

Implementation issues

AbstractBatchConfiguration creates JobBuilderFactory and StepBuilderFactory as fields.

	@Override
	public void afterPropertiesSet() throws Exception {
		this.jobBuilderFactory = new JobBuilderFactory(jobRepository());
		this.stepBuilderFactory = new StepBuilderFactory(jobRepository(), transactionManager());
	}

JobRepository is being injected directly to it from the method bean defitinion

	@Bean
	public abstract JobRepository jobRepository() throws Exception;

Potential solutions

  • do not expose the bean unconditionally
  • inject any JobRepository not the concrete one
  • do not create JobBuilderFactory nor StepBuilderFactory via new.
@fmbenhassine
Copy link
Contributor

Resolved with #3942 .

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

No branches or pull requests

2 participants