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

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

Closed
spring-projects-issues opened this issue Dec 30, 2009 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've added a corresponding "alwaysTranslate" flag: off by default; can be switched on to enforce a translation in any case.

Juergen

@spring-projects-issues spring-projects-issues added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants