Skip to content

Commit

Permalink
6141: JMC logs warnings when creating recordings
Browse files Browse the repository at this point in the history
Reviewed-by: hirt, jpbempel
  • Loading branch information
aptmac committed Jun 25, 2021
1 parent 7f38790 commit e34323d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.openjdk.jmc.common.unit.UnitLookup.BYTE;
import static org.openjdk.jmc.common.unit.UnitLookup.DAY;
import static org.openjdk.jmc.common.unit.UnitLookup.EPOCH_MS;
import static org.openjdk.jmc.common.unit.UnitLookup.EPOCH_NS;
import static org.openjdk.jmc.common.unit.UnitLookup.HOUR;
import static org.openjdk.jmc.common.unit.UnitLookup.MEMORY;
import static org.openjdk.jmc.common.unit.UnitLookup.MINUTE;
Expand Down Expand Up @@ -270,7 +271,7 @@ public IQuantity parsePersisted(String persistedValue) throws QuantityConversion
}

public final static IConstraint<IQuantity> POSITIVE_TIMESPAN = new ComparableConstraint<>(
new TimePersisterBrokenSI(), SECOND.quantity(0), YEAR.quantity(200));
new TimePersisterBrokenSI(), SECOND.quantity(0), EPOCH_NS.quantity(Long.MAX_VALUE));
public final static IConstraint<IQuantity> PERIOD_V1 = new ComparableConstraint<>(new PeriodPersister(),
NANOSECOND.quantity(1), YEAR.quantity(1));
public final static IConstraint<IQuantity> PERIOD_V2 = new ComparableConstraint<>(new PeriodPersisterV2(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Provides information about an event type for JFR 2.0.
*/
public final class EventTypeMetadataV2 implements IEventTypeInfo {
private static final String JFR_SETTINGS_PERIOD = "com.oracle.jfr.settings.Period"; //$NON-NLS-1$
private static final String JFR_SETTINGS_PERIOD = "jdk.settings.Period"; //$NON-NLS-1$
private final Long id;
private final EventTypeIDV2 eventTypeID;
private final String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class LinearKindOfQuantity extends KindOfQuantity<LinearUnit> {
private static final FormatThreadLocal<NumberFormat> NUMBER_FORMAT_INTERACTIVE_HOLDER;
// Holder of display number formatter/parser, which may contain non-breaking spaces.
private static final FormatThreadLocal<NumberFormat> NUMBER_FORMAT_DISPLAY_HOLDER;
private static final String INFINITY = "infinity"; //$NON-NLS-1$

protected final LinearUnit atomUnit;
// Since units no longer have an explicit name, only a description, use this to generate prefixed names.
Expand Down Expand Up @@ -613,6 +614,9 @@ public ITypedQuantity<LinearUnit> parsePersisted(String persistedQuantity) throw
throw QuantityConversionException.unknownUnit(persistedQuantity, getDefaultUnit().quantity(1234.0));
}
}
if (INFINITY.equals(persistedQuantity)) {
return UnitLookup.NANOSECOND.quantity(Long.MAX_VALUE);
}
throw QuantityConversionException.unparsable(persistedQuantity, getDefaultUnit().quantity(1234.0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,10 @@ public void testCustomUnitConversion() throws Exception {
AdHocQuantityTest.assertNearlySame(quantity, wellKnown);
}

@Test
public void testPersistedQuantityInfinity() throws Exception {
ITypedQuantity<LinearUnit> quantity = TIMESPAN.parsePersisted("infinity");
assertEquals(quantity.longValue(), Long.MAX_VALUE);
}

}

0 comments on commit e34323d

Please sign in to comment.