From issues-return-13069-archive-asf-public=cust-asf.ponee.io@sentry.apache.org Wed Feb 21 19:21:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9390B18067E for ; Wed, 21 Feb 2018 19:21:03 +0100 (CET) Received: (qmail 1009 invoked by uid 500); 21 Feb 2018 18:21:02 -0000 Mailing-List: contact issues-help@sentry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@sentry.apache.org Received: (qmail 997 invoked by uid 99); 21 Feb 2018 18:21:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2018 18:21:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 05EDD1A07EF for ; Wed, 21 Feb 2018 18:21:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.311 X-Spam-Level: X-Spam-Status: No, score=-102.311 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id y3SK9doCWE2y for ; Wed, 21 Feb 2018 18:21:01 +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 066845F3CD for ; Wed, 21 Feb 2018 18:21:01 +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 85764E0254 for ; Wed, 21 Feb 2018 18:21:00 +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 3DB7B21001 for ; Wed, 21 Feb 2018 18:21:00 +0000 (UTC) Date: Wed, 21 Feb 2018 18:21:00 +0000 (UTC) From: =?utf-8?Q?Sergio_Pe=C3=B1a_=28JIRA=29?= To: issues@sentry.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SENTRY-1572) SentryMain() shouldn't dynamically load tool class MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SENTRY-1572?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Sergio Pe=C3=B1a updated SENTRY-1572: -------------------------------- Resolution: Fixed Fix Version/s: 2.1.0 Status: Resolved (was: Patch Available) Thanks [~xyu2017] for your contribution. I committed to master. > SentryMain() shouldn't dynamically load tool class > -------------------------------------------------- > > Key: SENTRY-1572 > URL: https://issues.apache.org/jira/browse/SENTRY-1572 > Project: Sentry > Issue Type: Improvement > Components: Sentry > Reporter: Alexander Kolbasov > Assignee: Xinran Tinney > Priority: Major > Labels: bite-sized, newbie > Fix For: 2.1.0 > > Attachments: SENTRY-1572.001.patch, SENTRY-1572.002.patch, SENTRY= -1572.003.patch, SENTRY-1572.004.patch, SENTRY-1572.005.patch > > > TheSentryMain class currently works by mapping the command name to a Java= class that is then dynamically loaded: > {code} > String commandName =3D commandLine.getOptionValue(COMMAND); > String commandClazz =3D COMMANDS.get(commandName); > Object command; > try { > command =3D Class.forName(commandClazz.trim()).newInstance(); > } catch (Exception e) { > String msg =3D "Could not create instance of " + commandClazz + " f= or command " + commandName; > throw new IllegalStateException(msg, e); > } > if (!(command instanceof Command)) { > String msg =3D "Command " + command.getClass().getName() + " is not= an instance of " > + Command.class.getName(); > throw new IllegalStateException(msg); > } > ((Command)command).run(commandLine.getArgs()); > } > {code} > This ia too complicated and causes subtle problems at runtime. Instead it= should just create a new instance of appropriate class and call it directl= y. -- This message was sent by Atlassian JIRA (v7.6.3#76005)