Skip to content

Commit e30b4b4

Browse files
xerialclaude
andcommitted
Apply @SuppressWarnings to specific methods instead of class level
Based on review feedback, narrowed the scope of @SuppressWarnings("removal") annotations to only the specific methods and code blocks that use AccessController, rather than applying it at the class level. This approach: - Reduces the scope of the suppression - Avoids hiding other potential deprecation warnings - Follows best practices for targeted warning suppression 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 58b3491 commit e30b4b4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/xerial/snappy/pool/DirectByteBuffers.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
/**
2121
* Utility to facilitate disposing of direct byte buffer instances.
2222
*/
23-
@SuppressWarnings("removal") // AccessController is deprecated for removal in Java 17+
2423
final class DirectByteBuffers {
2524

2625
/**
@@ -36,6 +35,7 @@ final class DirectByteBuffers {
3635
// and https://github.com/apache/lucene-solr/blob/7e03427fa14a024ce257babcb8362d2451941e21/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
3736
MethodHandle cleanHandle = null;
3837
try {
38+
@SuppressWarnings("removal") // AccessController is deprecated for removal in Java 17+
3939
final PrivilegedExceptionAction<MethodHandle> action = new PrivilegedExceptionAction<MethodHandle>() {
4040

4141
@Override
@@ -91,7 +91,9 @@ public MethodHandle run() throws Exception {
9191
}
9292
};
9393

94-
cleanHandle = AccessController.doPrivileged(action);
94+
@SuppressWarnings("removal") // AccessController is deprecated for removal in Java 17+
95+
MethodHandle temp = AccessController.doPrivileged(action);
96+
cleanHandle = temp;
9597

9698
} catch (Throwable t) {
9799
Logger.getLogger(DirectByteBuffers.class.getName()).log(Level.FINE, "Exception occurred attempting to lookup Sun specific DirectByteBuffer cleaner classes.", t);
@@ -122,6 +124,7 @@ static boolean nonNull(Object o) {
122124
*
123125
* @param buffer The {@code ByteBuffer} to release. Must not be {@code null}. Must be {@link ByteBuffer#isDirect() direct}.
124126
*/
127+
@SuppressWarnings("removal") // AccessController is deprecated for removal in Java 17+
125128
public static void releaseDirectByteBuffer(final ByteBuffer buffer)
126129
{
127130
assert buffer != null && buffer.isDirect();

0 commit comments

Comments
 (0)