<commit_before>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.util.annotation;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

/**
 * Abstract processor to assist in retrieving fields to check for annotations.
 * 
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.1
 */
public abstract class AbstractAnnotationBeanPostProcessor extends
    InstantiationAwareBeanPostProcessorAdapter {

    protected final Log log = LogFactory.getLog(getClass());

    public final Object postProcessBeforeInitialization(final Object bean,
        final String beanName) throws BeansException {

        final List<Field> fields = new ArrayList<Field>();
        final Class<?> clazz = bean.getClass();
        final Class<?>[] classes = clazz.getClasses();

        addDeclaredFields(clazz, fields);

        for (int i = 0; i < classes.length; i++) {
            addDeclaredFields(classes[i], fields);
        }

        try {
            for (final Field field : fields) {
                processField(field, bean, beanName);
            }
        } catch (final IllegalAccessException e) {
            log.warn("Could not access field: " + e.getMessage(), e);
        }
<commit_msg>correctly set the field accessibility<commit_after>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.util.annotation;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

/**
 * Abstract processor to assist in retrieving fields to check for annotations.
 * 
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.1
 */
public abstract class AbstractAnnotationBeanPostProcessor extends
    InstantiationAwareBeanPostProcessorAdapter {

    protected final Log log = LogFactory.getLog(getClass());

    public final Object postProcessBeforeInitialization(final Object bean,
        final String beanName) throws BeansException {

        final List<Field> fields = new ArrayList<Field>();
        final Class<?> clazz = bean.getClass();
        final Class<?>[] classes = clazz.getClasses();

        addDeclaredFields(clazz, fields);

        for (int i = 0; i < classes.length; i++) {
            addDeclaredFields(classes[i], fields);
        }

        try {
            for (final Field field : fields) {
                final boolean originalValue = field.isAccessible();
                field.setAccessible(true);
                processField(field, bean, beanName);
                field.setAccessible(originalValue);
            }
        } catch (final IllegalAccessException e) {
            log.warn("Could not access field: " + e.getMessage(), e);
        }

{'fraction_non_alphanumeric': 0.10067114093959731, 'fraction_numerical': 0.004085205719288007, 'mean_word_length': 3.1958384332925336, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2149597', 'n_tokens_mistral': 922, 'n_tokens_neox': 891, 'n_words': 252}