JDK-6896219 : (fc) FileChannel.transferTo to DatagramChannel fails with "Operation not supported" (sol)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.2_20
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,solaris_10
  • CPU: x86,sparc
  • Submitted: 2009-10-29
  • Updated: 2011-02-16
  • Resolved: 2010-02-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other
1.4.2_25-rev b04Fixed 1.4.2_26-revFixed 1.4.2_27Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
When user sets DatagramChannel to  3rd arg. of transferTo(),
IOException occurs.

CONFIGURATION:
OS : Solaris 10
JDK : 1.4.2_20

REPRODUCE:

1. Compile the attached  transferToDatagram.java
2. Invoke java  transferToDatagram <org file> <target file> as follows.
 Then you can see an IOException as follows.

goedel[50]% java transferToDatagram from to
transferTo : pos=0, len=1708, pos+len=1708
Client
java.io.IOException: Operation not supported on transport endpoint
        at sun.nio.ch.FileChannelImpl.transferTo0(Native Method)
        at sun.nio.ch.FileChannelImpl.transferToDirectly(FileChannelImpl.java:39
2)
        at sun.nio.ch.FileChannelImpl.transferTo(FileChannelImpl.java:487)
        at transferToDatagram.main(transferToDatagram.java:57)
goedel[51]%

Comments
SUGGESTED FIX At least for jdk6, this is trivially fixed with this patch from jdk7: --- a/src/solaris/native/sun/nio/ch/FileChannelImpl.c Sun Feb 15 12:25:54 2009 +0000 +++ b/src/solaris/native/sun/nio/ch/FileChannelImpl.c Mon Apr 06 08:59:33 2009 +0100 @@ -231,6 +231,8 @@ Java_sun_nio_ch_FileChannelImpl_transfer if (result < 0) { if (errno == EAGAIN) return IOS_UNAVAILABLE; + if (errno == EOPNOTSUPP) + return IOS_UNSUPPORTED_CASE; if ((errno == EINVAL) && ((ssize_t)count >= 0)) return IOS_UNSUPPORTED_CASE; if (errno == EINTR)
29-10-2009

EVALUATION This bug is applicable to jdk6 and older releases. At least for jdk6, the issue is that sendfile may fail with -1/EOPNOTSUPP and this error is not handled. In jdk7 this error is handled so that the fallback/slow-path is used.
29-10-2009