United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4940437 sun.nio.ch.Util.releaseTemporaryDirectBuffer NullPointerException
JDK-4940437 : sun.nio.ch.Util.releaseTemporaryDirectBuffer NullPointerException

Details
Type:
Bug
Submit Date:
2003-10-20
Status:
Resolved
Updated Date:
2003-12-11
Project Name:
JDK
Resolved Date:
2003-11-23
Component:
core-libs
OS:
solaris_9
Sub-Component:
java.nio
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
3.5,1.4.2_02
Fixed Versions:
1.4.2_04 (04)

Related Reports
Backport:

Sub Tasks

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
EVALUATION

I agree with the analysis in the description. This should be a straightforward fix.
###@###.### 2003-10-23
                                     
2003-10-23
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


                                     
2004-07-16



Hardware and Software, Engineered to Work Together