You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/08/12 23:55:35 UTC

[9/9] camel git commit: CAMEL-11630: Fixed CS. This closes #1883.

CAMEL-11630: Fixed CS. This closes #1883.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/692b0f7d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/692b0f7d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/692b0f7d

Branch: refs/heads/camel-2.18.x
Commit: 692b0f7d130c025f1b7fd5a192d65f7c4043e8d5
Parents: 5b183fd
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Aug 13 01:52:26 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Aug 13 01:55:17 2017 +0200

----------------------------------------------------------------------
 .../idempotent/jpa/JpaMessageIdRepository.java  | 109 +++++++++----------
 1 file changed, 54 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/692b0f7d/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java b/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
index fabef9f..36fb2e4 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java
@@ -19,7 +19,6 @@ package org.apache.camel.processor.idempotent.jpa;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
@@ -97,22 +96,22 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
                 }
 
                 try {
-                	List<?> list = query(entityManager, messageId);
-                	if (list.isEmpty()) {
-                		MessageProcessed processed = new MessageProcessed();
-                		processed.setProcessorName(processorName);
-                		processed.setMessageId(messageId);
-                		processed.setCreatedAt(new Date());
-                		entityManager.persist(processed);
-                		entityManager.flush();
-                		entityManager.close();
-                		return Boolean.TRUE;
-                	} else {
-                		return Boolean.FALSE;
-                	}
-                } catch(Exception ex) {
-                	LOG.error("Something went wrong trying to add message to repository {}", ex);
-                	throw new PersistenceException(ex);
+                    List<?> list = query(entityManager, messageId);
+                    if (list.isEmpty()) {
+                        MessageProcessed processed = new MessageProcessed();
+                        processed.setProcessorName(processorName);
+                        processed.setMessageId(messageId);
+                        processed.setCreatedAt(new Date());
+                        entityManager.persist(processed);
+                        entityManager.flush();
+                        entityManager.close();
+                        return Boolean.TRUE;
+                    } else {
+                        return Boolean.FALSE;
+                    }
+                } catch (Exception ex) {
+                    LOG.error("Something went wrong trying to add message to repository {}", ex);
+                    throw new PersistenceException(ex);
                 } finally {
                     try {
                         if (entityManager.isOpen()) {
@@ -172,28 +171,28 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
                 if (isJoinTransaction()) {
                     entityManager.joinTransaction();
                 }
-                try{
-                	List<?> list = query(entityManager, messageId);
-                	if (list.isEmpty()) {
-                		return Boolean.FALSE;
-                	} else {
-                		MessageProcessed processed = (MessageProcessed) list.get(0);
-                		entityManager.remove(processed);
-                		entityManager.flush();
-                		entityManager.close();
-                		return Boolean.TRUE;
-                	}
-                } catch(Exception ex){
-                	LOG.error("Something went wrong trying to remove message to repository {}", ex);
-                	throw new PersistenceException(ex);
+                try {
+                    List<?> list = query(entityManager, messageId);
+                    if (list.isEmpty()) {
+                        return Boolean.FALSE;
+                    } else {
+                        MessageProcessed processed = (MessageProcessed) list.get(0);
+                        entityManager.remove(processed);
+                        entityManager.flush();
+                        entityManager.close();
+                        return Boolean.TRUE;
+                    }
+                } catch (Exception ex) {
+                    LOG.error("Something went wrong trying to remove message to repository {}", ex);
+                    throw new PersistenceException(ex);
                 } finally {
-                	try {
-                		if (entityManager.isOpen()) {
-                			entityManager.close();
-                		}
-                	} catch (Exception e) {
-                		// ignore
-                	}
+                    try {
+                        if (entityManager.isOpen()) {
+                            entityManager.close();
+                        }
+                    } catch (Exception e) {
+                        // ignore
+                    }
                 }
             }
         });
@@ -223,20 +222,20 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
                     entityManager.joinTransaction();
                 }
                 try {
-                	List<?> list = queryClear(entityManager);
-                	if (!list.isEmpty()) {
-                		Iterator it = list.iterator();
-                		while (it.hasNext()) {
-                			Object item = it.next();
-                			entityManager.remove(item);
-                		}
-                		entityManager.flush();
-                		entityManager.close();
-                	}
-                	return Boolean.TRUE;
-                } catch(Exception ex) {
-                	LOG.error("Something went wrong trying to clear the repository {}", ex);
-                	throw new PersistenceException(ex);
+                    List<?> list = queryClear(entityManager);
+                    if (!list.isEmpty()) {
+                        Iterator it = list.iterator();
+                        while (it.hasNext()) {
+                            Object item = it.next();
+                            entityManager.remove(item);
+                        }
+                        entityManager.flush();
+                        entityManager.close();
+                    }
+                    return Boolean.TRUE;
+                } catch (Exception ex) {
+                    LOG.error("Something went wrong trying to clear the repository {}", ex);
+                    throw new PersistenceException(ex);
                 } finally {
                     try {
                         if (entityManager.isOpen()) {
@@ -249,7 +248,7 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
             }
         });
 
-        LOG.debug("clear the store {}", MessageProcessed.class.getName());        
+        LOG.debug("clear the store {}", MessageProcessed.class.getName());
     }
 
     private List<?> query(final EntityManager entityManager, final String messageId) {
@@ -258,7 +257,7 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
         query.setParameter(2, messageId);
         return query.getResultList();
     }
-    
+
     private List<?> queryClear(final EntityManager entityManager) {
         Query query = entityManager.createQuery(QUERY_CLEAR_STRING);
         query.setParameter(1, processorName);
@@ -287,7 +286,7 @@ public class JpaMessageIdRepository extends ServiceSupport implements ExchangeId
     public void setSharedEntityManager(boolean sharedEntityManager) {
         this.sharedEntityManager = sharedEntityManager;
     }
-    
+
     @Override
     protected void doStart() throws Exception {
         // noop