BertOnline opened a new issue #2012:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2012
## Bug Report
### Which version of ElasticJob did you use?
3.0.1
### Which project did you use? ElasticJob-Lite or ElasticJob-Cloud?
ElasticJob-Lite
### Expected behavior
Job registration succeeded
### Actual behavior
```text
Job conflict with register center. The job 'test' in register center's class
is 'com.test.elasticjob.CustomJob$$Lambda$1124/0x0000000800a5d440', your job
class is 'com.test.elasticjob.CustomJob$$Lambda$1111/0x0000000800a60440'
```
### Reason analyze (If you can)
```java
@Slf4j
public final class SpringProxyJobClassNameProvider implements
JobClassNameProvider {
public SpringProxyJobClassNameProvider() {
log.info("create SpringProxyJobClassNameProvider");
}
@Override
public String getJobClassName(final ElasticJob elasticJob) {
return AopUtils.isAopProxy(elasticJob) ?
AopTargetUtils.getTarget(elasticJob).getClass().getName() :
elasticJob.getClass().getName();
}
}
```
When I create a SimpleJob using an anonymous inner class or lambda
expression, AopUtils.isAopProxy(elasticJob) == true, and return
elasticJob.getClass().getName(), it will cause a job conflict with ZK. For the
solution, refer to
org.apache.shardingsphere.elasticjob.lite.internal.setup.DefaultJobClassNameProvider#getJobClassName
```java
@Override
public String getJobClassName(final ElasticJob elasticJob) {
Class<? extends ElasticJob> elasticJobClass = elasticJob.getClass();
String elasticJobClassName = elasticJobClass.getName();
return isLambdaClass(elasticJobClass) ?
trimLambdaClassSuffix(elasticJobClassName) : elasticJobClassName;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]