I'm not sure if anybody else has run across this error but it pops up frequently for me. I run the MetricsSource and sometimes it randomly throws a NPE, other times, it doesn't. When it does, a relaunch of the MetricsSource usually fixes the issue. Here is the operator trace I get:
01 Jun 2017 13:57:34.480 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[MetricsSource.java:com.ibm.streamsx.metrics.MetricsSource$1.run:398] - Operator error
01 Jun 2017 13:57:34.482 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - java.lang.NullPointerException
01 Jun 2017 13:57:34.482 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.ibm.streams.instance.srm.client.BaseMetrics.getTimestamp(BaseMetrics.java:340)
01 Jun 2017 13:57:34.482 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.ibm.streams.instance.srm.client.BaseMetrics.<init>(BaseMetrics.java:192)
01 Jun 2017 13:57:34.482 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.ibm.streams.instance.srm.client.PEMetrics.<init>(PEMetrics.java:64)
01 Jun 2017 13:57:34.482 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.ibm.streams.instance.srm.client.SrmClient.getPEMetrics(SrmClient.java:292)
01 Jun 2017 13:57:34.483 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.ibm.streams.management.internal.PeBean.retrieveMetrics(PeBean.java:952)
01 Jun 2017 13:57:34.483 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
01 Jun 2017 13:57:34.483 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
01 Jun 2017 13:57:34.483 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at java.lang.reflect.Method.invoke(Method.java:508)
01 Jun 2017 13:57:34.483 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:83)
01 Jun 2017 13:57:34.484 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
01 Jun 2017 13:57:34.484 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
01 Jun 2017 13:57:34.484 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at java.lang.reflect.Method.invoke(Method.java:508)
01 Jun 2017 13:57:34.484 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:287)
01 Jun 2017 13:57:34.484 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:205)
01 Jun 2017 13:57:34.485 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:187)
01 Jun 2017 13:57:34.485 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:129)
01 Jun 2017 13:57:34.485 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:66)
01 Jun 2017 13:57:34.485 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:249)
01 Jun 2017 13:57:34.485 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:150)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:264)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:831)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:813)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at javax.management.remote.generic.ServerIntermediary.handleRequest(ServerIntermediary.java:280)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at javax.management.remote.generic.ServerIntermediary$PrivilegedRequestJob.run(ServerIntermediary.java:951)
01 Jun 2017 13:57:34.486 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at java.security.AccessController.doPrivileged(AccessController.java:686)
01 Jun 2017 13:57:34.487 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at javax.management.remote.generic.ServerIntermediary$RequestHandler.handleMBSReqMessage(ServerIntermediary.java:727)
01 Jun 2017 13:57:34.487 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at javax.management.remote.generic.ServerIntermediary$RequestHandler.execute(ServerIntermediary.java:629)
01 Jun 2017 13:57:34.487 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.remote.generic.ServerSynchroMessageConnectionImpl$RemoteJob.run(ServerSynchroMessageConnectionImpl.java:266)
01 Jun 2017 13:57:34.487 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.remote.opt.util.ThreadService$ThreadServiceJob.run(ThreadService.java:208)
01 Jun 2017 13:57:34.487 [24022] ERROR #splapptrc,J[39],P[40],MetricsSource_1 M[?:?:0] - at com.sun.jmx.remote.opt.util.JobExecutor.run(JobExecutor.java:59)
I've been try-catching the retrieveMetrics() function call in MetricOwningHandler.captureAndSubmitMetrics() and that seems to have fixed the problem.
Maybe the MetricsSource tries to retrieve the PeMXBean for jobs too soon after they're launched (have not come across this error for any other MXBean).