Merge branch '1.6'

Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/04774b17
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/04774b17
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/04774b17

Branch: refs/heads/master
Commit: 04774b1714c5fb9f0a160262045767d4d2a1eefe
Parents: de1d3ee 98c524e
Author: Josh Elser <els...@apache.org>
Authored: Tue Dec 9 13:11:31 2014 -0500
Committer: Josh Elser <els...@apache.org>
Committed: Tue Dec 9 13:11:31 2014 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/accumulo/server/rpc/RpcWrapper.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/04774b17/server/base/src/main/java/org/apache/accumulo/server/rpc/RpcWrapper.java
----------------------------------------------------------------------
diff --cc 
server/base/src/main/java/org/apache/accumulo/server/rpc/RpcWrapper.java
index 7b34986,0000000..a488da9
mode 100644,000000..100644
--- a/server/base/src/main/java/org/apache/accumulo/server/rpc/RpcWrapper.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/rpc/RpcWrapper.java
@@@ -1,62 -1,0 +1,64 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.server.rpc;
 +
 +import java.lang.reflect.InvocationHandler;
 +import java.lang.reflect.Method;
 +import java.lang.reflect.Proxy;
 +
 +import org.apache.accumulo.core.trace.wrappers.RpcServerInvocationHandler;
 +import org.apache.accumulo.core.trace.wrappers.TraceWrap;
 +import org.apache.thrift.TApplicationException;
 +import org.apache.thrift.TException;
++import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +/**
 + * This class accommodates the changes in THRIFT-1805, which appeared in 
Thrift 0.9.1 and restricts client-side notification of server-side errors to
 + * {@link TException} only, by wrapping {@link RuntimeException} and {@link 
Error} as {@link TException}, so it doesn't just close the connection and look 
like
 + * a network issue, but informs the client that a {@link 
TApplicationException} had occurred, as it did in Thrift 0.9.0. This performs 
similar functions as
 + * {@link TraceWrap}, but with the additional action of translating 
exceptions. See also ACCUMULO-1691 and ACCUMULO-2950.
 + *
 + * @since 1.6.1
 + */
 +public class RpcWrapper {
 +
 +  public static <T> T service(final T instance) {
 +    InvocationHandler handler = new RpcServerInvocationHandler<T>(instance) {
++      private final Logger log = LoggerFactory.getLogger(instance.getClass());
 +      @Override
 +      public Object invoke(Object obj, Method method, Object[] args) throws 
Throwable {
 +        try {
 +          return super.invoke(obj, method, args);
 +        } catch (RuntimeException e) {
 +          String msg = e.getMessage();
-           LoggerFactory.getLogger(instance.getClass()).error(msg, e);
++          log.error(msg, e);
 +          throw new TException(msg);
 +        } catch (Error e) {
 +          String msg = e.getMessage();
-           LoggerFactory.getLogger(instance.getClass()).error(msg, e);
++          log.error(msg, e);
 +          throw new TException(msg);
 +        }
 +      }
 +    };
 +
 +    @SuppressWarnings("unchecked")
 +    T proxiedInstance = (T) 
Proxy.newProxyInstance(instance.getClass().getClassLoader(), 
instance.getClass().getInterfaces(), handler);
 +    return proxiedInstance;
 +  }
 +
 +}

Reply via email to