mloayzagahona / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

MockGateway not Thread Safe #525

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In our test we replaced the (non-static) method "logAccess" with our mocked 
version via

PowerMockito.replace(PowerMockito.method(DomainObject.class, "logAccess", 
String.class, Object.class)).with(new InvocationHandler() {...})

We constructed a multithreaded test for our class DomainObject.

Now most of the time we get an NullPointer Exception:

Exception in thread "#15" java.lang.NullPointerException
      at org.powermock.core.MockGateway.doMethodCall(MockGateway.java:118)
      at org.powermock.core.MockGateway.methodCall(MockGateway.java:60)
      at com.novomind.util.database.DomainObject.executeQuery(DomainObject.java)

I think the temporary removal of the method proxy is a problem for this use 
case:

https://github.com/jayway/powermock/blame/master/core/src/main/java/org/powermoc
k/core/MockGateway.java#L129-L141

Original issue reported on code.google.com by kguel...@gmail.com on 5 Nov 2014 at 8:34