Closed GoogleCodeExporter closed 8 years ago
When injecting beans via spring and in same test, you call CatchException,
there is no problem with classNames. The problems rises when running tests with
and without spring.
Original comment by federico...@gmail.com
on 1 Nov 2013 at 5:34
AFAIK catch-exception is using mockito, right? there is no such problem when
using plain mockito. do you know what exactly is causing the problem? more
details would be helpful. maybe i could create a patch, rise a ticket for
spring team or at least find some workaround
Original comment by Piotr.Tu...@gmail.com
on 1 Nov 2013 at 9:04
As described in:
http://blog.piotrturski.net/2013/06/codegenerationexception-and-proxies.html
The problem is mixing spring + catch-exception.
If i run a spring+junit+catch-exception test, there is no problem at all. But
when i run junit-catch-exception test (catch-exception proxy around class A)
and then spring+junit+catch-exception test (spring proxy around class A) then
the problem rises:
java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader):
attempted duplicate class definition for name: "A$$FastClassByCGLIB$$441a78f3"
Will try to have more details to provide.
Cheers
Original comment by federico...@gmail.com
on 1 Nov 2013 at 9:12
I have dived into darkness to found what the problem was. Here we go:
CatchException is using Cglib through Mockito.
When using standalone Mockito, it uses its own NamingPolicy
(org.mockito.internal.creation.cglib.MockitoNamingPolicy) which tag its proxy
with "ByMockitoWithCGLIB". So every proxy differs from others proxy, like ones
created by SpringAOP (in my case)
CatchException hasn't this "feature" and used default naming policy, so when i
call my catch-exception+junit test it creates a proxy named
A$$FastClassByCGLIB$$8a285887. Just before, when catch-exception+junit+spring
test run, com.googlecode.catchexception.internal.ExceptionProcessingInterceptor
also creates a proxy named A$$FastClassByCGLIB$$8a285887 (cause it used cglib
DefaultNamePolicy). There is where the name clashing happens.
ExceptionProcessingInterceptor {
#intercept() {
...
Object retval = proxy.invoke(target, args);
...
}
}
MethodProxy calls AbstractClassGenerator fromEnhancer =
AbstractClassGenerator.getCurrent(); who return an Enhancer with defaultPolicy
Hope it helps
Original comment by federico...@gmail.com
on 2 Nov 2013 at 12:36
Got it fixed. I'm going to upload a patch for this one.
Original comment by federico...@gmail.com
on 2 Nov 2013 at 1:22
[deleted comment]
Attached patch. All test run correctly (Including
com.googlecode.catchexception.internal.ExceptionProcessingInterceptorTest)
Any problem, just let me know.
Original comment by federico...@gmail.com
on 4 Nov 2013 at 11:48
Attachments:
Federico, thank you for your patch!
The patch is applied. The next release of catch-exception is coming soon.
Piotr, thank you for providing an integration test.
Original comment by rwoo@gmx.de
on 4 Nov 2013 at 7:30
i can confirm that this patch solves all my issues. now, waiting for the
release :)
Original comment by Piotr.Tu...@gmail.com
on 5 Nov 2013 at 12:05
Original comment by rwoo@gmx.de
on 5 Nov 2013 at 6:46
Original comment by rwoo@gmx.de
on 6 Nov 2013 at 1:18
Original issue reported on code.google.com by
Piotr.Tu...@gmail.com
on 16 Sep 2013 at 10:55