Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 64249200C10 for ; Fri, 3 Feb 2017 13:56:58 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 62C38160B55; Fri, 3 Feb 2017 12:56:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AA306160B48 for ; Fri, 3 Feb 2017 13:56:57 +0100 (CET) Received: (qmail 81755 invoked by uid 500); 3 Feb 2017 12:56:56 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 81743 invoked by uid 99); 3 Feb 2017 12:56:56 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2017 12:56:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4B62F18231E for ; Fri, 3 Feb 2017 12:56:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id OuP75CYAQhHu for ; Fri, 3 Feb 2017 12:56:55 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 1AE655F30B for ; Fri, 3 Feb 2017 12:56:55 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E177FE02D5 for ; Fri, 3 Feb 2017 12:56:51 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 98CBD2528B for ; Fri, 3 Feb 2017 12:56:51 +0000 (UTC) Date: Fri, 3 Feb 2017 12:56:51 +0000 (UTC) From: "Lorenzo Bernacchioni (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-4738) AnnotationValidationInterceptor : NullPointerException when method is null MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 03 Feb 2017 12:56:58 -0000 [ https://issues.apache.org/jira/browse/WW-4738?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15851456#comment-15851456 ] Lorenzo Bernacchioni commented on WW-4738: ------------------------------------------ OK, so it's been solved (I'm currently stuck in the {{2.3.24.1}}) Thanks. > AnnotationValidationInterceptor : NullPointerException when method is null > -------------------------------------------------------------------------- > > Key: WW-4738 > URL: https://issues.apache.org/jira/browse/WW-4738 > Project: Struts 2 > Issue Type: Bug > Components: Core Interceptors > Affects Versions: 2.3.24 > Reporter: Lorenzo Bernacchioni > Priority: Minor > Fix For: 2.5.next > > > In {{AnnotationValidationInterceptor}} class {{method}} can be null and {{method.getName()}} throws a NullPointerException > Why only in {{devMode}} a {{NoSuchMethodException}} is thrown ? > {code} > protected String doIntercept(ActionInvocation invocation) throws Exception { > Object action = invocation.getAction(); > if (action != null) { > Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod()); > Collection annotatedMethods = AnnotationUtils.getAnnotatedMethods(action.getClass(), SkipValidation.class); > if (annotatedMethods.contains(method)) > return invocation.invoke(); > //check if method overwites an annotated method > Class clazz = action.getClass().getSuperclass(); > while (clazz != null) { > annotatedMethods = AnnotationUtils.getAnnotatedMethods(clazz, SkipValidation.class); > if (annotatedMethods != null) { > for (Method annotatedMethod : annotatedMethods) { > if (annotatedMethod.getName().equals(method.getName()) > && Arrays.equals(annotatedMethod.getParameterTypes(), method.getParameterTypes()) > && Arrays.equals(annotatedMethod.getExceptionTypes(), method.getExceptionTypes())) > return invocation.invoke(); > } > } > clazz = clazz.getSuperclass(); > } > } > return super.doIntercept(invocation); > } > protected Method getActionMethod(Class actionClass, String methodName) throws NoSuchMethodException { > Method method = null; > try { > method = actionClass.getMethod(methodName, new Class[0]); > } catch (NoSuchMethodException e) { > // hmm -- OK, try doXxx instead > try { > String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1); > method = actionClass.getMethod(altMethodName, new Class[0]); > } catch (NoSuchMethodException e1) { > // throw the original one > if (devMode) { > throw e; > } > } > } > return method; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)