<commit_before>package com.instinctools.padlaboris.application.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;

/**
 * Interceptor used for logging controller method calls and completion status.
 */
@Slf4j
public class LoggerInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(final HttpServletRequest request,
                             final HttpServletResponse response,
                             final Object handler) throws Exception {
        final Method method = ((HandlerMethod) handler).getMethod();
        final String message = "Called method '"
                + method.getName()
                + "' in controller '"
                + method.getDeclaringClass().getSimpleName()
                + "'";

        log.info(message);
        return super.preHandle(request, response, handler);
    }

    @Override
    public void afterCompletion(final HttpServletRequest request,
                                final HttpServletResponse response,
                                final Object handler,
                                final Exception ex) throws Exception {
        final Method method = ((HandlerMethod) handler).getMethod();
        final String message = "Method '"
                + method.getName()
                + "' in controller '"
                + method.getDeclaringClass().getSimpleName()
                + "' finished with code "
                + Integer.toString(response.getStatus());

        log.info(message);
        super.afterCompletion(request, response, handler, ex);
    }
}
<commit_msg>fix class cast exception in interceptor<commit_after>package com.instinctools.padlaboris.application.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;

/**
 * Interceptor used for logging controller method calls and completion status.
 */
@Slf4j
public class LoggerInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(final HttpServletRequest request,
                             final HttpServletResponse response,
                             final Object handler) throws Exception {

        if (handler instanceof HandlerMethod) {
            final Method method = ((HandlerMethod) handler).getMethod();
            final String message = "Called method '"
                    + method.getName()
                    + "' in controller '"
                    + method.getDeclaringClass().getSimpleName()
                    + "'";

            log.info(message);
        }

        return super.preHandle(request, response, handler);
    }

    @Override
    public void afterCompletion(final HttpServletRequest request,
                                final HttpServletResponse response,
                                final Object handler,
                                final Exception ex) throws Exception {

        if (handler instanceof HandlerMethod) {
            final Method method = ((HandlerMethod) handler).getMethod();
            final String message = "Method '"
                    + method.getName()
                    + "' in controller '"
                    + method.getDeclaringClass().getSimpleName()
                    + "' finished with code "
                    + Integer.toString(response.getStatus());

            log.info(message);
        }

        super.afterCompletion(request, response, handler, ex);
    }
}

{'fraction_non_alphanumeric': 0.082389289392379, 'fraction_numerical': 0.001544799176107106, 'mean_word_length': 2.098086124401914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1378114', 'n_tokens_mistral': 889, 'n_tokens_neox': 852, 'n_words': 217}