<commit_before>/*
 * Copyright 2015-2021 the original author or authors.
 *
 * Licensed 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
 *
 *      https://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.springframework.cloud.stream.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.ClassUtils;

/**
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar {


	private Log logger = LogFactory.getLog(this.getClass());

	@Override
	public void registerBeanDefinitions(AnnotationMetadata metadata,
			BeanDefinitionRegistry registry) {
		AnnotationAttributes attrs = AnnotatedElementUtils.getMergedAnnotationAttributes(
				ClassUtils.resolveClassName(metadata.getClassName(), null),
				EnableBinding.class);
		try {
			for (Class<?> type : collectClasses(attrs, metadata.getClassName())) {
				if (!registry.containsBeanDefinition(type.getName())) {
					BindingBeanDefinitionRegistryUtils.registerBindingTargetBeanDefinitions(
							type, type.getName(), registry);
					BindingBeanDefinitionRegistryUtils
							.registerBindingTargetsQualifiedBeanDefinitions(ClassUtils
									.resolveClassName(metadata.getClassName(), null), type,
									registry);
				}
			}
		}
		catch (Exception e) {
			logger.warn("Failed to proxy EnableBinding annotation. If you are using functional programming style, "
					+ "ignore this warning, otherwise, annotation-based programming model is not and will "
					+ "not be suppported in native images.");
			// happens in native images, but we do not intend supporting annotation-based model for much longer
		}
	}

	private Class<?>[] collectClasses(AnnotationAttributes attrs, String className) {
		EnableBinding enableBinding = AnnotationUtils.synthesizeAnnotation(attrs,
				EnableBinding.class, ClassUtils.resolveClassName(className, null));
		return enableBinding.value();
	}
}
<commit_msg>Change from Exception to Throwable from last commit<commit_after>/*
 * Copyright 2015-2021 the original author or authors.
 *
 * Licensed 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
 *
 *      https://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.springframework.cloud.stream.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.ClassUtils;

/**
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar {


	private Log logger = LogFactory.getLog(this.getClass());

	@Override
	public void registerBeanDefinitions(AnnotationMetadata metadata,
			BeanDefinitionRegistry registry) {
		AnnotationAttributes attrs = AnnotatedElementUtils.getMergedAnnotationAttributes(
				ClassUtils.resolveClassName(metadata.getClassName(), null),
				EnableBinding.class);
		try {
			for (Class<?> type : collectClasses(attrs, metadata.getClassName())) {
				if (!registry.containsBeanDefinition(type.getName())) {
					BindingBeanDefinitionRegistryUtils.registerBindingTargetBeanDefinitions(
							type, type.getName(), registry);
					BindingBeanDefinitionRegistryUtils
							.registerBindingTargetsQualifiedBeanDefinitions(ClassUtils
									.resolveClassName(metadata.getClassName(), null), type,
									registry);
				}
			}
		}
		catch (Throwable e) {
			logger.warn("Failed to proxy EnableBinding annotation. If you are using functional programming style, "
					+ "ignore this warning, otherwise, annotation-based programming model is not and will "
					+ "not be suppported in native images.");
			// happens in native images, but we do not intend supporting annotation-based model for much longer
		}
	}

	private Class<?>[] collectClasses(AnnotationAttributes attrs, String className) {
		EnableBinding enableBinding = AnnotationUtils.synthesizeAnnotation(attrs,
				EnableBinding.class, ClassUtils.resolveClassName(className, null));
		return enableBinding.value();
	}
}

{'fraction_non_alphanumeric': 0.08603573792190602, 'fraction_numerical': 0.003970880211780278, 'mean_word_length': 5.069277108433735, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '5112297', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1465, 'n_words': 445}