You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2013/05/16 21:37:41 UTC

[pool] 1.x and TestGenericObjectPoolClassLoaders

In the 1.x branch, the test TestGenericObjectPoolClassLoaders fails for me
at HEAD.

If I do an svn switch to the revision that added the test, 1243737, it
still fails.

Can anyone else reproduce this issue or help?

Thank you,
Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Gary Gregory <ga...@gmail.com>.
Yep, it's a resource problem. I found a simple way to fix it. see revision
1483916.

Thank you for digging in.

Gary


On Fri, May 17, 2013 at 12:18 PM, Bruno P. Kinoshita <
brunodepaulak@yahoo.com.br> wrote:

> Hello,
>
> TL;DR:
> looks like there is an ignored exception that occurs when the test factory
> CustomClassLoaderObjectFactory tries to load a not existing resource.
>
> Test files 'test1' and 'test2' that are not processed by Maven (branch 1.x
> has a not-maven-default directory structure). This way, no new objects are
> created/added to the pool and the test fails.
>
> ---
>
> FWIU, in TestGenericObjectPoolClassLoaders.java the
> testContextClassLoader() test method creates custom class loaders
> (CustomClassLoader) and custom class loader object factories
> (CustomClassLoaderObjectFactory).
>
> These factories are created with a number and the makeObject() method
> returns an URL to a resource "test" + n.
>
> In the test package, there are two files, test1 and test2 that were
> supposed to be used in the test. However, it looks like during test
> execution these files are not included by Maven (probably because the 1.x
> branch has a custom directory structure).
>
> Thus, the CustomClassLoaderObjectFactory#makeObject() method returns null.
> When the GenericObjectPool tries to create a new object (using that
> factory) an exception is raised, but ignored (see GenericObjectPool, line
> 1801). And in the end no new objects are added to the pool and the test
> fails.
>
> I think we could fix it by changing the pom.xml to include these two files
> or by dropping these files and creating some other dummy URL for tests.
> Here's a patch that worked for me [1] (sorry, going to a meeting and
> couldn't attach a decent patch right now).
>
> Just my 0.02 cents, hope that helps.
>
> Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19
> 10:51:28-0300)
> Maven home: /opt/java/apache-maven-3.0.5
> Java version: 1.6.0_43, vendor: Sun Microsystems Inc.
> Java home: /opt/java/jdk1.6.0_43/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "3.8.0-21-generic", arch: "amd64", family:
> "unix"
>
> Cheers, Bruno
>
> [1] https://gist.github.com/kinow/5600147
>
> Bruno P. Kinoshita
> http://kinoshita.eti.br
> http://tupilabs.com
>
>
> --- Em sex, 17/5/13, Mark Thomas <ma...@apache.org> escreveu:
>
> > De: Mark Thomas <ma...@apache.org>
> > Assunto: Re: [pool] 1.x and TestGenericObjectPoolClassLoaders
> > Para: "Commons Developers List" <de...@commons.apache.org>
> > Data: Sexta-feira, 17 de Maio de 2013, 10:03
> > On 17/05/2013 13:51, Gary Gregory
> > wrote:
> > > On Thu, May 16, 2013 at 6:30 PM, Mark Thomas <ma...@apache.org>
> > wrote:
> > >
> > >> On 16/05/2013 20:58, Gary Gregory wrote:
> > >>> TestGenericObjectPoolClassLoaders (1)
> > >>>
> > org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
> > >>>
> > >>
> >
> testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
> > >>> junit.framework.AssertionFailedError: Wrong
> > number of idle objects in
> > >> pool1
> > >>> expected:<1> but was:<0>
> > >>
> > >> <snip/>
> > >>
> > >>>     at
> > >>
> >
> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)
> > >>
> > >> <snip/>
> > >>
> > >> Looking at line 46 of the test, it is possible that
> > it could fail
> > >> depending on the execution timing. Maybe try
> > increasing the Thread.sleep()
> > >> ?
> > >>
> > >
> > > I am glad it works on your end.
> > >
> > > It fails no matter what I change the numbers to, for
> > example:
> >
> > OK. That makes a timing issue unlikely.
> >
> > >
> > >
> >    pool1.setTimeBetweenEvictionRunsMillis(20);
> > >
> >    Thread.sleep(5000);
> > >
> > > or:
> > >
> > >
> >    pool1.setTimeBetweenEvictionRunsMillis(1000);
> > >
> >    Thread.sleep(5000);
> > >
> > > arg :(
> > >
> > > I makes it hard to cut an RC!
> >
> > Indeed.
> >
> > I'd suggest it is time to step through that test case with
> > the debugger
> > in Eclipse and figure out why the object isn't being
> > created.
> >
> > Mark
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br>.
Hello, 

TL;DR: 
looks like there is an ignored exception that occurs when the test factory CustomClassLoaderObjectFactory tries to load a not existing resource. 

Test files 'test1' and 'test2' that are not processed by Maven (branch 1.x has a not-maven-default directory structure). This way, no new objects are created/added to the pool and the test fails.

---

FWIU, in TestGenericObjectPoolClassLoaders.java the testContextClassLoader() test method creates custom class loaders (CustomClassLoader) and custom class loader object factories (CustomClassLoaderObjectFactory).

These factories are created with a number and the makeObject() method returns an URL to a resource "test" + n.

In the test package, there are two files, test1 and test2 that were supposed to be used in the test. However, it looks like during test execution these files are not included by Maven (probably because the 1.x branch has a custom directory structure).

Thus, the CustomClassLoaderObjectFactory#makeObject() method returns null. When the GenericObjectPool tries to create a new object (using that factory) an exception is raised, but ignored (see GenericObjectPool, line 1801). And in the end no new objects are added to the pool and the test fails.

I think we could fix it by changing the pom.xml to include these two files or by dropping these files and creating some other dummy URL for tests. Here's a patch that worked for me [1] (sorry, going to a meeting and couldn't attach a decent patch right now). 

Just my 0.02 cents, hope that helps.

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 10:51:28-0300)
Maven home: /opt/java/apache-maven-3.0.5
Java version: 1.6.0_43, vendor: Sun Microsystems Inc.
Java home: /opt/java/jdk1.6.0_43/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-21-generic", arch: "amd64", family: "unix"

Cheers, Bruno

[1] https://gist.github.com/kinow/5600147

Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


--- Em sex, 17/5/13, Mark Thomas <ma...@apache.org> escreveu:

> De: Mark Thomas <ma...@apache.org>
> Assunto: Re: [pool] 1.x and TestGenericObjectPoolClassLoaders
> Para: "Commons Developers List" <de...@commons.apache.org>
> Data: Sexta-feira, 17 de Maio de 2013, 10:03
> On 17/05/2013 13:51, Gary Gregory
> wrote:
> > On Thu, May 16, 2013 at 6:30 PM, Mark Thomas <ma...@apache.org>
> wrote:
> > 
> >> On 16/05/2013 20:58, Gary Gregory wrote:
> >>> TestGenericObjectPoolClassLoaders (1)
> >>>
> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
> >>>
> >>
> testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
> >>> junit.framework.AssertionFailedError: Wrong
> number of idle objects in
> >> pool1
> >>> expected:<1> but was:<0>
> >>
> >> <snip/>
> >>
> >>>     at
> >>
> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)
> >>
> >> <snip/>
> >>
> >> Looking at line 46 of the test, it is possible that
> it could fail
> >> depending on the execution timing. Maybe try
> increasing the Thread.sleep()
> >> ?
> >>
> > 
> > I am glad it works on your end.
> > 
> > It fails no matter what I change the numbers to, for
> example:
> 
> OK. That makes a timing issue unlikely.
> 
> > 
> >         
>    pool1.setTimeBetweenEvictionRunsMillis(20);
> >         
>    Thread.sleep(5000);
> > 
> > or:
> > 
> >         
>    pool1.setTimeBetweenEvictionRunsMillis(1000);
> >         
>    Thread.sleep(5000);
> > 
> > arg :(
> > 
> > I makes it hard to cut an RC!
> 
> Indeed.
> 
> I'd suggest it is time to step through that test case with
> the debugger
> in Eclipse and figure out why the object isn't being
> created.
> 
> Mark
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Mark Thomas <ma...@apache.org>.
On 17/05/2013 13:51, Gary Gregory wrote:
> On Thu, May 16, 2013 at 6:30 PM, Mark Thomas <ma...@apache.org> wrote:
> 
>> On 16/05/2013 20:58, Gary Gregory wrote:
>>> TestGenericObjectPoolClassLoaders (1)
>>> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
>>>
>> testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
>>> junit.framework.AssertionFailedError: Wrong number of idle objects in
>> pool1
>>> expected:<1> but was:<0>
>>
>> <snip/>
>>
>>>     at
>> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)
>>
>> <snip/>
>>
>> Looking at line 46 of the test, it is possible that it could fail
>> depending on the execution timing. Maybe try increasing the Thread.sleep()
>> ?
>>
> 
> I am glad it works on your end.
> 
> It fails no matter what I change the numbers to, for example:

OK. That makes a timing issue unlikely.

> 
>             pool1.setTimeBetweenEvictionRunsMillis(20);
>             Thread.sleep(5000);
> 
> or:
> 
>             pool1.setTimeBetweenEvictionRunsMillis(1000);
>             Thread.sleep(5000);
> 
> arg :(
> 
> I makes it hard to cut an RC!

Indeed.

I'd suggest it is time to step through that test case with the debugger
in Eclipse and figure out why the object isn't being created.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, May 16, 2013 at 6:30 PM, Mark Thomas <ma...@apache.org> wrote:

> On 16/05/2013 20:58, Gary Gregory wrote:
> > TestGenericObjectPoolClassLoaders (1)
> > org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
> >
> testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
> > junit.framework.AssertionFailedError: Wrong number of idle objects in
> pool1
> > expected:<1> but was:<0>
>
> <snip/>
>
> >     at
> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)
>
> <snip/>
>
> Looking at line 46 of the test, it is possible that it could fail
> depending on the execution timing. Maybe try increasing the Thread.sleep()
> ?
>

I am glad it works on your end.

It fails no matter what I change the numbers to, for example:

            pool1.setTimeBetweenEvictionRunsMillis(20);
            Thread.sleep(5000);

or:

            pool1.setTimeBetweenEvictionRunsMillis(1000);
            Thread.sleep(5000);

arg :(

I makes it hard to cut an RC!

Gary


> > This fails for me from Eclipse and Maven:
> >
> > Maven home: C:\Java\apache-maven-3.0.5\bin\..
> I don't use Maven.
>
> > Java version: 1.7.0_21, vendor: Oracle Corporation
> Same version, 64 bit version.
>
> > Java home: C:\Program Files\Java\jdk1.7.0_21\jre
> Different install location - that shouldn't matter.
>
> > Default locale: en_US, platform encoding: Cp1252
> en_GB, Cp1252
>
> > OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
> Same apart from Windows Server 2008 R2
>
> Pretty similar platforms. Best guess is a timing issue.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Mark Thomas <ma...@apache.org>.
On 16/05/2013 20:58, Gary Gregory wrote:
> TestGenericObjectPoolClassLoaders (1)
> org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
> testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
> junit.framework.AssertionFailedError: Wrong number of idle objects in pool1
> expected:<1> but was:<0>

<snip/>

>     at org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)

<snip/>

Looking at line 46 of the test, it is possible that it could fail
depending on the execution timing. Maybe try increasing the Thread.sleep() ?

> This fails for me from Eclipse and Maven:
> 
> Maven home: C:\Java\apache-maven-3.0.5\bin\..
I don't use Maven.

> Java version: 1.7.0_21, vendor: Oracle Corporation
Same version, 64 bit version.

> Java home: C:\Program Files\Java\jdk1.7.0_21\jre
Different install location - that shouldn't matter.

> Default locale: en_US, platform encoding: Cp1252
en_GB, Cp1252

> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Same apart from Windows Server 2008 R2

Pretty similar platforms. Best guess is a timing issue.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Gary Gregory <ga...@gmail.com>.
TestGenericObjectPoolClassLoaders (1)
org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders
testContextClassLoader(org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders)
junit.framework.AssertionFailedError: Wrong number of idle objects in pool1
expected:<1> but was:<0>
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.Assert.failNotEquals(Assert.java:329)
    at junit.framework.Assert.assertEquals(Assert.java:78)
    at junit.framework.Assert.assertEquals(Assert.java:234)
    at junit.framework.TestCase.assertEquals(TestCase.java:401)
    at
org.apache.commons.pool.impl.TestGenericObjectPoolClassLoaders.testContextClassLoader(TestGenericObjectPoolClassLoaders.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

This fails for me from Eclipse and Maven:

Maven home: C:\Java\apache-maven-3.0.5\bin\..
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_21\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Gary



On Thu, May 16, 2013 at 3:52 PM, Mark Thomas <ma...@apache.org> wrote:

> On 16/05/2013 20:37, Gary Gregory wrote:
> > In the 1.x branch, the test TestGenericObjectPoolClassLoaders fails for
> me
> > at HEAD.
> >
> > If I do an svn switch to the revision that added the test, 1243737, it
> > still fails.
> >
> > Can anyone else reproduce this issue or help?
>
> This works for me when running inside Eclipse.
>
> What does the failure look like?
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [pool] 1.x and TestGenericObjectPoolClassLoaders

Posted by Mark Thomas <ma...@apache.org>.
On 16/05/2013 20:37, Gary Gregory wrote:
> In the 1.x branch, the test TestGenericObjectPoolClassLoaders fails for me
> at HEAD.
> 
> If I do an svn switch to the revision that added the test, 1243737, it
> still fails.
> 
> Can anyone else reproduce this issue or help?

This works for me when running inside Eclipse.

What does the failure look like?

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org