Buggy code:
public abstract class AbstractMetadataFactory { protected static final String COLLECTION_SEPARATOR = "," ; protected static final List osgiProperties = Arrays . asList ( new String [ ] { RemoteConstants . ENDPOINT_ID , RemoteConstants . ENDPOINT_SERVICE_ID , Constants . OBJECTCLASS , RemoteConstants . ENDPOINT_FRAMEWORK_UUID , RemoteConstants . SERVICE_IMPORTED_CONFIGS , RemoteConstants . SERVICE_INTENTS , RemoteConstants . SERVICE_IMPORTED } ) ; protected static final List ecfProperties = Arrays . asList ( new String [ ] { RemoteConstants . ENDPOINT_CONTAINER_ID , RemoteConstants . ENDPOINT_CONTAINER_ID_NAMESPACE , RemoteConstants . ENDPOINT_REMOTESERVICE_ID , RemoteConstants . ENDPOINT_CONNECTTARGET_ID , RemoteConstants . ENDPOINT_CONNECTTARGET_ID_NAMESPACE , RemoteConstants . ENDPOINT_IDFILTER_IDS , RemoteConstants . ENDPOINT_IDFILTER_IDARRAY_COUNT , RemoteConstants . ENDPOINT_REMOTESERVICE_FILTER } ) ; protected String [ ] getStringArrayWithDefault ( Map < String , Object > properties , String key , String [ ] def ) { } protected String getStringWithDefault ( Map props , String key , String def ) { } protected Long getLongWithDefault ( Map props , String key , Long def ) { } protected void encodeString ( IServiceProperties props , String name , String value ) { } protected String decodeString ( IServiceProperties props , String name ) { } protected void encodeLong ( IServiceProperties result , String name , Long value ) { } protected Long decodeLong ( IServiceProperties props , String name ) { } protected void encodeList ( IServiceProperties props , String name , List < String > value ) { } protected List decodeList ( IServiceProperties props , String name ) { } protected void encodeIDArray ( IServiceProperties result , ID [ ] idFilter ) { } protected ID [ ] decodeIDArray ( IServiceProperties props ) { } protected ID createID ( String namespace , String name ) throws IDCreateException { } protected ID createID ( Namespace namespace , String name ) throws IDCreateException { } protected IIDFactory getIDFactory ( ) { } protected Namespace getNamespace ( String namespaceName ) { } protected Namespace findNamespace ( String namespaceName ) { } protected Namespace findNamespaceForOSGiId ( String osgiId ) { } protected Namespace findNamespaceByScheme ( String scheme ) { } protected void decodeOSGiProperties ( IServiceProperties props , Map osgiProperties ) { } protected EndpointDescription decodeEndpointDescription ( IServiceProperties discoveredServiceProperties ) { } protected void encodeServiceProperties ( EndpointDescription endpointDescription , IServiceProperties result ) { String endpointId = endpointDescription . getId ( ) ; encodeString ( result , ENDPOINT_ID , endpointId ) ; long endpointServiceId = endpointDescription . getServiceId ( ) ; encodeLong ( result , ENDPOINT_SERVICE_ID , new Long ( endpointServiceId ) ) ; List < String > interfaces = endpointDescription . getInterfaces ( ) ; encodeList ( result , Constants . OBJECTCLASS , interfaces ) ; String frameworkUUID = endpointDescription . getFrameworkUUID ( ) ; if ( frameworkUUID == null ) { frameworkUUID = Activator . getDefault ( ) . getFrameworkUUID ( ) ; } if ( frameworkUUID != null ) encodeString ( result , ENDPOINT_FRAMEWORK_UUID , frameworkUUID ) ; List < String > configurationTypes = endpointDescription . getConfigurationTypes ( ) ; if ( ( configurationTypes . size ( ) ) > 0 ) { encodeList ( result , SERVICE_IMPORTED_CONFIGS , configurationTypes ) ; } List < String > serviceIntents = endpointDescription . getIntents ( ) ; if ( ( serviceIntents . size ( ) ) > 0 ) { encodeList ( result , SERVICE_INTENTS , serviceIntents ) ; } ID endpointID = endpointDescription . getContainerID ( ) ; encodeString ( result , ENDPOINT_CONTAINER_ID , endpointID . toExternalForm ( ) ) ; encodeString ( result , ENDPOINT_CONTAINER_ID_NAMESPACE , endpointID . getNamespace ( ) . getName ( ) ) ; long remoteServiceId = endpointDescription . getRemoteServiceId ( ) ; encodeLong ( result , ENDPOINT_REMOTESERVICE_ID , new Long ( remoteServiceId ) ) ; <START_BUG> ID connectTargetID = endpointDescription . getTargetID ( ) ; <END_BUG> if ( connectTargetID != null ) { encodeString ( result , ENDPOINT_CONNECTTARGET_ID , connectTargetID . toExternalForm ( ) ) ; encodeString ( result , ENDPOINT_CONNECTTARGET_ID_NAMESPACE , connectTargetID . getNamespace ( ) . getName ( ) ) ; } ID [ ] idFilter = endpointDescription . getIDFilter ( ) ; if ( ( idFilter != null ) && ( ( idFilter . length ) > 0 ) ) { encodeIDArray ( result , idFilter ) ; } String remoteFilter = endpointDescription . getRemoteServiceFilter ( ) ; if ( remoteFilter != null ) { encodeString ( result , ENDPOINT_REMOTESERVICE_FILTER , remoteFilter ) ; } encodeNonStandardServiceProperties ( endpointDescription . getProperties ( ) , result ) ; } protected boolean isOSGiProperty ( String key ) { } protected boolean isECFProperty ( String key ) { } protected boolean isStandardProperty ( String key ) { } protected void encodeNonStandardServiceProperties ( Map < String , Object > properties , IServiceProperties result ) { } protected void decodeNonStandardServiceProperties ( IServiceProperties props , Map < String , Object > result ) { } protected void logInfo ( String methodName , String message , Throwable t ) { } protected void logError ( String methodName , String message , Throwable t ) { } public void close ( ) { } }

Fix:
ID connectTargetID = endpointDescription . getConnectTargetID ( ) ;