From commits-return-22191-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Tue Oct 9 23:20:58 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 0729D180668 for ; Tue, 9 Oct 2018 23:20:57 +0200 (CEST) Received: (qmail 54327 invoked by uid 500); 9 Oct 2018 21:20:57 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 54317 invoked by uid 99); 9 Oct 2018 21:20:57 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Oct 2018 21:20:57 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 599CA82820; Tue, 9 Oct 2018 21:20:56 +0000 (UTC) Date: Tue, 09 Oct 2018 21:20:56 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo-maven-plugin] branch master updated: Improve spotbugs and cleanup m2e warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153912005632.2684.15457861117346205813@gitbox.apache.org> From: ctubbsii@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo-maven-plugin X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c1379d582747510d83335b85410197ef0849bdbe X-Git-Newrev: 21ee50c1f4365926937c4c2c88121ca5dc9bf1fe X-Git-Rev: 21ee50c1f4365926937c4c2c88121ca5dc9bf1fe X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo-maven-plugin.git The following commit(s) were added to refs/heads/master by this push: new 21ee50c Improve spotbugs and cleanup m2e warnings 21ee50c is described below commit 21ee50c1f4365926937c4c2c88121ca5dc9bf1fe Author: Christopher Tubbs AuthorDate: Tue Oct 9 17:17:54 2018 -0400 Improve spotbugs and cleanup m2e warnings * Suppress warnings in m2e (in Eclipse) about unknown plugin goals * Use spotbugs annotation, and remove main method with spotbugs error * Increase spotbugs rank to max (20) * Remove redundant plugin versions inherited from parent POM * Add safety check for instanceName characters * Limit the exception catching to the checked exceptions thrown --- pom.xml | 121 ++++++++++++++++++++- .../apache/accumulo/maven/plugin/StartMojo.java | 34 ++---- src/main/spotbugs/exclude-filter.xml | 17 +-- 3 files changed, 132 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 8a37c48..825cdc4 100644 --- a/pom.xml +++ b/pom.xml @@ -100,8 +100,16 @@ 3.5.4 source-release-tar src/main/spotbugs/exclude-filter.xml + 3.1.6 + + + com.github.spotbugs + spotbugs-annotations + ${spotbugs.version} + true + commons-io commons-io @@ -255,13 +263,13 @@ com.github.spotbugs spotbugs-maven-plugin - 3.1.6 + ${spotbugs.version} true Max true true - 16 + 20 com.overstock.findbugs @@ -464,7 +472,6 @@ org.apache.maven.plugins maven-invoker-plugin - 3.1.0 true ${project.build.directory}/it @@ -495,7 +502,6 @@ org.apache.maven.plugins maven-plugin-plugin - ${mavenPluginToolsVersion} @@ -541,12 +547,10 @@ org.apache.maven.plugins maven-plugin-plugin - ${mavenPluginToolsVersion} org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 @@ -620,5 +624,110 @@ + + m2e + + + m2e.version + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + [0,) + + install + + + + + + + + + org.apache.maven.plugins + maven-remote-resources-plugin + [0,) + + process + + + + + + + + + org.apache.rat + apache-rat-plugin + [0,) + + check + + + + + + + + + org.gaul + modernizer-maven-plugin + [0,) + + modernizer + + + + + + + + + com.github.ekryd.sortpom + sortpom-maven-plugin + [0,) + + sort + verify + + + + + + + + + com.github.koraktor + mavanagaiata + [0,) + + commit + + + + + + + + + + + + + + diff --git a/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java b/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java index 42131cf..ebd441e 100644 --- a/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java +++ b/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java @@ -32,6 +32,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Goal which starts an instance of {@link MiniAccumuloCluster}. */ @@ -55,56 +57,42 @@ public class StartMojo extends AbstractAccumuloMojo { required = true) private int zooKeeperPort; - private String miniClasspath; - static Set runningClusters = Collections .synchronizedSet(new HashSet<>()); + @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", + justification = "could restrict outputDirectory to target/ in future") @Override public void execute() throws MojoExecutionException { if (shouldSkip()) { return; } - File subdir = new File(new File(outputDirectory, "accumulo-maven-plugin"), instanceName); + if (!instanceName.matches("^[a-zA-Z0-9_-]+$")) { + throw new MojoExecutionException("instanceName must be only letters and numbers"); + } + File subdir = new File(new File(outputDirectory, "accumulo-maven-plugin"), instanceName); try { subdir = subdir.getCanonicalFile(); if (subdir.exists()) FileUtils.forceDelete(subdir); if (!subdir.mkdirs() && !subdir.isDirectory()) - throw new IOException(subdir + " cannot be created as a directory"); + throw new MojoExecutionException(subdir + " cannot be created as a directory"); MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(subdir, rootPassword); cfg.setInstanceName(instanceName); cfg.setZooKeeperPort(zooKeeperPort); - configureMiniClasspath(cfg, miniClasspath); + configureMiniClasspath(cfg, null); MiniAccumuloClusterImpl mac = new MiniAccumuloClusterImpl(cfg); getLog().info("Starting MiniAccumuloCluster: " + mac.getInstanceName() + " in " + mac.getConfig().getDir()); mac.start(); runningClusters.add(mac); - } catch (Exception e) { + } catch (IOException | InterruptedException e) { throw new MojoExecutionException( "Unable to start " + MiniAccumuloCluster.class.getSimpleName(), e); } } - public static void main(String[] args) throws MojoExecutionException { - int a = 0; - for (String arg : args) { - if (a < 2) { - // skip the first two args - a++; - continue; - } - StartMojo starter = new StartMojo(); - starter.outputDirectory = new File(args[0]); - String[] instArgs = arg.split(" "); - starter.instanceName = instArgs[0]; - starter.rootPassword = instArgs[1]; - starter.miniClasspath = args[1]; - starter.execute(); - } - } } diff --git a/src/main/spotbugs/exclude-filter.xml b/src/main/spotbugs/exclude-filter.xml index e4122bb..d2c9650 100644 --- a/src/main/spotbugs/exclude-filter.xml +++ b/src/main/spotbugs/exclude-filter.xml @@ -15,15 +15,10 @@ limitations under the License. --> - - - - - - - - - - - + + + + + +