Author: richard.opalka(a)jboss.com
Date: 2009-02-06 16:17:16 -0500 (Fri, 06 Feb 2009)
New Revision: 9255
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
Log:
[JBWS-2519] prevent NPE
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2009-02-06
20:42:11 UTC (rev 9254)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2009-02-06
21:17:16 UTC (rev 9255)
@@ -212,10 +212,15 @@
public Object run() throws Exception
{
Field delegateField = findServiceDelegateField(service.getClass());
- delegateField.setAccessible(true);
- ServiceDelegate delegate =
(ServiceDelegate)delegateField.get(service);
- delegateField.set(service, new
ServiceRefStubPropertyServiceDelegate(delegate, serviceRef));
- return delegate;
+ if (delegateField != null)
+ {
+ delegateField.setAccessible(true);
+ ServiceDelegate delegate =
(ServiceDelegate)delegateField.get(service);
+ delegateField.set(service, new
ServiceRefStubPropertyServiceDelegate(delegate, serviceRef));
+ return delegate;
+ } else {
+ return null;
+ }
}
});
}
@@ -225,10 +230,15 @@
}
}
Field delegateField = findServiceDelegateField(service.getClass());
- delegateField.setAccessible(true);
- ServiceDelegate delegate = (ServiceDelegate)delegateField.get(service);
- delegateField.set(service, new ServiceRefStubPropertyServiceDelegate(delegate,
serviceRef));
- return delegate;
+ if (delegateField != null)
+ {
+ delegateField.setAccessible(true);
+ ServiceDelegate delegate = (ServiceDelegate)delegateField.get(service);
+ delegateField.set(service, new ServiceRefStubPropertyServiceDelegate(delegate,
serviceRef));
+ return delegate;
+ } else {
+ return null;
+ }
}
private Bus getBus(final Service service) throws Throwable
@@ -243,9 +253,13 @@
public Bus run() throws Exception
{
Field delegateField = findServiceDelegateField(service.getClass());
- delegateField.setAccessible(true);
- ServiceImpl serviceImpl = (ServiceImpl)delegateField.get(service);
- return serviceImpl.getBus();
+ if (delegateField != null)
+ {
+ delegateField.setAccessible(true);
+ ServiceImpl serviceImpl = (ServiceImpl)delegateField.get(service);
+ return serviceImpl.getBus();
+ }
+ throw new IllegalStateException("Bus not found");
}
});
}
@@ -255,9 +269,13 @@
}
}
Field delegateField = findServiceDelegateField(service.getClass());
- delegateField.setAccessible(true);
- ServiceImpl serviceImpl = (ServiceImpl)delegateField.get(service);
- return serviceImpl.getBus();
+ if (delegateField != null)
+ {
+ delegateField.setAccessible(true);
+ ServiceImpl serviceImpl = (ServiceImpl)delegateField.get(service);
+ return serviceImpl.getBus();
+ }
+ throw new IllegalStateException("Bus not found");
}
private static Field findServiceDelegateField(Class<?> clazz)
Show replies by date