{"record":{"id":"6fb093658a18567c","repo":"apache/hadoop","slug":"null-endpoint","errorCode":null,"errorMessage":"Null endpoint","messagePattern":"Null endpoint","errorType":"validation","errorClass":"InvalidRecordException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java","lineNumber":233,"sourceCode":"    String val = address.get(field);\n    if (val == null) {\n      throw new InvalidRecordException(\"\", \"Missing address field: \" + field);\n    }\n    return val;\n  }\n\n  /**\n   * Get the address URLs. Guranteed to return at least one address.\n   * @param epr endpoint\n   * @return the address as a URL\n   * @throws InvalidRecordException if the type is wrong, there are no addresses\n   * or the payload ill-formatted\n   * @throws MalformedURLException address can't be turned into a URL\n   */\n  public static List<URL> retrieveAddressURLs(Endpoint epr)\n      throws InvalidRecordException, MalformedURLException {\n    if (epr == null) {\n      throw new InvalidRecordException(\"\", \"Null endpoint\");\n    }\n    List<String> addresses = retrieveAddressesUriType(epr);\n    List<URL> results = new ArrayList<URL>(addresses.size());\n    for (String address : addresses) {\n      results.add(new URL(address));\n    }\n    return results;\n  }\n\n  /**\n   * Validate the record by checking for null fields and other invalid\n   * conditions\n   * @param path path for exceptions\n   * @param record record to validate. May be null\n   * @throws InvalidRecordException on invalid entries\n   */\n  public static void validateServiceRecord(String path, ServiceRecord record)\n      throws InvalidRecordException {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java#L215-L251","documentation":"RegistryTypeUtils.retrieveAddressURLs converts a URI-typed endpoint's addresses into java.net.URL objects. Unlike retrieveAddressesUriType — which returns null for a null endpoint — this method deliberately rejects null and throws InvalidRecordException ('Null endpoint', with an empty path).","triggerScenarios":"Passing a null Endpoint: taken from an empty external/internal list lookup, record.external.get(i) where the list contains nulls, or code assuming the null-tolerant behavior of retrieveAddressesUriType.","commonSituations":"Iterating ServiceRecord.external/internal without per-element null checks; endpoints cleared after record mutation; chaining accessors without intermediate validation.","solutions":["Null-check the endpoint before calling: if (epr == null) skip or handle the absent case","Filter null endpoints out of record.external/internal lists before processing","Use retrieveAddressesUriType when a null-tolerant read (returns null) fits the control flow better"],"exampleFix":"// before\nList<URL> urls = RegistryTypeUtils.retrieveAddressURLs(firstExternal(record)); // may be null\n\n// after\nEndpoint epr = firstExternal(record);\nif (epr != null && AddressTypes.ADDRESS_URI.equals(epr.addressType)\n    && epr.addresses != null && !epr.addresses.isEmpty()) {\n  List<URL> urls = RegistryTypeUtils.retrieveAddressURLs(epr);\n}","handlingStrategy":"type-guard","validationCode":"if (epr == null) {\n  return Collections.emptyList(); // no endpoint -> no URLs\n}\nreturn RegistryTypeUtils.retrieveAddressURLs(epr);","typeGuard":"static boolean isRetrievableEndpoint(Endpoint epr) {\n  return epr != null\n      && AddressTypes.ADDRESS_URI.equals(epr.addressType)\n      && epr.addresses != null && !epr.addresses.isEmpty();\n}","tryCatchPattern":"try {\n  urls = RegistryTypeUtils.retrieveAddressURLs(epr);\n} catch (InvalidRecordException e) {\n  if (\"Null endpoint\".equals(e.getMessage())) {\n    return Collections.emptyList();\n  }\n  throw e;\n}","preventionTips":["Null-check every element of record.external/internal before passing it to Registry accessors","Remember retrieveAddressURLs rejects null while retrieveAddressesUriType returns null — pick deliberately","Filter null endpoints out of lists right after deserialization"],"tags":["registry","endpoint","null-check","validation"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}