Skip to content

Commit 5da52e3

Browse files
haniczmoresandeep
authored andcommitted
KNOX-3221: Remove JDK9+ checks from BCInterceptingSocket (apache#1115)
1 parent ac9c79a commit 5da52e3

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

gateway-spi/src/main/java/org/apache/knox/gateway/fips/BCInterceptingSocket.java

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.IOException;
2121
import java.io.InputStream;
2222
import java.io.OutputStream;
23-
import java.lang.reflect.InvocationTargetException;
2423
import java.net.InetAddress;
2524
import java.net.Socket;
2625
import java.net.SocketAddress;
@@ -239,37 +238,19 @@ public void setPerformancePreferences(int connectionTime,
239238
delegate.setPerformancePreferences(connectionTime, latency, bandwidth);
240239
}
241240

242-
/**
243-
* This method is only available in JDK9+ therefor reflection is used to call it.
244-
*/
245-
@SuppressWarnings({"PMD.MissingOverride", "unchecked"})
241+
@Override
246242
public Set<SocketOption<?>> supportedOptions() {
247-
return invokeDelegateMethod("supportedOptions", new Class<?>[]{});
243+
return delegate.supportedOptions();
248244
}
249245

250-
/**
251-
* This method is only available in JDK9+ therefor reflection is used to call it.
252-
*/
253-
@SuppressWarnings({"PMD.MissingOverride", "unchecked"})
246+
@Override
254247
public <T> T getOption(SocketOption<T> name) throws IOException {
255-
return invokeDelegateMethod("getOption", new Class<?>[]{SocketOption.class}, name);
248+
return delegate.getOption(name);
256249
}
257250

258251

259-
/**
260-
* This method is only available in JDK9+ therefor reflection is used to call it.
261-
*/
262-
@SuppressWarnings("PMD.MissingOverride")
252+
@Override
263253
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException {
264-
return invokeDelegateMethod("setOption", new Class<?>[]{SocketOption.class, Object.class}, name, value);
265-
}
266-
267-
@SuppressWarnings("unchecked")
268-
private <T> T invokeDelegateMethod(String methodName, Class<?>[] parameterTypes, Object... args) {
269-
try {
270-
return (T) delegate.getClass().getMethod(methodName, parameterTypes).invoke(delegate, args);
271-
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
272-
throw new UnsupportedOperationException("Socket option not supported", e);
273-
}
254+
return delegate.setOption(name, value);
274255
}
275256
}

0 commit comments

Comments
 (0)