You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/10/14 14:28:53 UTC
svn commit: r1531875 - in /commons/proper/pool/trunk:
findbugs-exclude-filter.xml
src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java
src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java
Author: markt
Date: Mon Oct 14 12:28:52 2013
New Revision: 1531875
URL: http://svn.apache.org/r1531875
Log:
Fix some FindBugs warnings
Modified:
commons/proper/pool/trunk/findbugs-exclude-filter.xml
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java
Modified: commons/proper/pool/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/findbugs-exclude-filter.xml?rev=1531875&r1=1531874&r2=1531875&view=diff
==============================================================================
--- commons/proper/pool/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/pool/trunk/findbugs-exclude-filter.xml Mon Oct 14 12:28:52 2013
@@ -74,4 +74,12 @@
</Or>
<Bug code="DE" />
</Match>
+
+ <!-- TEST CODE -->
+ <Match>
+ <!-- Generating a new object is a deliberate choice -->
+ <Class name="org.apache.commons.pool2.MethodCallPoolableObjectFactory" />
+ <Method name="makeObject" />
+ <Bug pattern="DM_NUMBER_CTOR" />
+ </Match>
</FindBugsFilter>
Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java?rev=1531875&r1=1531874&r2=1531875&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/MethodCallPoolableObjectFactory.java Mon Oct 14 12:28:52 2013
@@ -118,6 +118,7 @@ public class MethodCallPoolableObjectFac
if (makeObjectFail) {
throw new PrivateException("makeObject");
}
+ // Generate new object, don't use cache via Integer.valueOf(...)
final Integer obj = new Integer(count);
call.setReturned(obj);
return new DefaultPooledObject<Object>(obj);
@@ -139,7 +140,7 @@ public class MethodCallPoolableObjectFac
throw new PrivateException("validateObject");
}
final boolean r = valid;
- call.returned(new Boolean(r));
+ call.returned(Boolean.valueOf(r));
return r;
}
Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java?rev=1531875&r1=1531874&r2=1531875&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java Mon Oct 14 12:28:52 2013
@@ -5,9 +5,9 @@
* 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.
@@ -27,16 +27,19 @@ public class TestBaseKeyedPoolableObject
@Test
public void testDefaultMethods() throws Exception {
- KeyedPooledObjectFactory<Object,Object> factory = new BaseKeyedPooledObjectFactory<Object,Object>() {
- @Override
- public Object create(Object key) throws Exception {
- return null;
- }
- };
-
+ KeyedPooledObjectFactory<Object,Object> factory = new TestFactory();
+
factory.activateObject("key",null); // a no-op
factory.passivateObject("key",null); // a no-op
factory.destroyObject("key",null); // a no-op
assertTrue(factory.validateObject("key",null)); // constant true
}
-}
+
+ private static class TestFactory
+ extends BaseKeyedPooledObjectFactory<Object,Object> {
+ @Override
+ public Object create(Object key) throws Exception {
+ return null;
+ }
+ }
+}
\ No newline at end of file