File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
server/src/main/java/invite/cron Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1010import java .sql .SQLTransactionRollbackException ;
1111import java .util .Optional ;
1212
13- public class DeadlockRetryLockProvider implements LockProvider {
13+ public class DeadlockLockProvider implements LockProvider {
1414
15- private static final Log LOG = LogFactory .getLog (DeadlockRetryLockProvider .class );
15+ private static final Log LOG = LogFactory .getLog (DeadlockLockProvider .class );
1616
1717 private final LockProvider delegate ;
1818
19- public DeadlockRetryLockProvider (LockProvider delegate ) {
19+ public DeadlockLockProvider (LockProvider delegate ) {
2020 this .delegate = delegate ;
2121 }
2222
@@ -29,8 +29,11 @@ public Optional<SimpleLock> lock(LockConfiguration lockConfiguration) {
2929 LOG .warn (String .format ("Deadlock acquiring ShedLock '%s', skipping cycle" ,
3030 lockConfiguration .getName ()));
3131 return Optional .empty (); // treat as "already locked", skip this cycle
32+ } else {
33+ LOG .error (String .format ("Unexpected error acquiring ShedLock '%s', skipping cycle" ,
34+ lockConfiguration .getName ()), e );
35+ return Optional .empty (); // treat as "already locked", skip this cycle, but make noise
3236 }
33- throw e ; // rethrow non-deadlock exceptions as-is
3437 }
3538 }
3639
Original file line number Diff line number Diff line change 11package invite .cron ;
22
33import net .javacrumbs .shedlock .core .LockProvider ;
4+ import net .javacrumbs .shedlock .core .SimpleLock ;
45import net .javacrumbs .shedlock .provider .jdbctemplate .JdbcTemplateLockProvider ;
56import net .javacrumbs .shedlock .spring .annotation .EnableSchedulerLock ;
67import org .springframework .context .annotation .Bean ;
@@ -24,12 +25,17 @@ public LockProvider lockProvider(DataSource dataSource) {
2425 .usingDbTime () // Use DB time, not app-node time — avoids clock skew
2526 .build ()
2627 );
27- return new DeadlockRetryLockProvider (delegate );
28+ return new DeadlockLockProvider (delegate );
2829 }
2930
3031 @ Bean
3132 @ Profile ("test" )
3233 public LockProvider noOpLockProvider () {
33- return lockConfiguration -> Optional .of (() -> {});
34+ return lockConfiguration -> Optional .of (() -> new SimpleLock () {
35+ @ Override
36+ public void unlock () {
37+ //noop
38+ }
39+ });
3440 }
3541}
You can’t perform that action at this time.
0 commit comments