Skip to content

Commit 99ea9e0

Browse files
committed
Change/remove usage of some deprecated JDK API
API deprecated in Java 16 or more. There are alternatives (e.g. for certificate subject and issuer) for some, but not for all (e.g. usage of the security manager to change thread, which is no big deal as the changes to thread are minor and it is likely nobody cares about such checks nowadays). Fixes #709 (cherry picked from commit 57b61d8)
1 parent ecbe850 commit 99ea9e0

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/main/java/com/rabbitmq/client/impl/Environment.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,29 @@
2323
* Package-protected API.
2424
*/
2525
public class Environment {
26+
27+
/**
28+
* This method is deprecated and subject to removal in the next major release.
29+
*
30+
* There is no replacement for this method, as it used to use the
31+
* {@link SecurityManager}, which is itself deprecated and subject to removal.
32+
* @deprecated
33+
* @return always returns true
34+
*/
35+
@Deprecated
2636
public static boolean isAllowedToModifyThreads() {
27-
try {
28-
SecurityManager sm = System.getSecurityManager();
29-
if(sm != null) {
30-
sm.checkPermission(new RuntimePermission("modifyThread"));
31-
sm.checkPermission(new RuntimePermission("modifyThreadGroup"));
32-
}
33-
return true;
34-
} catch (SecurityException se) {
35-
return false;
36-
}
37+
return true;
3738
}
3839

3940
public static Thread newThread(ThreadFactory factory, Runnable runnable, String name) {
4041
Thread t = factory.newThread(runnable);
41-
if(isAllowedToModifyThreads()) {
42-
t.setName(name);
43-
}
42+
t.setName(name);
4443
return t;
4544
}
4645

4746
public static Thread newThread(ThreadFactory factory, Runnable runnable, String name, boolean isDaemon) {
4847
Thread t = newThread(factory, runnable, name);
49-
if(isAllowedToModifyThreads()) {
50-
t.setDaemon(isDaemon);
51-
}
48+
t.setDaemon(isDaemon);
5249
return t;
5350
}
5451
}

src/main/java/com/rabbitmq/client/impl/TlsUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static String peerCertificateInfo(Certificate certificate, String prefix)
104104
try {
105105
return String.format("%s subject: %s, subject alternative names: %s, " +
106106
"issuer: %s, not valid after: %s, X.509 usage extensions: %s",
107-
stripCRLF(prefix), stripCRLF(c.getSubjectDN().getName()), stripCRLF(sans(c, ",")), stripCRLF(c.getIssuerDN().getName()),
107+
stripCRLF(prefix), stripCRLF(c.getSubjectX500Principal().getName()), stripCRLF(sans(c, ",")), stripCRLF(c.getIssuerX500Principal().getName()),
108108
c.getNotAfter(), stripCRLF(extensions(c)));
109109
} catch (Exception e) {
110110
return "Error while retrieving " + prefix + " certificate information";

0 commit comments

Comments
 (0)