Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10098

AbstractJdbcMessageIdRepository<T> is not actually parameterizable

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.15.1
    • Fix Version/s: Future
    • Component/s: camel-core, camel-sql
    • Labels:
      None
    • Environment:
    • Estimated Complexity:
      Unknown

      Description

      The org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository class is advertised as being extendable in the documentation, and is declared as parameterized in the source code, so that developers "can extend to build custom JDBC idempotent repository."

      However, attempting to parameterize with anything other than String fails. The cause appears to be org.apache.camel.processor.idempotent.IdempotentConsumer, whose process() method assumes that the key is always a String before handing it off to the repository instance (which may in fact be a AbstractJdbcMessageIdRepository<T> where T is not String). The results is an unavoidable ClassCastException.

      Here is the relevant bit from a stack trace using public class IdempRepository extends AbstractJdbcMessageIdRepository<IdempKey>:

      Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to my.custom.IdempKey
      	at my.custom.IdempRepository.queryForInt(IdempRepository.java:18)[515:my-bundle:1.0.0.SNAPSHOT]
      	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository$1.doInTransaction(AbstractJdbcMessageIdRepository.java:122)[273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
      	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository$1.doInTransaction(AbstractJdbcMessageIdRepository.java:120)[273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)[202:org.apache.servicemix.bundles.spring-tx:3.2.12.RELEASE_1]
      	at org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository.add(AbstractJdbcMessageIdRepository.java:120)[273:org.apache.camel.camel-sql:2.15.1.redhat-620133]
      	at org.apache.camel.processor.idempotent.IdempotentConsumer.process(IdempotentConsumer.java:94)[198:org.apache.camel.camel-core:2.15.1.redhat-620133]
      

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              MattZ Matthew Zipay

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment