Buggy code:
public class UpenaService { private final UpenaStore upenaStore ; public UpenaService ( UpenaStore upenaStore ) throws Exception { } public ConnectionDescriptorsResponse connectionRequest ( ConnectionDescriptorsRequest connectionsRequest ) throws Exception { } ConcurrentNavigableMap < InstanceKey , TimestampedValue < Instance > > findInstances ( List < String > messages , ClusterKey clusterKey , ReleaseGroupKey releaseGroupKey , ServiceKey wantToConnectToServiceKey ) throws Exception { } List < ConnectionDescriptor > buildConnextions ( List < String > messages , ConcurrentNavigableMap < InstanceKey , TimestampedValue < Instance > > instances , String portName ) throws Exception { } private ConnectionDescriptorsResponse failedConnectionResponse ( String ... message ) { } public InstanceDescriptorsResponse instanceDescriptors ( InstanceDescriptorsRequest instanceDescriptorsRequest ) throws Exception { HostKey hostKey = new HostKey ( instanceDescriptorsRequest . hostKey ) ; Host host = upenaStore . hosts . get ( hostKey ) ; if ( host == null ) { return new InstanceDescriptorsResponse ( instanceDescriptorsRequest . hostKey , true ) ; } InstanceDescriptorsResponse instanceDescriptorsResponse = new InstanceDescriptorsResponse ( instanceDescriptorsRequest . hostKey , false ) ; InstanceFilter impactedFilter = new InstanceFilter ( null , hostKey , null , null , null , 0 , Integer . MAX_VALUE ) ; ConcurrentNavigableMap < InstanceKey , TimestampedValue < Instance > > got = upenaStore . instances . find ( impactedFilter ) ; for ( Map . Entry < InstanceKey , TimestampedValue < Instance > > e : got . entrySet ( ) ) { Instance instance = e . getValue ( ) . getValue ( ) ; if ( ! ( instance . enabled ) ) { continue ; } ClusterKey clusterKey = instance . clusterKey ; Cluster cluster = upenaStore . clusters . get ( clusterKey ) ; if ( cluster == null ) { upenaStore . instances . remove ( e . getKey ( ) ) ; continue ; } String clusterName = cluster . name ; ServiceKey serviceKey = instance . serviceKey ; Service service = upenaStore . services . get ( serviceKey ) ; if ( service == null ) { upenaStore . instances . remove ( e . getKey ( ) ) ; continue ; } String serviceName = service . name ; ReleaseGroupKey releaseGroupKey = instance . releaseGroupKey ; ReleaseGroup releaseGroup = upenaStore . releaseGroups . get ( releaseGroupKey ) ; if ( releaseGroup == null ) { upenaStore . instances . remove ( e . getKey ( ) ) ; continue ; } String releaseGroupName = releaseGroup . email ; InstanceKey instanceKey = e . getKey ( ) ; <START_BUG> InstanceDescriptor instanceDescriptor = new InstanceDescriptor ( clusterKey . getKey ( ) , clusterName , serviceKey . getKey ( ) , serviceName , releaseGroupKey . getKey ( ) , releaseGroupName , instanceKey . getKey ( ) , instance . instanceId , releaseGroup . version , releaseGroup . repository , ( - 1 ) ) ; <END_BUG> for ( Map . Entry < String , Instance . Port > p : instance . ports . entrySet ( ) ) { instanceDescriptor . ports . put ( p . getKey ( ) , new InstanceDescriptor . InstanceDescriptorPort ( p . getValue ( ) . port ) ) ; } instanceDescriptorsResponse . instanceDescriptors . add ( instanceDescriptor ) ; } return instanceDescriptorsResponse ; } }

Fix:
InstanceDescriptor instanceDescriptor = new InstanceDescriptor ( clusterKey . getKey ( ) , clusterName , serviceKey . getKey ( ) , serviceName , releaseGroupKey . getKey ( ) , releaseGroupName , instanceKey . getKey ( ) , instance . instanceId , releaseGroup . version , releaseGroup . repository , instance . restartTimestampGMTMillis ) ;