public void merge(Map<?, ?> properties, Source source) {
    if (properties == null || properties.isEmpty()) {
      return;
    }
    // merge the properties
    for (Map.Entry<?, ?> entry : properties.entrySet()) {
      String key = entry.getKey().toString().trim();
      String value = entry.getValue() == null ? null : entry.getValue().toString().trim();
      PropertyKey propertyKey;
      if (PropertyKey.isValid(key)) {
        propertyKey = PropertyKey.fromString(key);
      } else {
        // Add unrecognized properties
        LOG.debug("Property {} from source {} is unrecognized", key, source);
        // Workaround for issue https://alluxio.atlassian.net/browse/ALLUXIO-3108
        // This will register the key as a valid PropertyKey
        // TODO(adit): Do not add properties unrecognized by Ufs extensions when Configuration
        // is made dynamic
        propertyKey = PropertyKey.getOrBuildCustom(key);
      }
      put(propertyKey, propertyKey.parseValue(value), source);
    }
    mHash.markOutdated();
  }
@Test
  public void merge() {
    PropertyKey newKey = stringBuilder("mergeNew").setDefaultValue("value3").build();
    Properties sysProp = new Properties();
    sysProp.put(mKeyWithValue, "value1");
    sysProp.put(mKeyWithoutValue, "value2");
    mProperties.merge(sysProp, Source.SYSTEM_PROPERTY);
    assertEquals(Source.SYSTEM_PROPERTY, mProperties.getSource(mKeyWithValue));
    assertEquals(Source.SYSTEM_PROPERTY, mProperties.getSource(mKeyWithoutValue));
    assertEquals(Source.DEFAULT, mProperties.getSource(newKey));
    assertEquals("value1", mProperties.get(mKeyWithValue));
    assertEquals("value2", mProperties.get(mKeyWithoutValue));
    assertEquals("value3", mProperties.get(newKey));
  }