<commit_before>package com.nhn.pinpoint.profiler.util;


import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;

public class PreparedStatementUtils {

    private static final Pattern BIND_SETTER = Pattern.compile("set[A-Z]([a-zA-Z]+)");

    private static final List<Method> bindMethod;

    static {
        bindMethod = findBindVariableSetMethod0();
    }

    public static List<Method> findBindVariableSetMethod() {
        return bindMethod;
    }

    public static List<Method> findBindVariableSetMethod(BindVariableFilter filter) {
        List<Method> temp = new ArrayList<Method>(bindMethod.size());
        for (Method method : bindMethod) {
            if (filter.filter(method)) {
                temp.add(method);
            }
        }
        return temp;
    }

    static List<Method> findBindVariableSetMethod0() {
        Method[] methods = PreparedStatement.class.getDeclaredMethods();
        List<Method> bindMethod = new LinkedList<Method>();
        for (Method method : methods) {
            if (isSetter(method.getName())) {
                Class<?>[] parameterTypes = method.getParameterTypes();

                if (parameterTypes.length < 2) {
                    continue;
                }
                if (parameterTypes[0] != int.class) {
                    continue;
                }
                if (method.getReturnType() != void.class) {
                    continue;
                }
                if (method.getExceptionTypes().equals(SQLException.class)) {
                    continue;
                }
                bindMethod.add(method);
            }
        }
        return Collections.unmodifiableList(bindMethod);
    }


    public static boolean isSetter(String name) {<commit_msg>[강운덕] [LUCYSUS-1744] preparedStatmentUtil에서 bindvariable메소드를 잘못 찾는 코드가 있어 수정. <commit_after>package com.nhn.pinpoint.profiler.util;


import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;

public class PreparedStatementUtils {

    private static final Pattern BIND_SETTER = Pattern.compile("set[A-Z]([a-zA-Z]+)");

    private static final List<Method> bindMethod;

    static {
        bindMethod = findBindVariableSetMethod0();
    }

    public static List<Method> findBindVariableSetMethod() {
        return bindMethod;
    }

    public static List<Method> findBindVariableSetMethod(BindVariableFilter filter) {
        List<Method> temp = new ArrayList<Method>(bindMethod.size());
        for (Method method : bindMethod) {
            if (filter.filter(method)) {
                temp.add(method);
            }
        }
        return temp;
    }

    static List<Method> findBindVariableSetMethod0() {
        Method[] methods = PreparedStatement.class.getDeclaredMethods();
        List<Method> bindMethod = new LinkedList<Method>();
        for (Method method : methods) {
            if (isSetter(method.getName())) {
                Class<?>[] parameterTypes = method.getParameterTypes();

                if (parameterTypes.length < 2) {
                    continue;
                }
                if (parameterTypes[0] != int.class) {
                    continue;
                }
                if (method.getReturnType() != void.class) {
                    continue;
                }
                // sql exception을 던지는지 본다.
                if (!throwSqlException(method)) {
                    continue;
                }
                bindMethod.add(method);
            }
        }
        return Collections.unmodifiableList(bindMethod);
    }

    private static boolean throwSqlException(Method method) {
        Class<?>[] exceptionTypes = method.getExceptionTypes();
        if (exceptionTypes.length == 1) {
            Class<?> exceptionType = exceptionTypes[0];
            if (exceptionType.equals(SQLException.class)) {
                return true;
            }
        }
        return false;
    }


    public static boolean isSetter(String name) {
{'fraction_non_alphanumeric': 0.10205970840083314, 'fraction_numerical': 0.0032399907428835918, 'mean_word_length': 2.0587402689313516, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3022218', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1129, 'n_words': 235}