8303622: JFR: Missing message with Objects.requireNonNull

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2023-03-07 23:32:09 +00:00
parent d7298245d6
commit 9b10c69475
6 changed files with 22 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -329,7 +329,7 @@ public final class AnnotationElement {
* it exists, else {@code null}
*/
public final <A> A getAnnotation(Class<? extends Annotation> annotationType) {
Objects.requireNonNull(annotationType);
Objects.requireNonNull(annotationType, "annotationType");
return type.getAnnotation(annotationType);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -693,8 +693,8 @@ public final class Recording implements Closeable {
}
private void setSetting(String id, String value) {
Objects.requireNonNull(id);
Objects.requireNonNull(value);
Objects.requireNonNull(id, "id");
Objects.requireNonNull(value, "value");
internal.setSetting(id, value);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -193,7 +193,7 @@ public sealed class RecordedObject
* @see #getFields()
*/
public boolean hasField(String name) {
Objects.requireNonNull(name);
Objects.requireNonNull(name, "name");
for (ValueDescriptor v : objectContext.fields) {
if (v.getName().equals(name)) {
return true;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -267,6 +267,7 @@ public final class RecordingFile implements Closeable {
* {@code checkRead} method denies read access to the file.
*/
public static List<RecordedEvent> readAllEvents(Path path) throws IOException {
Objects.requireNonNull(path, "path");
try (RecordingFile r = new RecordingFile(path)) {
List<RecordedEvent> list = new ArrayList<>();
while (r.hasMoreEvents()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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
@ -441,7 +441,7 @@ public final class RecordingStream implements AutoCloseable, EventStream {
* @since 17
*/
public void dump(Path destination) throws IOException {
Objects.requireNonNull(destination);
Objects.requireNonNull(destination, "destination");
Object recorder = PrivateAccess.getInstance().getPlatformRecorder();
synchronized (recorder) {
RecordingState state = recording.getState();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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
@ -109,8 +109,8 @@ public final class RemoteRecordingStream implements EventStream {
@Override
public void with(String name, String value) {
Objects.requireNonNull(name);
Objects.requireNonNull(value);
Objects.requireNonNull(name, "name");
Objects.requireNonNull(value, "value");
// FlightRecorderMXBean implementation always returns
// new instance of Map so no need to create new here.
Map<String, String> newSettings = getEventSettings();
@ -210,12 +210,12 @@ public final class RemoteRecordingStream implements EventStream {
}
@SuppressWarnings("removal")
private RemoteRecordingStream(MBeanServerConnection connection, Path dir, boolean delete) throws IOException {
Objects.requireNonNull(connection);
Objects.requireNonNull(dir);
private RemoteRecordingStream(MBeanServerConnection connection, Path directory, boolean delete) throws IOException {
Objects.requireNonNull(connection, "connection");
Objects.requireNonNull(directory, "directory");
accessControllerContext = AccessController.getContext();
// Make sure users can't implement malicious version of a Path object.
path = Paths.get(dir.toString());
path = Paths.get(directory.toString());
if (!Files.exists(path)) {
throw new IOException("Download directory doesn't exist");
}
@ -334,7 +334,7 @@ public final class RemoteRecordingStream implements EventStream {
* @see Recording#setSettings(Map)
*/
public void setSettings(Map<String, String> settings) {
Objects.requireNonNull(settings);
Objects.requireNonNull(settings, "settings");
try {
mbean.setRecordingSettings(recordingId, settings);
} catch (Exception e) {
@ -355,7 +355,7 @@ public final class RemoteRecordingStream implements EventStream {
*
*/
public EventSettings disable(String name) {
Objects.requireNonNull(name);
Objects.requireNonNull(name, "name");
EventSettings s = ManagementSupport.newEventSettings(new RemoteSettings(mbean, recordingId));
try {
return s.with(name + "#" + ENABLED, "false");
@ -379,7 +379,7 @@ public final class RemoteRecordingStream implements EventStream {
* @see EventType
*/
public EventSettings enable(String name) {
Objects.requireNonNull(name);
Objects.requireNonNull(name, "name");
EventSettings s = ManagementSupport.newEventSettings(new RemoteSettings(mbean, recordingId));
try {
return s.with(name + "#" + ENABLED, "true");
@ -656,7 +656,7 @@ public final class RemoteRecordingStream implements EventStream {
* @since 17
*/
public void dump(Path destination) throws IOException {
Objects.requireNonNull(destination);
Objects.requireNonNull(destination, "destination");
long id = -1;
try {
FileDump fileDump;