public static URI internStringsInUri(URI uri) {
    if (uri == null) return null;
    try {
      String string = (String) stringField.get(uri);
      if (string != null && string != string.intern()) stringField.set(uri, string.intern());
      String scheme = (String) schemeField.get(uri);
      if (scheme != null && scheme != scheme.intern()) schemeField.set(uri, scheme.intern());
      String authority = (String) authorityField.get(uri);
      if (authority != null && authority != authority.intern()) authorityField.set(uri, authority.intern());
      String host = (String) hostField.get(uri);
      if (host != null && host != host.intern()) hostField.set(uri, host.intern());
      String path = (String) pathField.get(uri);
      if (path != null && path != path.intern()) pathField.set(uri, path.intern());
      String fragment = (String) fragmentField.get(uri);
      if (fragment != null && fragment != fragment.intern()) fragmentField.set(uri, fragment.intern());
      String schemeSPart = (String) schemeSpecificPartField.get(uri);
      if (schemeSPart != null && schemeSPart != schemeSPart.intern()) schemeSpecificPartField.set(uri, schemeSPart.intern());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return uri;
  }
This method interns all the URI strings in place.
Goes over the URI strings, checks if each string element is already interned,
and if not it replaces each element with the interned copy.
Eventually returns the same URI.

@param uri
@return
common/src/java/org/apache/hadoop/hive/common/StringInternUtils.java