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

fix: the StdSchedulerFactory.GetDefaultScheduler method is not thread… #3212

Closed
wants to merge 2 commits into from

Conversation

ly303550688
Copy link
Contributor

the StdSchedulerFactory.GetDefaultScheduler method is not thread safe,need lock

@acjh
Copy link
Contributor

acjh commented Mar 19, 2018

Why is it not thread-safe?

@ly303550688
Copy link
Contributor Author

Run two unit test at the same time the, it will throw exception: Scheduler with name 'DefaultQuartzScheduler' already exists. because the AbpIntegratedTestBase class execute InitializeAbp twice

@acjh
Copy link
Contributor

acjh commented Mar 19, 2018

The test that you added passes.

@hikalkan
Copy link
Member

@ly303550688:

Run two unit test at the same time the, it will throw exception: Scheduler with name 'DefaultQuartzScheduler' already exists. because the AbpIntegratedTestBase class execute InitializeAbp twice

Adding lock ensures that it's not called concurrently. However, it will be executed twice anyway. Isn't that a problem?

@ly303550688
Copy link
Contributor Author

I think it's only going to happen in unit tests

@acjh
Copy link
Contributor

acjh commented Mar 20, 2018

The test that you added passes without your change.

@ly303550688
Copy link
Contributor Author

@acjh are you sure? If I delete my change , run the test will throw exception

@ly303550688
Copy link
Contributor Author

System.AggregateException : 发生一个或多个错误。
---- System.AggregateException : 发生一个或多个错误。
-------- Quartz.SchedulerException : Scheduler with name 'DefaultQuartzScheduler' already exists.
在 System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
在 System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
在 System.Threading.Tasks.Task.WaitAll(Task[] tasks)
在 Abp.Quartz.Tests.AbpQuartzConfigurationTests.TestGetScheduler()
----- Inner Stack Trace -----
在 System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) 在 Abp.Quartz.Configuration.AbpQuartzConfiguration.get_Scheduler() 在 Abp.Quartz.Tests.AbpQuartzConfigurationTests.<>c__DisplayClass0_0.<TestGetScheduler>b__1() 在 System.Threading.Tasks.Task1.InnerInvoke()
在 System.Threading.Tasks.Task.Execute()
----- Inner Stack Trace -----
在 Quartz.Impl.SchedulerRepository.Bind(IScheduler sched)
在 Quartz.Impl.StdSchedulerFactory.d__65.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 Quartz.Impl.StdSchedulerFactory.d__65.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Quartz.Impl.StdSchedulerFactory.d__69.MoveNext()

@stale
Copy link

stale bot commented Nov 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 22, 2019
@hikalkan hikalkan closed this Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants