• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HotelsDotCom / waggle-dance / #318

pending completion
#318

push

web-flow
Feature/upgrade springboot (#268)

* update springboot to 2.1.18

* update springboot to 2.2.13

* Upgrade to srping boot 2.7.11

* Update changelog

* Update changelog

* fix version

3 of 3 new or added lines in 2 files covered. (100.0%)

132 of 3058 relevant lines covered (4.32%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/ExceptionWrappingHMSHandler.java
1
/**
2
 * Copyright (C) 2016-2019 Expedia, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.hotels.bdp.waggledance.server;
17

18
import java.lang.reflect.InvocationHandler;
19
import java.lang.reflect.InvocationTargetException;
20
import java.lang.reflect.Method;
21
import java.lang.reflect.Proxy;
22
import java.lang.reflect.UndeclaredThrowableException;
23
import java.util.Arrays;
24

25
import org.apache.hadoop.hive.metastore.IHMSHandler;
26
import org.apache.hadoop.hive.metastore.api.MetaException;
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

30
import com.hotels.bdp.waggledance.server.security.NotAllowedException;
31

32
public class ExceptionWrappingHMSHandler implements InvocationHandler {
33

34
  private final static Logger LOG = LoggerFactory.getLogger(ExceptionWrappingHMSHandler.class);
×
35

36
  private final IHMSHandler baseHandler;
37

38
  public static IHMSHandler newProxyInstance(IHMSHandler baseHandler) {
39
    return (IHMSHandler) Proxy.newProxyInstance(ExceptionWrappingHMSHandler.class.getClassLoader(),
×
40
        new Class[] { IHMSHandler.class }, new ExceptionWrappingHMSHandler(baseHandler));
×
41
  }
42

43
  public ExceptionWrappingHMSHandler(IHMSHandler baseHandler) {
×
44
    this.baseHandler = baseHandler;
×
45
  }
×
46

47
  @Override
48
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
49
    try {
50
      return method.invoke(baseHandler, args);
×
51
    } catch (InvocationTargetException e) {
×
52
      Throwable cause = e.getCause();
×
53
      if (cause instanceof NotAllowedException) {
×
54
        // not logging this as this is an "expected" exception, just rewriting it so any client can do something with
55
        // the thrift exception.
56
        throw new MetaException("Waggle Dance: " + cause.getMessage());
×
57
      } else if (cause instanceof WaggleDanceServerException) {
×
58
        LOG.debug("Got error processing '{}' with args '{}'", method, Arrays.toString(args), cause);
×
59
        throw new MetaException("Waggle Dance: " + cause.getMessage());
×
60
      } else {
61
        // Need to unwrap this, so callers get the correct exception thrown by the handler.
62
        throw e.getCause();
×
63
      }
64
    } catch (UndeclaredThrowableException e) {
×
65
      // Need to unwrap this, so callers get the correct exception thrown by the handler.
66
      throw e.getCause();
×
67
    }
68
  }
69

70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc