Skip to content

Make interface signature check optional in PersistenceExceptionTranslationInterceptor so it can translate all exceptions [SPR-6630] #11296

@spring-projects-issues

Description

@spring-projects-issues

Dave Syer opened SPR-6630 and commented

PersistenceExceptionTranslationInterceptor does this:

public Object invoke(MethodInvocation mi) throws Throwable {
     try {
          return mi.proceed();
     }
     catch (RuntimeException ex) {
          // Let it throw raw if the type of the exception is on the throws clause of the method.
          if (ReflectionUtils.declaresException(mi.getMethod(), ex.getClass())) {
               throw ex;
          }
          else {
               throw DataAccessUtils.translateIfNecessary(ex, this.persistenceExceptionTranslator);
          }
     }
}

Could we make the declaresException() test optional (default true)? The reason I ask is that we have some framework interfaces in Batch in particular that declare that they throw Exception, but the concrete implementation does not (or need not), and it is impossible to use the existing interceptor with such classes because of their interface.


Affects: 3.0 GA

Issue Links:

  • BATCH-1464 Allow for use of PersistenceExceptionTranslator on JpaItemWriter ("is depended on by")
  • BATCH-1472 Allow for use of PersistenceExceptionTranslator on JpaItemWriter ("is depended on by")

Referenced from: commits 2e03288

1 votes, 1 watchers

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions