Changeset fadc624


Ignore:
Timestamp:
Mar 31, 2015 1:18:11 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
20197fc
Parents:
22c4149
Message:

API: Fix some client-side APIs to honor defaults in Properties;
add javadocs to specify where we do and don't (ticket #1491)

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java

    r22c4149 rfadc624  
    541541     * A more efficient runClientOptions().
    542542     *
     543     * Defaults in opts properties are not recommended, they may or may not be honored.
     544     *
    543545     * @param opts non-null
    544546     * @since 0.9.1
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java

    r22c4149 rfadc624  
    114114     * before being interpreted by this controller)
    115115     *
     116     * Defaults in config properties are not recommended, they may or may not be honored.
     117     *
    116118     * @param config original key=value mapping non-null
    117119     * @param prefix beginning of key values that are relevant to this tunnel
     
    122124
    123125    /**
     126     * Defaults in config properties are not recommended, they may or may not be honored.
    124127     *
    125128     * @param config original key=value mapping non-null
     
    507510    /**
    508511     *  These are the ones stored with a prefix of "option."
     512     *  Defaults in config properties are not honored.
    509513     *
    510514     *  @return keys with the "option." prefix stripped, non-null
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManager.java

    r22c4149 rfadc624  
    7474    /**
    7575     *  Create a modified copy of the current options, to be used in a setDefaultOptions() call.
     76     *
     77     *  As of 0.9.19, defaults in opts are honored.
     78     *
    7679     *  @param opts The new options, may be null
    7780     */
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java

    r22c4149 rfadc624  
    5050     *
    5151     * Blocks for a long time while the router builds tunnels.
     52     * The nonblocking createDisconnectedManager() is preferred.
    5253     *
    5354     * @return the newly created socket manager, or null if there were errors
     
    6263     *
    6364     * Blocks for a long time while the router builds tunnels.
     65     * The nonblocking createDisconnectedManager() is preferred.
    6466     *
    6567     * @param opts Streaming and I2CP options, may be null
     
    7577     *
    7678     * Blocks for a long time while the router builds tunnels.
     79     * The nonblocking createDisconnectedManager() is preferred.
    7780     *
    7881     * @param host I2CP host null to use default, ignored if in router context
     
    8992     *
    9093     * Blocks for a long time while the router builds tunnels.
     94     * The nonblocking createDisconnectedManager() is preferred.
    9195     *
    9296     * @param i2cpHost I2CP host null to use default, ignored if in router context
     
    116120     *
    117121     * Blocks for a long time while the router builds tunnels.
     122     * The nonblocking createDisconnectedManager() is preferred.
    118123     *
    119124     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     
    130135     *
    131136     * Blocks for a long time while the router builds tunnels.
     137     * The nonblocking createDisconnectedManager() is preferred.
    132138     *
    133139     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     
    146152     *
    147153     * Blocks for a long time while the router builds tunnels.
     154     * The nonblocking createDisconnectedManager() is preferred.
    148155     *
    149156     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     
    221228        for (Map.Entry<Object, Object> e : syscopy.entrySet()) {
    222229            String name = (String) e.getKey();
    223             if (!opts.containsKey(name))
     230            if (opts.getProperty(name) != null)
    224231                opts.setProperty(name, (String) e.getValue());
    225232        }
    226233        // as of 0.8.1 (I2CP default is BestEffort)
    227         if (!opts.containsKey(I2PClient.PROP_RELIABILITY))
     234        if (opts.getProperty(I2PClient.PROP_RELIABILITY) == null)
    228235            opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_NONE);
    229236
  • apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionOptions.java

    r22c4149 rfadc624  
    265265     *  Sets max buffer size, connect timeout, read timeout, and write timeout
    266266     *  from properties. Does not set local port or remote port.
     267     *
     268     *  As of 0.9.19, defaults in opts are honored.
     269     *
    267270     *  @param opts may be null
    268271     */
     
    389392    /**
    390393     *  Note: NOT part of the interface
     394     *
     395     *  As of 0.9.19, defaults in opts are honored.
    391396     */
    392397    @Override
     
    394399        super.setProperties(opts);
    395400        if (opts == null) return;
    396         if (opts.containsKey(PROP_MAX_WINDOW_SIZE))
     401        if (opts.getProperty(PROP_MAX_WINDOW_SIZE) != null)
    397402            setMaxWindowSize(getInt(opts, PROP_MAX_WINDOW_SIZE, Connection.MAX_WINDOW_SIZE));
    398         if (opts.containsKey(PROP_CONNECT_DELAY))
     403        if (opts.getProperty(PROP_CONNECT_DELAY) != null)
    399404            setConnectDelay(getInt(opts, PROP_CONNECT_DELAY, -1));
    400         if (opts.containsKey(PROP_PROFILE))
     405        if (opts.getProperty(PROP_PROFILE) != null)
    401406            setProfile(getInt(opts, PROP_PROFILE, PROFILE_BULK));
    402         if (opts.containsKey(PROP_MAX_MESSAGE_SIZE))
     407        if (opts.getProperty(PROP_MAX_MESSAGE_SIZE) != null)
    403408            setMaxMessageSize(getInt(opts, PROP_MAX_MESSAGE_SIZE, Packet.MAX_PAYLOAD_SIZE));
    404         if (opts.containsKey(PROP_INITIAL_RECEIVE_WINDOW))
     409        if (opts.getProperty(PROP_INITIAL_RECEIVE_WINDOW) != null)
    405410            setReceiveWindow(getInt(opts, PROP_INITIAL_RECEIVE_WINDOW, 1));
    406         if (opts.containsKey(PROP_INITIAL_RESEND_DELAY))
     411        if (opts.getProperty(PROP_INITIAL_RESEND_DELAY) != null)
    407412            setResendDelay(getInt(opts, PROP_INITIAL_RESEND_DELAY, 1000));
    408         if (opts.containsKey(PROP_INITIAL_ACK_DELAY))
     413        if (opts.getProperty(PROP_INITIAL_ACK_DELAY) != null)
    409414            setSendAckDelay(getInt(opts, PROP_INITIAL_ACK_DELAY, DEFAULT_INITIAL_ACK_DELAY));
    410         if (opts.containsKey(PROP_INITIAL_WINDOW_SIZE))
     415        if (opts.getProperty(PROP_INITIAL_WINDOW_SIZE) != null)
    411416            setWindowSize(getInt(opts, PROP_INITIAL_WINDOW_SIZE, INITIAL_WINDOW_SIZE));
    412         if (opts.containsKey(PROP_MAX_RESENDS))
     417        if (opts.getProperty(PROP_MAX_RESENDS) != null)
    413418            setMaxResends(getInt(opts, PROP_MAX_RESENDS, DEFAULT_MAX_SENDS));
    414419        // handled in super()
    415         //if (opts.containsKey(PROP_WRITE_TIMEOUT))
     420        //if (opts.getProperty(PROP_WRITE_TIMEOUT))
    416421        //    setWriteTimeout(getInt(opts, PROP_WRITE_TIMEOUT, -1));
    417         if (opts.containsKey(PROP_INACTIVITY_TIMEOUT))
     422        if (opts.getProperty(PROP_INACTIVITY_TIMEOUT) != null)
    418423            setInactivityTimeout(getInt(opts, PROP_INACTIVITY_TIMEOUT, DEFAULT_INACTIVITY_TIMEOUT));
    419         if (opts.containsKey(PROP_INACTIVITY_ACTION))
     424        if (opts.getProperty(PROP_INACTIVITY_ACTION) != null)
    420425            setInactivityAction(getInt(opts, PROP_INACTIVITY_ACTION, DEFAULT_INACTIVITY_ACTION));
    421426        setInboundBufferSize(getMaxMessageSize() * (Connection.MAX_WINDOW_SIZE + 2));
    422         if (opts.contains(PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR))
     427        if (opts.getProperty(PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR) != null)
    423428            setCongestionAvoidanceGrowthRateFactor(getInt(opts, PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR,
    424429                                                          DEFAULT_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR));
    425         if (opts.contains(PROP_SLOW_START_GROWTH_RATE_FACTOR))
     430        if (opts.getProperty(PROP_SLOW_START_GROWTH_RATE_FACTOR) != null)
    426431            setSlowStartGrowthRateFactor(getInt(opts, PROP_SLOW_START_GROWTH_RATE_FACTOR,
    427432                                                DEFAULT_SLOW_START_GROWTH_RATE_FACTOR));
    428         if (opts.containsKey(PROP_CONNECT_TIMEOUT))
     433        if (opts.getProperty(PROP_CONNECT_TIMEOUT) != null)
    429434            // overrides default in super()
    430435            setConnectTimeout(getInt(opts, PROP_CONNECT_TIMEOUT, Connection.DEFAULT_CONNECT_TIMEOUT));
    431         if (opts.containsKey(PROP_ANSWER_PINGS))
     436        if (opts.getProperty(PROP_ANSWER_PINGS) != null)
    432437            setAnswerPings(getBool(opts, PROP_ANSWER_PINGS, DEFAULT_ANSWER_PINGS));
    433         if (opts.containsKey(PROP_ENFORCE_PROTO))
     438        if (opts.getProperty(PROP_ENFORCE_PROTO) != null)
    434439            setEnforceProtocol(getBool(opts, PROP_ENFORCE_PROTO, DEFAULT_ENFORCE_PROTO));
    435         if (opts.containsKey(PROP_DISABLE_REJ_LOG))
     440        if (opts.getProperty(PROP_DISABLE_REJ_LOG) != null)
    436441            setDisableRejectLogging(getBool(opts, PROP_DISABLE_REJ_LOG, false));
    437442        initLists(opts);
    438         if (opts.containsKey(PROP_MAX_CONNS_MIN))
     443        if (opts.getProperty(PROP_MAX_CONNS_MIN) != null)
    439444            _maxConnsPerMinute = getInt(opts, PROP_MAX_CONNS_MIN, 0);
    440         if (opts.containsKey(PROP_MAX_CONNS_HOUR))
     445        if (opts.getProperty(PROP_MAX_CONNS_HOUR) != null)
    441446            _maxConnsPerHour = getInt(opts, PROP_MAX_CONNS_HOUR, 0);
    442         if (opts.containsKey(PROP_MAX_CONNS_DAY))
     447        if (opts.getProperty(PROP_MAX_CONNS_DAY) != null)
    443448            _maxConnsPerDay = getInt(opts, PROP_MAX_CONNS_DAY, 0);
    444         if (opts.containsKey(PROP_MAX_TOTAL_CONNS_MIN))
     449        if (opts.getProperty(PROP_MAX_TOTAL_CONNS_MIN) != null)
    445450            _maxTotalConnsPerMinute = getInt(opts, PROP_MAX_TOTAL_CONNS_MIN, 0);
    446         if (opts.containsKey(PROP_MAX_TOTAL_CONNS_HOUR))
     451        if (opts.getProperty(PROP_MAX_TOTAL_CONNS_HOUR) != null)
    447452            _maxTotalConnsPerHour = getInt(opts, PROP_MAX_TOTAL_CONNS_HOUR, 0);
    448         if (opts.containsKey(PROP_MAX_TOTAL_CONNS_DAY))
     453        if (opts.getProperty(PROP_MAX_TOTAL_CONNS_DAY) != null)
    449454            _maxTotalConnsPerDay = getInt(opts, PROP_MAX_TOTAL_CONNS_DAY, 0);
    450         if (opts.containsKey(PROP_MAX_STREAMS))
     455        if (opts.getProperty(PROP_MAX_STREAMS) != null)
    451456            _maxConns = getInt(opts, PROP_MAX_STREAMS, 0);
    452457       
  • apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java

    r22c4149 rfadc624  
    103103    /**
    104104     *  Create a modified copy of the current options, to be used in a setDefaultOptions() call.
     105     *
     106     *  As of 0.9.19, defaults in opts are honored.
     107     *
    105108     *  @param opts The new options, may be null
    106109     */
     
    217220     *  with the setters; no need to use this method for those.
    218221     *  This does NOT update the underlying I2CP or tunnel options; use getSession().updateOptions() for that.
     222     *
    219223     *  @param options as created from a call to buildOptions(properties), non-null
    220224     */
  • apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketOptionsImpl.java

    r22c4149 rfadc624  
    4848     *  Sets max buffer size, connect timeout, read timeout, and write timeout
    4949     *  from properties. Does not set local port or remote port.
     50     *
     51     *  As of 0.9.19, defaults in opts are honored.
     52     *
    5053     *  @param opts may be null
    5154     */
     
    5760     *  Sets max buffer size, connect timeout, read timeout, and write timeout
    5861     *  from properties. Does not set local port or remote port.
     62     *
     63     *  As of 0.9.19, defaults in opts are honored.
     64     *
    5965     *  @param opts may be null
    6066     */
    6167    public void setProperties(Properties opts) {
    6268        if (opts == null) return;
    63         if (opts.containsKey(PROP_BUFFER_SIZE))
     69        if (opts.getProperty(PROP_BUFFER_SIZE) != null)
    6470            _maxBufferSize = getInt(opts, PROP_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
    65         if (opts.containsKey(PROP_CONNECT_TIMEOUT))
     71        if (opts.getProperty(PROP_CONNECT_TIMEOUT) != null)
    6672            _connectTimeout = getInt(opts, PROP_CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT);
    67         if (opts.containsKey(PROP_READ_TIMEOUT))
     73        if (opts.getProperty(PROP_READ_TIMEOUT) != null)
    6874            _readTimeout = getInt(opts, PROP_READ_TIMEOUT, -1);
    69         if (opts.containsKey(PROP_WRITE_TIMEOUT))
     75        if (opts.getProperty(PROP_WRITE_TIMEOUT) != null)
    7076            _writeTimeout = getInt(opts, PROP_WRITE_TIMEOUT, DEFAULT_WRITE_TIMEOUT);
    7177    }
     
    96102    }
    97103   
     104    /**
     105     *  Not part of the API, not for external use.
     106     */
    98107    public static double getDouble(Properties opts, String name, double defaultVal) {
    99108        if (opts == null) return defaultVal;
  • core/java/src/net/i2p/client/I2PClient.java

    r22c4149 rfadc624  
    7373     * encryption.
    7474     *
     75     * As of 0.9.19, defaults in options are honored.
     76     *
    7577     * @param destKeyStream location from which to read the Destination, PrivateKey, and SigningPrivateKey from,
    7678     *                      format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    r22c4149 rfadc624  
    236236     * from the destKeyStream, and using the specified options to connect to the router
    237237     *
     238     * As of 0.9.19, defaults in options are honored.
     239     *
    238240     * @param destKeyStream stream containing the private key data,
    239241     *                             format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     
    315317    }
    316318
    317     /** save some memory, don't pass along the pointless properties */
     319    /**
     320     *  Save some memory, don't pass along the pointless properties.
     321     *  As of 0.9.19, defaults from options will be promoted to real values in rv.
     322     *  @return a new Properties without defaults
     323     */
    318324    private Properties filter(Properties options) {
    319325        Properties rv = new Properties();
    320         for (Object oKey : options.keySet()) { // TODO-Java6: s/keySet()/stringPropertyNames()/
    321             String key = (String) oKey;
     326        for (String key : options.stringPropertyNames()) {
    322327            if (key.startsWith("java.") ||
    323328                key.startsWith("user.") ||
     
    788793
    789794    /**
    790      * Retrieve the configuration options
     795     * Retrieve the configuration options, filtered.
     796     * All defaults passed in via constructor have been promoted to the primary map.
     797     *
    791798     * @return non-null, if insantiated with null options, this will be the System properties.
    792799     */
  • core/java/src/net/i2p/data/DataHelper.java

    r22c4149 rfadc624  
    173173     * Keys and values must be 255 bytes or less,
    174174     * Formatted length must not exceed 65535 bytes
    175      * @throws DataFormatException if either is too long.
     175     *
     176     * Properties from the defaults table of props (if any) are not written out by this method.
    176177     *
    177178     * @param rawStream stream to write to
    178179     * @param props properties to write out
    179      * @throws DataFormatException if there is not enough valid data to write out
     180     * @throws DataFormatException if there is not enough valid data to write out,
     181     *                             or a length limit is exceeded
    180182     * @throws IOException if there is an IO error writing out the data
    181183     */
     
    191193     * Keys and values must be 255 bytes or less,
    192194     * Formatted length must not exceed 65535 bytes
    193      * @throws DataFormatException if either is too long.
     195     *
     196     * Properties from the defaults table of props (if any) are not written out by this method.
    194197     *
    195198     * jrandom disabled UTF-8 in mid-2004, for performance reasons,
     
    200203     * Use utf8 = true for SessionConfig (slow, UTF-8)
    201204     * @param props source may be null
     205     * @throws DataFormatException if a length limit is exceeded
    202206     */
    203207    public static void writeProperties(OutputStream rawStream, Properties props, boolean utf8)
     
    213217     * Keys and values must be 255 bytes or less,
    214218     * Formatted length must not exceed 65535 bytes
     219     *
     220     * Properties from the defaults table of props (if any) are not written out by this method.
    215221     *
    216222     * jrandom disabled UTF-8 in mid-2004, for performance reasons,
     
    269275     * Strings will be UTF-8 encoded in the byte array.
    270276     * Warning - confusing method name, Properties is the source.
     277     *
     278     * Properties from the defaults table of props (if any) are not written out by this method.
    271279     *
    272280     * @deprecated unused
     
    365373     * Warning - confusing method name, Properties is the source.
    366374     *
     375     * Properties from the defaults table of props (if any) are not written out by this method.
     376     *
    367377     * @throws DataFormatException if key, value, or total is too long
    368378     */
     
    477487     * Note that this does not escape the \r or \n that are unescaped in loadProps() above.
    478488     * As of 0.8.1, file will be mode 600.
     489     *
     490     * Properties from the defaults table of props (if any) are not written out by this method.
    479491     *
    480492     * Leading or trailing whitespace in values is not checked but
  • core/java/src/net/i2p/data/i2cp/GetDateMessage.java

    r22c4149 rfadc624  
    4646
    4747    /**
     48     *  Defaults in GetDateMessage options are, in general, NOT honored.
     49     *  Defaults are not serialized out-of-JVM, and the router does not recognize defaults in-JVM.
     50     *  Client side must promote defaults to the primary map.
     51     *
    4852     *  @param version the client's version String to be sent to the router; may be null;
    4953     *                 must be non-null if options is non-null and non-empty.
  • core/java/src/net/i2p/data/i2cp/SessionConfig.java

    r22c4149 rfadc624  
    9191     * Configure the session with the given options;
    9292     * keys and values 255 bytes (not chars) max each
     93     *
     94     * Defaults in SessionConfig options are, in general, NOT honored.
     95     * Defaults are not serialized out-of-JVM, and the router does not recognize defaults in-JVM.
     96     * Client side must promote defaults to the primary map.
    9397     *
    9498     * @param options Properties for this session
  • router/java/src/net/i2p/router/TunnelPoolSettings.java

    r22c4149 rfadc624  
    238238   
    239239    /**
     240     *  Defaults in props are NOT honored.
     241     *  In-JVM client side must promote defaults to the primary map.
     242     *
    240243     *  @param prefix non-null
    241244     */
    242     public void readFromProperties(String prefix, Map<Object, Object> props) {
     245    public void readFromProperties(String prefix, Properties props) {
    243246        for (Map.Entry<Object, Object> e : props.entrySet()) {
    244247            String name = (String) e.getKey();
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    r22c4149 rfadc624  
    162162    }
    163163   
     164    /**
     165     *  Defaults in GetDateMessage options are NOT honored.
     166     *  Defaults are not serialized out-of-JVM, and the router does not recognize defaults in-JVM.
     167     *  Client side must promote defaults to the primary map.
     168     */
    164169    private void handleGetDate(GetDateMessage message) {
    165170        // sent by clients >= 0.8.7
     
    193198     * DisconnectMessage in return, and not wait around for our DisconnectMessage.
    194199     * So keep it simple.
     200     *
     201     * Defaults in SessionConfig options are, in general, NOT honored.
     202     * In-JVM client side must promote defaults to the primary map.
    195203     */
    196204    private void handleCreateSession(CreateSessionMessage message) {
     
    460468     * Note that this does NOT update the few options handled in
    461469     * ClientConnectionRunner.sessionEstablished(). Those can't be changed later.
     470     *
     471     * Defaults in SessionConfig options are, in general, NOT honored.
     472     * In-JVM client side must promote defaults to the primary map.
    462473     */
    463474    private void handleReconfigureSession(ReconfigureSessionMessage message) {
Note: See TracChangeset for help on using the changeset viewer.