-
Bug
-
Resolution: Fixed
-
P3
-
9, 11, 12, 13
-
b24
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225979 | 14 | Chris Hegarty | P3 | Resolved | Fixed | team |
Socket.getOption(StandardSocketOptions.SO_LINGER) does not return the
expected type, when invoked on a socket that has not had its setOption
equivalent invoke to set the option. The expected returned type is
Integer, but the actual type is Boolean.
For example:
$ jdk-12.jdk/Contents/Home/bin/jshell
| Welcome to JShell -- Version 12
| For an introduction type: /help intro
jshell> var s = new Socket()
s ==> Socket[unconnected]
jshell> s.getOption(StandardSocketOptions.SO_LINGER)
| Exception java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.Integer (java.lang.Boolean and java.lang.Integer are in module java.base of loader 'bootstrap')
| at (#2:1)
---
There are also issues when negative values are set. For example:
jshell> var s = new Socket()
s ==> Socket[unconnected]
jshell> s.setOption(StandardSocketOptions.SO_LINGER, -1)
$4 ==> Socket[unconnected]
jshell> s.getOption(StandardSocketOptions.SO_LINGER)
$5 ==> 65535
expected type, when invoked on a socket that has not had its setOption
equivalent invoke to set the option. The expected returned type is
Integer, but the actual type is Boolean.
For example:
$ jdk-12.jdk/Contents/Home/bin/jshell
| Welcome to JShell -- Version 12
| For an introduction type: /help intro
jshell> var s = new Socket()
s ==> Socket[unconnected]
jshell> s.getOption(StandardSocketOptions.SO_LINGER)
| Exception java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.Integer (java.lang.Boolean and java.lang.Integer are in module java.base of loader 'bootstrap')
| at (#2:1)
---
There are also issues when negative values are set. For example:
jshell> var s = new Socket()
s ==> Socket[unconnected]
jshell> s.setOption(StandardSocketOptions.SO_LINGER, -1)
$4 ==> Socket[unconnected]
jshell> s.getOption(StandardSocketOptions.SO_LINGER)
$5 ==> 65535
- backported by
-
JDK-8225979 Socket.getOption(SocketOption) not returning the expected type for the StandardSocketOptions.SO_LINGER
-
- Resolved
-