forked from netty/netty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace reflective access of Throwable#addSuppressed with version gua…
…rded access Motivation: In environments with a security manager, the reflective access to get the reference to Throwable#addSuppressed can cause issues that result in Netty failing to load. The main motivation in this pull request is to remove the use of reflection to prevent issues in these environments. Modifications: ThrowableUtil no longer uses Class#getDeclaredMembers to get the Method that references Throwable#addSuppressed and instead guards the call to Throwable#addSuppressed with a Java version check. Additionally, a annotation was added that suppresses the animal sniffer java16 signature check on the given method. The benefit of the annotation is that it limits the exclusion of Throwable to just the ThrowableUtil class and has string text indicating the reason for suppressing the java16 signature check. Result: Netty no longer requires the use of Class#getDeclaredMethod for ThrowableUtil and will work in environments restricted by a security manager without needing to grant reflection permissions. Fixes netty#7614
- Loading branch information
1 parent
b640797
commit f0c76ca
Showing
4 changed files
with
43 additions
and
42 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
common/src/main/java/io/netty/util/internal/SuppressJava6Requirement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2018 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.netty.util.internal; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotation to suppress the Java 6 source code requirement checks for a method. | ||
*/ | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ ElementType.METHOD }) | ||
public @interface SuppressJava6Requirement { | ||
|
||
String reason(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters