Skip to content

Commit

Permalink
Use the same Checkstyle configuration as in branch POOL_2_X
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Feb 11, 2025
1 parent e200ab6 commit 3d132b3
Show file tree
Hide file tree
Showing 43 changed files with 847 additions and 834 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<commons.componentid>pool</commons.componentid>
<commons.module.name>org.apache.commons.pool3</commons.module.name>
<commons.rc.version>RC1</commons.rc.version>
<checkstyle.suppress.file>${basedir}/src/conf/checkstyle-suppressions.xml</checkstyle.suppress.file>
<!-- Java 17 -->
<commons.release.version>3.0.0</commons.release.version>
<commons.release.desc>(Java 17)</commons.release.desc>
Expand Down Expand Up @@ -137,8 +138,10 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
<enableRulesSummary>false</enableRulesSummary>
<suppressionsLocation>${checkstyle.suppress.file}</suppressionsLocation>
<headerLocation>${basedir}/license-header.txt</headerLocation>
<enableRulesSummary>false</enableRulesSummary>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin>
Expand Down
25 changes: 25 additions & 0 deletions src/conf/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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
https://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.
-->
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<!-- SEE: http://checkstyle.sourceforge.net/config.html#Examples -->
<suppressions>
<suppress checks="JavadocPackage" files="src[/\\]test[/\\]java[/\\]" />
<suppress checks="NewlineAtEndOfFile" files="./target/classes/META-INF/maven/org.apache.commons/commons-pool3/pom.properties" />
</suppressions>
118 changes: 59 additions & 59 deletions src/conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,78 +22,78 @@
<!--
Checkstyle checks configured for Maven.
-->

<module name="Checker">

<property name="localeLanguage" value="en"/>

<!-- No tabs allowed! -->
<module name="FileTabCharacter"/>

<module name="TreeWalker">

<!-- Operator must be at end of wrapped line -->
<module name="OperatorWrap">
<property name="option" value="eol"/>
</module>

<!-- Interfaces must be types (not just constants) -->
<module name="InterfaceIsType"/>

<!-- Must have class / interface header comments -->
<module name="JavadocType"/>

<!-- Require method javadocs, allow undeclared RTE -->
<module name="JavadocMethod">
</module>

<!-- Require field javadoc -->
<module name="JavadocVariable">
<property name="scope" value="protected"/>
</module>

<!-- No public fields -->
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
<property name="protectedAllowed" value="true"/>
</module>

<!-- Require hash code override when equals is -->
<module name="EqualsHashCode"/>

<!-- Disallow unnecessary instantiation of Boolean, String -->
<module name="IllegalInstantiation">
<property name="classes" value="java.lang.Boolean, java.lang.String"/>
</module>
<module name="ImportOrder">
<property name="option" value="top"/>
<property name="groups" value="java,javax,org"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
</module>
<module name="ParenPad" />
<module name="TypecastParenPad" />
</module>

<!-- Require package Javadoc -->
<property name="localeLanguage" value="en" />
<module name="FileTabCharacter" />
<module name="JavadocPackage">
<!-- setting allowLegacy means it will check for package.html instead of just package-info.java -->
<property name="allowLegacy" value="true"/>
<property name="allowLegacy" value="true" />
</module>

<module name="LineLength">
<property name="max" value="160"/>
<property name="max" value="160" />
</module>
<module name="NewlineAtEndOfFile">
<!-- Files are saved in the repository with LF line endings; on Windows, use git config core.autocrlf input -->
<property name="lineSeparator" value="lf" />
</module>
<!-- @author tags are deprecated -->
<module name="RegexpSingleline">
<property name="format" value="^\s+\*\s+@author\s" />
<property name="message" value="Deprecated @author tag" />
<property name="fileExtensions" value="java" />
<property name="severity" value="warning" />
</module>
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$" />
<property name="message" value="Line has trailing spaces." />
</module>
<module name="TreeWalker">
<module name="ArrayTypeStyle" />
<module name="AvoidStarImport" />
<module name="CovariantEquals" />
<module name="DefaultComesLast" />
<module name="EmptyBlock">
<property name="option" value="text" />
</module>
<module name="EqualsHashCode" />
<module name="ExplicitInitialization" />
<module name="FinalLocalVariable" />
<module name="IllegalInstantiation" />
<module name="ImportOrder">
<property name="option" value="top" />
<property name="groups" value="java,javax,org" />
<property name="ordered" value="true" />
<property name="separated" value="true" />
</module>
<module name="InterfaceIsType" />
<module name="JavadocType" />
<module name="JavadocMethod">
</module>
<module name="JavadocVariable">
<property name="scope" value="protected" />
</module>
<module name="LeftCurly" />
<module name="MethodParamPad"/>
<module name="MissingOverride" />
<module name="ModifierOrder" />
<module name="MultipleVariableDeclarations" />
<module name="NeedBraces" />
<module name="ParenPad" />
<module name="RedundantImport" />
<module name="RedundantModifier" />
<module name="RightCurly" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="SuperClone" />
<module name="SuperFinalize" />
<module name="TypecastParenPad" />
<module name="UnnecessaryParentheses" />
<module name="UnusedImports" />
<module name="UpperEll" />
<module name="VisibilityModifier">
<property name="packageAllowed" value="true" />
<property name="protectedAllowed" value="true" />
</module>
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />
</module>
</module>
17 changes: 7 additions & 10 deletions src/main/java/org/apache/commons/pool3/PoolUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static final class ErodingFactor {
* @param factor
* erosion factor
*/
public ErodingFactor(final float factor) {
ErodingFactor(final float factor) {
this.factor = factor;
nextShrinkMillis = System.currentTimeMillis() + (long) (900000 * factor); // now + 15 min * factor
idleHighWaterMark = 1;
Expand Down Expand Up @@ -133,11 +133,9 @@ private static class ErodingKeyedObjectPool<K, V, E extends Exception> implement
* events
* @see #erodingFactor
*/
protected ErodingKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool,
final ErodingFactor erodingFactor) {
ErodingKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool, final ErodingFactor erodingFactor) {
if (keyedPool == null) {
throw new IllegalArgumentException(
MSG_NULL_KEYED_POOL);
throw new IllegalArgumentException(MSG_NULL_KEYED_POOL);
}
this.keyedPool = keyedPool;
this.erodingFactor = erodingFactor;
Expand All @@ -154,8 +152,7 @@ protected ErodingKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool,
* events
* @see #erodingFactor
*/
public ErodingKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool,
final float factor) {
ErodingKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool, final float factor) {
this(keyedPool, new ErodingFactor(factor));
}

Expand Down Expand Up @@ -351,7 +348,7 @@ private static final class ErodingObjectPool<T, E extends Exception> implements
* events
* @see #factor
*/
public ErodingObjectPool(final ObjectPool<T, E> pool, final float factor) {
ErodingObjectPool(final ObjectPool<T, E> pool, final float factor) {
this.pool = pool;
this.factor = new ErodingFactor(factor);
}
Expand All @@ -360,7 +357,7 @@ public ErodingObjectPool(final ObjectPool<T, E> pool, final float factor) {
* {@inheritDoc}
*/
@Override
public void addObject() throws E, IllegalStateException, UnsupportedOperationException{
public void addObject() throws E, IllegalStateException, UnsupportedOperationException {
pool.addObject();
}

Expand Down Expand Up @@ -492,7 +489,7 @@ private static final class ErodingPerKeyKeyedObjectPool<K, V, E extends Exceptio
* @param factor
* erosion factor
*/
public ErodingPerKeyKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool, final float factor) {
ErodingPerKeyKeyedObjectPool(final KeyedObjectPool<K, V, E> keyedPool, final float factor) {
super(keyedPool, null);
this.factor = factor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static <T> IdentityWrapper<T> on(final PooledObject<T> pooledObject) {
*
* @param instance object to wrap.
*/
public IdentityWrapper(final T instance) {
IdentityWrapper(final T instance) {
this.instance = instance;
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@ private ObjectName jmxRegister(final BaseObjectPoolConfig<T> config,
}
while (!registered) {
try {
ObjectName objName;
final ObjectName objName;
// Skip the numeric suffix for the first pool in case there is
// only one so the names are cleaner.
if (i == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/pool3/impl/CallStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ public interface CallStack {
* @param writer a PrintWriter to write the current stack trace to if available
* @return true if a stack trace was available to print or false if nothing was printed
*/
boolean printStackTrace(final PrintWriter writer);
boolean printStackTrace(PrintWriter writer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ public void use() {
usedBy.fillInStackTrace();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static final class ObjectDeque<S> {
* @param fairness true means client threads waiting to borrow / return instances
* will be served as if waiting in a FIFO queue.
*/
public ObjectDeque(final boolean fairness) {
ObjectDeque(final boolean fairness) {
idleObjects = new LinkedBlockingDeque<>(fairness);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class InterruptibleReentrantLock extends ReentrantLock {
* @param fairness true means threads should acquire contended locks as if
* waiting in a FIFO queue
*/
public InterruptibleReentrantLock(final boolean fairness) {
InterruptibleReentrantLock(final boolean fairness) {
super(fairness);
}

Expand All @@ -48,7 +48,7 @@ public InterruptibleReentrantLock(final boolean fairness) {
*
* @param condition the condition on which the threads are waiting.
*/
public void interruptWaiters(final Condition condition) {
void interruptWaiters(final Condition condition) {
getWaitingThreads(condition).forEach(Thread::interrupt);
}
}
Loading

0 comments on commit 3d132b3

Please sign in to comment.