Skip to content

Commit

Permalink
Issue #7760 was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Sep 20, 2017
1 parent 1e30411 commit a7d1daa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ public void shutdown() throws Exception {

@Override
public String toString() {
return getClass().getSimpleName();
//it is strange but windows defender block compilation if we get class name programmatically using Class instance
return "OShutdownPendingThreadsHandler";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,15 @@ public void change(final Object iCurrentValue, final Object iNewValue) {
@Deprecated CACHE_LOCAL_ENABLED("cache.local.enabled", "Deprecated, Level1 cache cannot be disabled anymore", Boolean.class,
true);

/**
* Place holder for the "undefined" value of setting.
*/
private final Object nullValue = new Object();

private final String key;
private final Object defValue;
private final Class<?> type;
private volatile Object value = null;
private volatile Object value = nullValue;
private final String description;
private final OConfigurationChangeCallback changeCallback;
private final Boolean canChangeAtRuntime;
Expand Down Expand Up @@ -1083,7 +1088,14 @@ private static void readConfiguration() {

public <T> T getValue() {
//noinspection unchecked
return (T) (value != null ? value : defValue);
return (T) (value != nullValue && value != null ? value : defValue);
}

/**
* @return <code>true</code> if configuration was changed from default value and <code>false</code> otherwise.
*/
public boolean isChanged() {
return value != nullValue;
}

/**
Expand Down Expand Up @@ -1148,34 +1160,34 @@ else if (type.isEnum()) {

if (changeCallback != null) {
try {
changeCallback.change(oldValue, value);
changeCallback.change(oldValue == nullValue ? null : oldValue, value == nullValue ? null : value);
} catch (Exception e) {
e.printStackTrace();
}
}
}

public boolean getValueAsBoolean() {
final Object v = value != null ? value : defValue;
final Object v = value != nullValue && value != null ? value : defValue;
return v instanceof Boolean ? (Boolean) v : Boolean.parseBoolean(v.toString());
}

public String getValueAsString() {
return value != null ? value.toString() : defValue != null ? defValue.toString() : null;
return value != nullValue && value != null ? value.toString() : defValue != null ? defValue.toString() : null;
}

public int getValueAsInteger() {
final Object v = value != null ? value : defValue;
final Object v = value != nullValue && value != null ? value : defValue;
return (int) (v instanceof Number ? ((Number) v).intValue() : OFileUtils.getSizeAsNumber(v.toString()));
}

public long getValueAsLong() {
final Object v = value != null ? value : defValue;
final Object v = value != nullValue && value != null ? value : defValue;
return v instanceof Number ? ((Number) v).longValue() : OFileUtils.getSizeAsNumber(v.toString());
}

public float getValueAsFloat() {
final Object v = value != null ? value : defValue;
final Object v = value != nullValue && value != null ? value : defValue;
return v instanceof Float ? (Float) v : Float.parseFloat(v.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public void initialize() {
}

private void configureDefaults() {
if (System.getProperty(OGlobalConfiguration.DISK_CACHE_SIZE.getKey()) == null)
if (!OGlobalConfiguration.DISK_CACHE_SIZE.isChanged())
configureDefaultDiskCacheSize();

if (System.getProperty(OGlobalConfiguration.WAL_RESTORE_BATCH_SIZE.getKey()) == null)
if (!OGlobalConfiguration.WAL_RESTORE_BATCH_SIZE.isChanged())
configureDefaultWalRestoreBatchSize();
}

Expand Down

0 comments on commit a7d1daa

Please sign in to comment.