You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/04/20 02:13:03 UTC
[18/24] james-project git commit: JAMES-2366 HBase data should rely
on IOUtils::closeQuietly
JAMES-2366 HBase data should rely on IOUtils::closeQuietly
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/696929b4
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/696929b4
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/696929b4
Branch: refs/heads/master
Commit: 696929b4192204e867d1033ff8553077ccc967f3
Parents: a7d5063
Author: benwa <bt...@linagora.com>
Authored: Tue Apr 17 09:57:39 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Apr 20 09:12:02 2018 +0700
----------------------------------------------------------------------
.../james/domainlist/hbase/HBaseDomainList.java | 37 +++------------
.../rrt/hbase/HBaseRecipientRewriteTable.java | 41 +++-------------
.../james/user/hbase/HBaseUsersRepository.java | 49 ++++----------------
3 files changed, 20 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/696929b4/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java b/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
index 1d51e40..6aff34a 100644
--- a/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
+++ b/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
@@ -24,6 +24,7 @@ import java.util.List;
import javax.inject.Inject;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
@@ -70,13 +71,7 @@ public class HBaseDomainList extends AbstractDomainList {
log.error("Error while counting domains from HBase", e);
throw new DomainListException("Error while counting domains from HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
return false;
}
@@ -97,13 +92,7 @@ public class HBaseDomainList extends AbstractDomainList {
log.error("Error while adding domain in HBase", e);
throw new DomainListException("Error while adding domain in HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -119,13 +108,7 @@ public class HBaseDomainList extends AbstractDomainList {
log.error("Error while deleting user from HBase", e);
throw new DomainListException("Error while deleting domain from HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -148,16 +131,8 @@ public class HBaseDomainList extends AbstractDomainList {
log.error("Error while counting domains from HBase", e);
throw new DomainListException("Error while counting domains from HBase", e);
} finally {
- if (resultScanner != null) {
- resultScanner.close();
- }
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(resultScanner);
+ IOUtils.closeQuietly(table);
}
return list;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/696929b4/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java b/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
index f859b08..7fa77ac 100644
--- a/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
+++ b/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
@@ -83,13 +84,7 @@ public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
log.error("Error while getting user domain mapping in HBase", e);
throw new RecipientRewriteTableException("Error while getting user domain mapping in HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -141,13 +136,7 @@ public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
if (resultScanner != null) {
resultScanner.close();
}
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
return map;
}
@@ -172,13 +161,7 @@ public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
log.error("Error while mapping address in HBase", e);
throw new RecipientRewriteTableException("Error while mapping address in HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -239,13 +222,7 @@ public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
log.error("Error while removing mapping from HBase", e);
throw new RecipientRewriteTableException("Error while removing mapping from HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -270,13 +247,7 @@ public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
log.error("Error while adding mapping in HBase", e);
throw new RecipientRewriteTableException("Error while adding mapping in HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/696929b4/server/data/data-hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java b/server/data/data-hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
index 024b5b8..c69b2cc 100644
--- a/server/data/data-hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
+++ b/server/data/data-hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
@@ -26,6 +26,7 @@ import java.util.Locale;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
@@ -101,13 +102,7 @@ public class HBaseUsersRepository extends AbstractUsersRepository {
log.error("Error while deleting user from HBase", e);
throw new UsersRepositoryException("Error while deleting user from HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -147,16 +142,8 @@ public class HBaseUsersRepository extends AbstractUsersRepository {
log.error("Error while counting users from HBase", e);
throw new UsersRepositoryException("Error while counting users from HBase", e);
} finally {
- if (resultScanner != null) {
- resultScanner.close();
- }
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(resultScanner);
+ IOUtils.closeQuietly(table);
}
}
@@ -179,16 +166,8 @@ public class HBaseUsersRepository extends AbstractUsersRepository {
log.error("Error while scanning users from HBase", e);
throw new UsersRepositoryException("Error while scanning users from HBase", e);
} finally {
- if (resultScanner != null) {
- resultScanner.close();
- }
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(resultScanner);
+ IOUtils.closeQuietly(table);
}
return list.iterator();
}
@@ -219,13 +198,7 @@ public class HBaseUsersRepository extends AbstractUsersRepository {
log.error("Error while counting users from HBase", e);
throw new UsersRepositoryException("Error while counting users from HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
@@ -255,13 +228,7 @@ public class HBaseUsersRepository extends AbstractUsersRepository {
log.error("Error while adding user in HBase", e);
throw new UsersRepositoryException("Error while adding user in HBase", e);
} finally {
- if (table != null) {
- try {
- table.close();
- } catch (IOException e) {
- // Do nothing, we can't get access to the HBaseSchema.
- }
- }
+ IOUtils.closeQuietly(table);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org