code: public void assignContextToKey(String primaryKey,
                                     String secondaryKey,
                                     int contextId) {
          // Get the mapping from primarykeys to context descriptors.
          List<Assignment> primaryAssignments = assignmentMap.get(primaryKey);
          if (primaryAssignments == null) {
              synchronized (this) {
                  primaryAssignments = assignmentMap.get(primaryKey);
                  if (primaryAssignments == null) {
                      primaryAssignments = Collections.synchronizedList(
                              new ArrayList<Assignment>());
                      assignmentMap.put(primaryKey, primaryAssignments);
                  }
              }
          }
  
          primaryAssignments.add(new Assignment(secondaryKey, contextId));
      }
docs: {@inheritDoc}