Ignore:
Timestamp:
2017-02-12T16:32:18+01:00 (7 years ago)
Author:
Don-vip
Message:

refactor handling of null values - use Java 8 Optional where possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r11535 r11553  
    1919import java.util.Map;
    2020import java.util.Map.Entry;
     21import java.util.Optional;
    2122import java.util.Scanner;
    2223import java.util.TreeMap;
     
    148149                if (redirectLocation == null) {
    149150                    /* I18n: argument is HTTP response code */
    150                     String msg = tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." +
    151                             " Can''t redirect. Aborting.", connection.getResponseCode());
    152                     throw new IOException(msg);
     151                    throw new IOException(tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." +
     152                            " Can''t redirect. Aborting.", connection.getResponseCode()));
    153153                } else if (maxRedirects > 0) {
    154154                    url = new URL(url, redirectLocation);
     
    284284            } catch (IOException ioe) {
    285285                Main.debug(ioe);
    286                 in = connection.getErrorStream();
    287                 if (in == null) {
    288                     in = new ByteArrayInputStream(new byte[]{});
    289                 }
     286                in = Optional.ofNullable(connection.getErrorStream()).orElseGet(() -> new ByteArrayInputStream(new byte[]{}));
    290287            }
    291288            in = new ProgressInputStream(in, getContentLength(), monitor);
Note: See TracChangeset for help on using the changeset viewer.