Skip to content

Commit d76f958

Browse files
committed
Bug 37989670 - [37984001->25.03.2] RFA: Silently ignoring setting system property com.oracle.coherence.common.internal.net.socketbus.*Millis (ce-main->ce-25.03)
Remote remote.full on coherence-ce/release/coherence-ce-v25.03 success, changes 116563, synced @116564, job.9.20250524025127.1827 [git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v25.03/": change = 116565]
1 parent c97fe39 commit d76f958

File tree

4 files changed

+154
-19
lines changed

4 files changed

+154
-19
lines changed

prj/coherence-core/src/main/java/com/oracle/coherence/common/internal/io/SegmentedBufferManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,8 @@ public interface BufferAllocator
11721172
* would cause them to reevaluate on their own.
11731173
*/
11741174
protected static final long CLEANUP_FREQUENCY_MILLIS = Config.getDuration(SegmentedBufferManager.class.getName() + ".cleanup.frequency",
1175-
new Duration(1, Duration.Magnitude.SECOND)).as(Duration.Magnitude.MILLI);
1175+
new Duration(1, Duration.Magnitude.SECOND),
1176+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
11761177

11771178
/**
11781179
* The logger.

prj/coherence-core/src/main/java/com/oracle/coherence/common/internal/net/socketbus/SocketBusDriver.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -941,7 +941,8 @@ protected DefaultDependencies validate()
941941
}
942942

943943
m_cAckTimeoutMillis = Config.getDuration(SocketBusDriver.class.getName() + ".ackTimeoutMillis",
944-
new Duration(getDefaultAckTimeoutMillis(), Duration.Magnitude.MILLI)).as(Duration.Magnitude.MILLI);
944+
new Duration(getDefaultAckTimeoutMillis(), Duration.Magnitude.MILLI),
945+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
945946

946947
return this;
947948
}
@@ -1010,7 +1011,8 @@ protected static void ensureArgument(Object o, String sName)
10101011
*/
10111012
protected long m_cReconnectDelayMillis =
10121013
Config.getDuration(SocketBusDriver.class.getName() + ".reconnectDelayMillis",
1013-
new Duration(200, Duration.Magnitude.MILLI)).as(Duration.Magnitude.MILLI);
1014+
new Duration(200, Duration.Magnitude.MILLI),
1015+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
10141016

10151017
/**
10161018
* The maximum number of sequential reconnects to attempt.
@@ -1023,7 +1025,8 @@ protected static void ensureArgument(Object o, String sName)
10231025
* Maximum receipt ack delay in millis
10241026
*/
10251027
protected long m_cMaxReceiptDelayMillis = Config.getDuration(SocketBusDriver.class.getName()+".maxReceiptDelayMillis",
1026-
new Duration(500, Duration.Magnitude.MILLI)).as(Duration.Magnitude.MILLI);
1028+
new Duration(500, Duration.Magnitude.MILLI),
1029+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
10271030

10281031
/**
10291032
* Ack timeout in millis
@@ -1040,7 +1043,8 @@ protected static void ensureArgument(Object o, String sName)
10401043
* Fatal ack timeout in millis
10411044
*/
10421045
protected long m_cAckFatalTimeoutMillis = Config.getDuration(SocketBusDriver.class.getName()+".fatalTimeoutMillis",
1043-
new Duration(10, Duration.Magnitude.MINUTE)).as(Duration.Magnitude.MILLI);
1046+
new Duration(10, Duration.Magnitude.MINUTE),
1047+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
10441048

10451049
/**
10461050
* Heartbeat interval in millis, disabled by default now that we support reconnects

prj/coherence-core/src/main/java/com/tangosol/coherence/config/Config.java

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -146,6 +146,7 @@ public static Integer getInteger(String sName)
146146
}
147147
catch (RuntimeException e)
148148
{
149+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to invalid value " + e.getMessage());
149150
return null;
150151
}
151152
}
@@ -187,6 +188,7 @@ public static Long getLong(String sName)
187188
}
188189
catch (RuntimeException e)
189190
{
191+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to invalid value " + e.getMessage());
190192
return null;
191193
}
192194
}
@@ -228,6 +230,7 @@ public static Float getFloat(String sName)
228230
}
229231
catch (RuntimeException e)
230232
{
233+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to invalid value " + e.getMessage());
231234
return null;
232235
}
233236
}
@@ -269,6 +272,7 @@ public static Double getDouble(String sName)
269272
}
270273
catch (RuntimeException e)
271274
{
275+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to invalid value " + e.getMessage());
272276
return null;
273277
}
274278
}
@@ -304,15 +308,7 @@ public static Double getDouble(String sName, double dDefault)
304308
*/
305309
public static Duration getDuration(String sName)
306310
{
307-
String sValue = getProperty(sName);
308-
try
309-
{
310-
return sValue == null || sValue.isEmpty() ? null : new Duration(sValue);
311-
}
312-
catch (RuntimeException e)
313-
{
314-
return null;
315-
}
311+
return getDuration(sName, /*dDefault*/ null, /*magnitudeDefault*/ null);
316312
}
317313

318314
/**
@@ -329,9 +325,37 @@ public static Duration getDuration(String sName)
329325
*/
330326
public static Duration getDuration(String sName, Duration dDefault)
331327
{
332-
Duration d = getDuration(sName);
328+
return getDuration(sName, dDefault, /*magnitudeDefault*/ null);
329+
}
333330

334-
return d == null ? dDefault : d;
331+
/**
332+
* Return Coherence system property value as a {@link Duration}.
333+
* <p>
334+
* Backwards compatibility support is described in {@link Config}.
335+
*
336+
* @param sName Coherence system property name beginning with <code>coherence.</code>
337+
* @param dDefault default {@link Duration} value
338+
* @param magnitudeDefault default Duration magnitude when system property value does not include a magnitude
339+
*
340+
* @return property value as {@link Duration} if property lookup and conversion
341+
* of the String value to {@link Duration} succeeds; otherwise,
342+
* return <code>dDefault</code>
343+
*
344+
* @since 25.09
345+
*/
346+
public static Duration getDuration(String sName, Duration dDefault, Duration.Magnitude magnitudeDefault)
347+
{
348+
String sValue = getProperty(sName);
349+
try
350+
{
351+
return sValue == null || sValue.isEmpty() ? dDefault : new Duration(sValue, magnitudeDefault);
352+
}
353+
catch (RuntimeException e)
354+
{
355+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to " + e.getMessage() +
356+
" Verify that duration string value uses valid magnitudes such as ms, s, m, h.");
357+
return dDefault;
358+
}
335359
}
336360

337361
/**
@@ -356,6 +380,8 @@ public static MemorySize getMemorySize(String sName)
356380
}
357381
catch (RuntimeException e)
358382
{
383+
System.err.println("Warning: ignoring system property \"" + sName + "\" due to " + e.getMessage() +
384+
" Verify that memory size string value ends in a valid memory size magnitude such as b, k, m, gb.");
359385
return null;
360386
}
361387
}

prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/config/ConfigTest.java

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.coherence.config;
88

99
import com.oracle.coherence.common.util.Duration;
10+
import com.oracle.coherence.common.util.MemorySize;
1011
import com.oracle.coherence.testing.SystemPropertyIsolation;
1112
import com.oracle.coherence.testing.SystemPropertyResource;
1213

@@ -601,6 +602,109 @@ public void testClassPrefixPropertyDefaultingBackwardsCompatible()
601602
assertThat(Config.getInteger(ORACLE_COMMON + RECONNECT_LIMIT_SUFFIX, DEFAULT_VALUE), is(DEFAULT_VALUE));
602603
}
603604

605+
/**
606+
* COH-32433: ensure no duration magnitude is needed in system property value ending in "Millis" and provided numeric value defaults to millis.
607+
*/
608+
@Test
609+
public void testValidMillisDuration()
610+
{
611+
final String ORACLE_COMMON = "com.oracle.common"; // before Coherence 14.1.1.0
612+
final String ACKTIMEOUTMILLIS = ".internal.net.socketbus.SocketBusDriver.ackTimeoutMillis";
613+
final long dMillis = 1200L;
614+
615+
try (SystemPropertyResource p = new SystemPropertyResource(ORACLE_COMMON + ACKTIMEOUTMILLIS, Long.toString(dMillis));)
616+
{
617+
long millis = Config.getDuration(ORACLE_COMMON + ACKTIMEOUTMILLIS,
618+
new Duration("111", Duration.Magnitude.MILLI),
619+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
620+
assertThat("system property value does not contain magnitude but defaults to millis as expected for duration for system property ending in Millis",
621+
millis, is(dMillis));
622+
}
623+
}
624+
625+
@Test
626+
public void testMillisDurationWithDuration()
627+
{
628+
final String ORACLE_COMMON = "com.oracle.common"; // before Coherence 14.1.1.0
629+
final String ACKTIMEOUTMILLIS = ".internal.net.socketbus.SocketBusDriver.ackTimeoutMillis";
630+
final String sValueSec = "2s";
631+
632+
try (SystemPropertyResource p = new SystemPropertyResource(ORACLE_COMMON + ACKTIMEOUTMILLIS, sValueSec);)
633+
{
634+
long dMillis = Config.getDuration(ORACLE_COMMON + ACKTIMEOUTMILLIS,
635+
new Duration("111", Duration.Magnitude.MILLI),
636+
Duration.Magnitude.MILLI).as(Duration.Magnitude.MILLI);
637+
assertThat("verify specified magnitude in system property value overrides default magnitude",
638+
dMillis, is(new Duration(sValueSec).as(Duration.Magnitude.MILLI)));
639+
}
640+
}
641+
642+
@Test
643+
public void testInvalidMillisDuration()
644+
{
645+
final String ORACLE_COMMON = "com.oracle.common";
646+
final String ACKTIMEOUTMILLIS = ".internal.net.socketbus.SocketBusDriver.ackTimeoutMillis";
647+
final long dMillis = 1200L;
648+
649+
try (SystemPropertyResource p = new SystemPropertyResource(ORACLE_COMMON + ACKTIMEOUTMILLIS, Long.toString(dMillis));)
650+
{
651+
long millis = Config.getDuration(ORACLE_COMMON + ACKTIMEOUTMILLIS,
652+
new Duration("111", Duration.Magnitude.MILLI)).as(Duration.Magnitude.MILLI);
653+
assertThat("system property value does not contain magnitude and has no defaults to millis as expected for duration for system property ending in Millis",
654+
millis, is(111L));
655+
}
656+
}
657+
658+
@Test
659+
public void testInvalidPropertyValues()
660+
{
661+
// test for Int, Long, Float, Double, Duration, MemorySize
662+
try (SystemPropertyResource p = new SystemPropertyResource("IntProperty", "123InvalidInt");)
663+
{
664+
final int DEFAULT = 5;
665+
int dValue = Config.getInteger("IntProperty", DEFAULT);
666+
667+
assertThat(dValue, is(DEFAULT));
668+
}
669+
try (SystemPropertyResource p = new SystemPropertyResource("LongProperty", "123InvalidLong");)
670+
{
671+
final long DEFAULT = 5;
672+
long lValue = Config.getLong("LongProperty", DEFAULT);
673+
674+
assertThat(lValue, is(DEFAULT));
675+
}
676+
try (SystemPropertyResource p = new SystemPropertyResource("FloatProperty", "123InvalidFloat");)
677+
{
678+
final float DEFAULT = 5.0f;
679+
float fValue = Config.getFloat("FloatProperty", DEFAULT);
680+
681+
assertThat(fValue, is(DEFAULT));
682+
}
683+
try (SystemPropertyResource p = new SystemPropertyResource("DoubleProperty", "123InvalidDouble");)
684+
{
685+
final double DEFAULT = 5.0f;
686+
double fValue = Config.getDouble("DoubleProperty", DEFAULT);
687+
688+
assertThat(fValue, is(DEFAULT));
689+
}
690+
691+
try (SystemPropertyResource p = new SystemPropertyResource("DurationProperty", "1234");)
692+
{
693+
// missing duration magnitude in string and Config.getDuration() does not provide a default magnitude.
694+
final Duration DEFAULT = new Duration("5s");
695+
Duration durValue = Config.getDuration("DurationProperty", DEFAULT, null);
696+
697+
assertThat(durValue, is(DEFAULT));
698+
}
699+
try (SystemPropertyResource p = new SystemPropertyResource("MemorySizeProperty", "123invalidMagnitude");)
700+
{
701+
final MemorySize DEFAULT = new MemorySize("1m");
702+
MemorySize memorySize = Config.getMemorySize("MemorySizeProperty", "1m");
703+
704+
assertThat(memorySize, is(DEFAULT));
705+
}
706+
}
707+
604708
//----- constants --------------------------------------------------------
605709

606710
/**

0 commit comments

Comments
 (0)