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

HotelsDotCom / waggle-dance / #445

24 Jul 2025 02:27PM UTC coverage: 69.257% (-7.1%) from 76.395%
#445

push

patduin
Merge branch 'hive-3.x' of github.com:ExpediaGroup/waggle-dance into hive-3.x

2620 of 3783 relevant lines covered (69.26%)

0.69 hits per line

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

86.96
/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/server/ExceptionWrappingHMSHandler.java
1
/**
2
 * Copyright (C) 2016-2025 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.commons.lang.StringUtils;
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
  private static Logger log = LoggerFactory.getLogger(ExceptionWrappingHMSHandler.class);
1✔
34

35
  private final CloseableIHMSHandler baseHandler;
36
  private String user = "";
1✔
37

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

44
  public ExceptionWrappingHMSHandler(CloseableIHMSHandler baseHandler) {
1✔
45
    this.baseHandler = baseHandler;
1✔
46
  }
1✔
47

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

77
}
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

© 2026 Coveralls, Inc