JDK-4940437 : sun.nio.ch.Util.releaseTemporaryDirectBuffer NullPointerException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 3.5,1.4.2_02
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: x86
  • Submitted: 2003-10-20
  • Updated: 2003-12-11
  • Resolved: 2003-11-23
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
1.4.2_04 04Fixed
Description
This problem was found while testing Sun ONE Message Queue 3.5 (Build 330-R) 
on J2SE 1.4.2_02, Solaris 9u4 x86. For more details on that test case see 
MQ bug 4939923. It involves performing IO on large (50MB) chunks of data.

During the test the broker (our server component) threw the following exception:

17/Oct/2003:16:14:32 PDT] WARNING [B3100]: Unexpected Broker Internal Error : [
sun.nio.ch.DevPollSelectorImpl@1bc4ec8] :
java.lang.NullPointerException
        at sun.nio.ch.Util.releaseTemporaryDirectBuffer(Util.java:70)
        at sun.nio.ch.IOUtil.read(IOUtil.java:212)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
        at com.sun.messaging.jmq.io.Packet.myChannelRead(Packet.java:1882)
        at com.sun.messaging.jmq.io.Packet.readRestOfPacket(Packet.java:1153)
        at com.sun.messaging.jmq.io.Packet.readPacket(Packet.java:1025)
        at com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection.readData(IM
QConnection.java:1635)
        at com.sun.messaging.jmq.jmsserver.service.imq.group.ReadThread.process(
ReadThread.java:57)
        at com.sun.messaging.jmq.jmsserver.service.imq.group.SelectThread.proces
sThread(SelectThread.java:353)
        at com.sun.messaging.jmq.jmsserver.service.imq.group.GroupRunnable.proce
ss(GroupRunnable.java:116)
        at com.sun.messaging.jmq.jmsserver.util.pool.BasicRunnable.run(BasicRunn
able.java:455)
        at java.lang.Thread.run(Thread.java:534)

On code inspection of sun/nio/ch/Util.java I see the following:

    66          // Otherwise replace a smaller one in the cache if such exists
    67          for (int i=0; i<TEMP_BUF_POOL_SIZE; i++) {
    68              SoftReference ref = (SoftReference)(bufferPool[i].get());
    69              ByteBuffer inCacheBuf = (ByteBuffer)ref.get();
    70              if (buf.capacity() > inCacheBuf.capacity()) {
    71                  bufferPool[i].set(new SoftReference(buf));
    72                  return;
    73              }
    74          }

It seems to me that on line 69 inCacheBuf could be null if the soft reference 
has been cleared.


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_04 tiger-beta FIXED IN: 1.4.2_04 tiger-beta INTEGRATED IN: 1.4.2_04 tiger-b28 tiger-b30 tiger-beta
16-07-2004

EVALUATION I agree with the analysis in the description. This should be a straightforward fix. ###@###.### 2003-10-23
23-10-2003