mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8254711: Add java.security.Provider.getService JFR Event
Reviewed-by: mullan, valeriep, jpai
This commit is contained in:
parent
d781ab09f7
commit
bc2af47e1e
9 changed files with 279 additions and 9 deletions
|
@ -25,6 +25,8 @@
|
|||
|
||||
package java.security;
|
||||
|
||||
import jdk.internal.event.SecurityProviderServiceEvent;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import static java.util.Locale.ENGLISH;
|
||||
|
@ -1281,18 +1283,22 @@ public abstract class Provider extends Properties {
|
|||
}
|
||||
|
||||
Service s = serviceMap.get(key);
|
||||
if (s != null) {
|
||||
return s;
|
||||
if (s == null) {
|
||||
s = legacyMap.get(key);
|
||||
if (s != null && !s.isValid()) {
|
||||
legacyMap.remove(key, s);
|
||||
}
|
||||
}
|
||||
|
||||
s = legacyMap.get(key);
|
||||
if (s != null && !s.isValid()) {
|
||||
legacyMap.remove(key, s);
|
||||
} else {
|
||||
return s;
|
||||
if (s != null && SecurityProviderServiceEvent.isTurnedOn()) {
|
||||
var e = new SecurityProviderServiceEvent();
|
||||
e.provider = getName();
|
||||
e.type = type;
|
||||
e.algorithm = algorithm;
|
||||
e.commit();
|
||||
}
|
||||
|
||||
return null;
|
||||
return s;
|
||||
}
|
||||
|
||||
// ServiceKey from previous getService() call
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.event;
|
||||
|
||||
/**
|
||||
* Event recording details of Provider.getService(String type, String algorithm) calls
|
||||
*/
|
||||
|
||||
public final class SecurityProviderServiceEvent extends Event {
|
||||
private final static SecurityProviderServiceEvent EVENT = new SecurityProviderServiceEvent();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if event is enabled, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isTurnedOn() {
|
||||
return EVENT.isEnabled();
|
||||
}
|
||||
|
||||
public String type;
|
||||
public String algorithm;
|
||||
public String provider;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue