brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #714: BROOKLYN-513: fix coercion for jclouds re...
Date Fri, 02 Jun 2017 10:11:39 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/714#discussion_r119823922
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/javalang/MethodAccessibleReflections.java
---
    @@ -0,0 +1,173 @@
    +/*
    + * 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.brooklyn.util.javalang;
    +
    +import java.lang.reflect.Member;
    +import java.lang.reflect.Method;
    +import java.lang.reflect.Modifier;
    +import java.util.Set;
    +
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.collect.Sets;
    +
    +/**
    + * Use {@link Reflections} methods to access this. The methods are declared here (to
this 
    + * package-private class) so we can avoid having an ever-growing single Reflections class!
    + */
    +class MethodAccessibleReflections {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(MethodAccessibleReflections.class);
    +    
    +    /**
    +     * Contains method.toString() representations for methods we have logged about failing
to
    +     * set accessible (or to find an alternative accessible version). Use this to ensure
we 
    +     * log.warn just once per method, rather than risk flooding our log.
    +     */
    +    private static final Set<String> SET_ACCESSIBLE_FAILED_LOGGED_METHODS = Sets.newConcurrentHashSet();
    +    
    +    /**
    +     * Contains method.toString() representations for methods we have logged about having
set
    +     * accessible. Having to setAccessible is discouraged, so want a single log.warn
once per
    +     * method.
    +     */
    +    private static final Set<String> SET_ACCESSIBLE_SUCCEEDED_LOGGED_METHODS =
Sets.newConcurrentHashSet();
    +    
    +    /**
    +     * Contains method.toString() representations for methods for which {@link #findAccessibleMethod(Method)}

    +     * failed to find a suitable publicly accessible method.
    +     */
    +    private static final Set<String> FIND_ACCESSIBLE_FAILED_LOGGED_METHODS = Sets.newConcurrentHashSet();
    +
    +    static boolean trySetAccessible(Method method) {
    --- End diff --
    
    Should we merge this if it's not used?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message