8303681: JFR: RemoteRecordingStream::setMaxAge() should accept null

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin
2023-03-07 22:32:45 +00:00
parent 9f9d678591
commit 32f4d8b5ea
3 changed files with 6 additions and 9 deletions

View File

@@ -409,7 +409,9 @@ final class DiskRepository implements Closeable {
public synchronized void setMaxAge(Duration maxAge) {
this.maxAge = maxAge;
trimToAge(Instant.now().minus(maxAge));
if (maxAge != null) {
trimToAge(Instant.now().minus(maxAge));
}
}
public synchronized void setMaxSize(long maxSize) {

View File

@@ -410,7 +410,6 @@ public final class RemoteRecordingStream implements EventStream {
* state
*/
public void setMaxAge(Duration maxAge) {
Objects.requireNonNull(maxAge);
synchronized (lock) {
repository.setMaxAge(maxAge);
this.maxAge = maxAge;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@ public class TestDelegated {
}
// The assumption here is that the following methods don't
// need t be tested fully since they all delegate to the
// need to be tested fully since they all delegate to the
// same implementation class that is tested elsewhere.
public static void main(String[] args) throws Exception {
@@ -70,12 +70,8 @@ public class TestDelegated {
private static void testSetMaxAge() throws Exception {
try (RemoteRecordingStream stream = new RemoteRecordingStream(CONNECTION)) {
try {
stream.setMaxAge(Duration.ofHours(1));
stream.setMaxAge(null);
throw new Exception("Expected NullPointerException");
} catch (NullPointerException npe) {
// As expected
}
}
}