fix unsafe initialization of super constructor calling override

This commit is contained in:
zzz
2012-06-29 17:21:57 +00:00
parent ab18550711
commit 63f22a54e1

View File

@@ -108,9 +108,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
*/ */
private static final boolean DEFAULT_ENFORCE_PROTO = false; private static final boolean DEFAULT_ENFORCE_PROTO = false;
// Syncronization fix, but doing it this way causes NPE... private final int _trend[] = new int[TREND_COUNT];
// FIXME private final int _trend[] = new int[TREND_COUNT]; FIXME
private int _trend[];
/** /**
* OK, here is the calculation on the message size to fit in a single * OK, here is the calculation on the message size to fit in a single
@@ -224,6 +222,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
*/ */
public ConnectionOptions() { public ConnectionOptions() {
super(); super();
cinit(System.getProperties());
} }
/** /**
@@ -233,6 +232,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
*/ */
public ConnectionOptions(Properties opts) { public ConnectionOptions(Properties opts) {
super(opts); super(opts);
cinit(opts);
} }
/** /**
@@ -241,6 +241,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
*/ */
public ConnectionOptions(I2PSocketOptions opts) { public ConnectionOptions(I2PSocketOptions opts) {
super(opts); super(opts);
cinit(System.getProperties());
} }
/** /**
@@ -249,6 +250,7 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
*/ */
public ConnectionOptions(ConnectionOptions opts) { public ConnectionOptions(ConnectionOptions opts) {
super(opts); super(opts);
cinit(System.getProperties());
if (opts != null) if (opts != null)
update(opts); update(opts);
} }
@@ -306,11 +308,10 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
_maxTotalConnsPerDay = opts.getMaxTotalConnsPerDay(); _maxTotalConnsPerDay = opts.getMaxTotalConnsPerDay();
} }
/** called by super's constructor */ /**
@Override * Initialization
protected void init(Properties opts) { */
super.init(opts); private void cinit(Properties opts) {
_trend = new int[TREND_COUNT];
setMaxWindowSize(getInt(opts, PROP_MAX_WINDOW_SIZE, Connection.MAX_WINDOW_SIZE)); setMaxWindowSize(getInt(opts, PROP_MAX_WINDOW_SIZE, Connection.MAX_WINDOW_SIZE));
setConnectDelay(getInt(opts, PROP_CONNECT_DELAY, -1)); setConnectDelay(getInt(opts, PROP_CONNECT_DELAY, -1));
setProfile(getInt(opts, PROP_PROFILE, PROFILE_BULK)); setProfile(getInt(opts, PROP_PROFILE, PROFILE_BULK));