This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-exec.git
commit c67d955a2bc9e2b228946c982a224fb4420fe67e Author: Gary Gregory <[email protected]> AuthorDate: Sat Jun 22 15:05:07 2024 -0400 Fix PMD EmptyCatchBlock by allowing commented blocks Fix PMD EmptyControlStatement by allowing commented blocks --- src/changes/changes.xml | 2 + src/conf/pmd-ruleset.xml | 76 ++++++++++++++++++++++ .../commons/exec/ShutdownHookProcessDestroyer.java | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 882c5144..389d305f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -31,6 +31,8 @@ <action dev="ggregory" type="fix" issue="EXEC-122" due-to="Marcono1234">Document PumpStreamHandler stream thread-safety requirements.</action> <action dev="ggregory" type="fix" due-to="Marcono1234">Fix CI only running on Ubuntu & improve OS-specific tests #143.</action> <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName in DefaultExecutor.</action> + <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix PMD EmptyCatchBlock by allowing commented blocks.</action> + <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix PMD EmptyControlStatement by allowing commented blocks.</action> <!-- UPDATE --> <action dev="ggregory" type="update" due-to="Dependabot">Bump org.apache.commons:commons-parent from 65 to 69 #174.</action> </release> diff --git a/src/conf/pmd-ruleset.xml b/src/conf/pmd-ruleset.xml new file mode 100644 index 00000000..108cf172 --- /dev/null +++ b/src/conf/pmd-ruleset.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<ruleset name='commons-bcel' xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> + <description> + This ruleset checks the code for discouraged programming constructs. + </description> + <!-- Default ruleset --> + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> + <rule ref="category/java/bestpractices.xml/CheckResultSet" /> + <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" /> + <rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> + <rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> + <rule ref="category/java/codestyle.xml/ExtendsObject" /> + <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" /> + <rule ref="category/java/codestyle.xml/TooManyStaticImports" /> + <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> + <rule ref="category/java/codestyle.xml/UnnecessaryImport" /> + <rule ref="category/java/codestyle.xml/UnnecessaryModifier" /> + <rule ref="category/java/codestyle.xml/UnnecessaryReturn" /> + <rule ref="category/java/codestyle.xml/UnnecessarySemicolon" /> + <rule ref="category/java/codestyle.xml/UselessParentheses" /> + <rule ref="category/java/codestyle.xml/UselessQualifiedThis" /> + <rule ref="category/java/design.xml/CollapsibleIfStatements" /> + <rule ref="category/java/design.xml/SimplifiedTernary" /> + <rule ref="category/java/design.xml/UselessOverridingMethod" /> + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" /> + <rule ref="category/java/errorprone.xml/BrokenNullCheck" /> + <rule ref="category/java/errorprone.xml/CheckSkipResult" /> + <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" /> + <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" /> + <rule ref="category/java/errorprone.xml/JumbledIncrementer" /> + <rule ref="category/java/errorprone.xml/MisplacedNullCheck" /> + <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" /> + <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" /> + <rule ref="category/java/errorprone.xml/UnconditionalIfStatement" /> + <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" /> + <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" /> + <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" /> + <rule ref="category/java/multithreading.xml/AvoidThreadGroup" /> + <rule ref="category/java/multithreading.xml/DontCallThreadRun" /> + <rule ref="category/java/multithreading.xml/DoubleCheckedLocking" /> + <rule ref="category/java/performance.xml/BigIntegerInstantiation" /> + <!-- Apache Commons Compress custom --> + <rule ref="category/java/errorprone.xml/EmptyCatchBlock"> + <properties> + <property name="allowCommentedBlocks" value="true" /> + <property name="allowExceptionNameRegex" value="^(ignored|expected)$" /> + </properties> + </rule> + <rule ref="category/java/codestyle.xml/EmptyControlStatement"> + <properties> + <property name="allowCommentedBlocks" value="true" /> + </properties> + </rule> +</ruleset> diff --git a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java index a7c5c9ca..77169c6c 100644 --- a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java +++ b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java @@ -149,7 +149,7 @@ public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable // this should return quickly, since it basically is a NO-OP. try { destroyProcessThread.join(20000); - } catch (final InterruptedException ie) { + } catch (final InterruptedException ignore) { // the thread didn't die in time // it should not kill any processes unexpectedly }
