kkewwei commented on code in PR #473: URL: https://github.com/apache/httpcomponents-core/pull/473#discussion_r1703016015
########## httpcore5/src/main/java/org/apache/hc/core5/util/ReflectionUtils.java: ########## @@ -72,4 +75,35 @@ public static int determineJRELevel() { return 7; } + /** + * @since 5.3 + */ + public static <T> SocketOption<T> getExtendedSocketOptionOrNull(final String fieldName) { + try { + final Class<?> extendedSocketOptionsClass = Class.forName("jdk.net.ExtendedSocketOptions"); + final Field field = extendedSocketOptionsClass.getField(fieldName); + return (SocketOption)field.get((Object)null); + } catch (final Exception ignore) { + return null; + } + } + + /** + * object can be ServerSocket or Socket + * + * @since 5.3 + */ + public static <T> void setOption(final T object, final String fieldName, final T value) { Review Comment: @ok2c whether I should use `ReflectionUtils.callSetter` directly? But the method doesn't throw any exception, which is not suitable for me, I want an exception to be thrown if there is a problem. I don't know whether I should change the logic of `ReflectionUtils.callSetter`: the method doesn't swallow the exception, which will have an impact on existing usage. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org