Skip to content

Commit

Permalink
8303681: JFR: RemoteRecordingStream::setMaxAge() should accept null
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Mar 7, 2023
1 parent 9f9d678 commit 32f4d8b
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -409,7 +409,9 @@ public synchronized void close() throws IOException {

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) {
Original file line number Diff line number Diff line change
@@ -410,7 +410,6 @@ public EventSettings enable(String name) {
* state
*/
public void setMaxAge(Duration maxAge) {
Objects.requireNonNull(maxAge);
synchronized (lock) {
repository.setMaxAge(maxAge);
this.maxAge = maxAge;
10 changes: 3 additions & 7 deletions test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java
Original file line number Diff line number Diff line change
@@ -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 @@ static class TestDelegatedEvent extends Event {
}

// 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 static void main(String[] args) throws Exception {

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
}
}
}

1 comment on commit 32f4d8b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.