private Map<String, String> convertMap(Map<String, String> dnMap, GetPartitionsArgs... args) {
    Map<String, String> parameters = MetaStoreServerUtils.trimMapNulls(dnMap,
        MetastoreConf.getBoolVar(getConf(), ConfVars.ORM_RETRIEVE_MAPNULLS_AS_EMPTY_STRINGS));
    if (parameters != null && args != null && args.length == 1) {
      // Pattern matching in Java might be different from the one used by the metastore backends,
      // An underscore (_) in pattern stands for (matches) any single character;
      // a percent sign (%) matches any sequence of zero or more characters.
      // See TestGetPartitionsUsingProjectionAndFilterSpecs#testPartitionProjectionEmptySpec.
      Pattern includePatt = null;
      if (StringUtils.isNotBlank(args[0].getIncludeParamKeyPattern())) {
        includePatt = Optional.of(args[0].getIncludeParamKeyPattern()).map(regex ->
            Pattern.compile(regex.replaceAll("%", ".*").replaceAll("_", "."))).get();
      }
      Pattern excludePatt = null;
      if (StringUtils.isNotBlank(args[0].getExcludeParamKeyPattern())) {
        excludePatt = Optional.of(args[0].getExcludeParamKeyPattern()).map(regex ->
            Pattern.compile(regex.replaceAll("%", ".*").replaceAll("_", "."))).get();;
      }
      final Pattern includePattern = includePatt;
      final Pattern excludePattern = excludePatt;
      return parameters.entrySet().stream().filter(entry -> {
        boolean matches = true;
        if (includePattern != null) {
          matches &= includePattern.matcher(entry.getKey()).matches();
        }
        if (excludePattern != null) {
          matches &= !excludePattern.matcher(entry.getKey()).matches();
        }
        return matches;
      }).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
    }
    return parameters;
  }
Makes shallow copy of a map to avoid DataNucleus mucking with our objects.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java