lhotari opened a new pull request #14006:
URL: https://github.com/apache/pulsar/pull/14006


   - Fixes #13620
   
   ### Motivation
   
   Workaround for a NPE issue that happens with Mockito/PowerMock:
   ```
   org.mockito.exceptions.base.MockitoException: Unable to create mock instance 
of type 'ServerCnx'
        at 
org.apache.pulsar.broker.BrokerTestUtil.spyWithClassAndConstructorArgs(BrokerTestUtil.java:43)
        at 
        ... 
        ... 
        ... 
   Caused by: java.lang.reflect.InvocationTargetException
        at 
org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:43)
        at 
org.powermock.api.mockito.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:41)
        at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:53)
        at org.mockito.internal.MockitoCore.mock(MockitoCore.java:84)
        at org.mockito.Mockito.mock(Mockito.java:1964)
        at 
org.apache.pulsar.broker.BrokerTestUtil.spyWithClassAndConstructorArgs(BrokerTestUtil.java:43)
        at 
org.apache.pulsar.broker.service.PersistentTopicTest.setup(PersistentTopicTest.java:211)
        at 
org.apache.pulsar.broker.service.persistent.PersistentTopicStreamingDispatcherTest.setup(PersistentTopicStreamingDispatcherTest.java:34)
        at jdk.internal.reflect.GeneratedMethodAccessor332.invoke(Unknown 
Source)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        ... 34 more
   Caused by: java.lang.NullPointerException
        at org.apache.pulsar.broker.service.ServerCnx.<init>(ServerCnx.java:234)
        at org.apache.pulsar.broker.service.ServerCnx.<init>(ServerCnx.java:230)
        at 
org.apache.pulsar.broker.service.ServerCnx$MockitoMock$985617261.<init>(Unknown 
Source)
        ... 55 more
   ```
   
   ### Modification
   
   Add a null check to prevent the NPE.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to