public static JsonNode readMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, ObjectMapper objectMapper, Map<String, String> requestProperties) throws IOException {
        URLConnection urlConnection = url.openConnection();

        if (url.getProtocol().equalsIgnoreCase("file")) {
            urlConnection.connect();
            try (InputStream in = urlConnection.getInputStream()) {
                return objectMapper.readTree(in);
            }
        } else {
            HttpURLConnection uc = (HttpURLConnection) urlConnection;
            uc.setConnectTimeout(connectionTimeoutMs);
            requestProperties.forEach(uc::setRequestProperty);
            uc.setReadTimeout(readTimeoutMs);
            uc.setRequestMethod(HttpMethod.GET.name());
            uc.setDoOutput(true);
            int responseCode = uc.getResponseCode();
            try (InputStream in = uc.getInputStream()) {
                return objectMapper.readTree(in);
            }
        }
    }
public static JsonNode readMetadataUrl ( URL url , int connectionTimeoutMs , int readTimeoutMs , ObjectMapper objectMapper , Map < String , String > requestProperties ) throws IOException { URLConnection urlConnection = url . openConnection ( ) ; if ( url . getProtocol ( ) . equalsIgnoreCase ( "file" ) ) { urlConnection . connect ( ) ; try ( InputStream in = urlConnection . getInputStream ( ) ) { return objectMapper . readTree ( in ) ; } } else { HttpURLConnection uc = ( HttpURLConnection ) urlConnection ; uc . setConnectTimeout ( connectionTimeoutMs ) ; requestProperties . forEach ( uc :: setRequestProperty ) ; uc . setReadTimeout ( readTimeoutMs ) ; uc . setRequestMethod ( HttpMethod . GET . name ( ) ) ; uc . setDoOutput ( true ) ; int responseCode = uc . getResponseCode ( ) ; try ( InputStream in = uc . getInputStream ( ) ) { return objectMapper . readTree ( in ) ; } } }
Reads the result of a URL and parses it using the given {@link ObjectMapper}.

@param url                 the URL to read
@param connectionTimeoutMs connection timeout, in milliseconds
@param readTimeoutMs       read timeout, in milliseconds
@param objectMapper        Jackson's {@link ObjectMapper}
@param requestProperties   any request properties to pass
@return a {@link JsonNode} instance
@throws IOException if any I/O error occurs