United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7034155 (ch) NullPointerException in sun.io.ch.IOUtil when OOM is thrown
JDK-7034155 : (ch) NullPointerException in sun.io.ch.IOUtil when OOM is thrown

Details
Type:
Bug
Submit Date:
2011-04-05
Status:
Closed
Updated Date:
2012-03-20
Project Name:
JDK
Resolved Date:
2011-06-08
Component:
core-libs
OS:
linux_redhat_4.0,solaris_10
Sub-Component:
java.nio
CPU:
x86,sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u24,6u26
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
JDK 6.0.23, but from looking at the sources the same problem is in the head revision of java 6 and java 7 code base

ADDITIONAL OS VERSION INFORMATION :
red hat linux 4.0

A DESCRIPTION OF THE PROBLEM :
java.lang.NullPointerException
        at sun.nio.ch.Util.free(Util.java:199)
        at sun.nio.ch.Util.offerFirstTemporaryDirectBuffer(Util.java:176)
        at sun.nio.ch.IOUtil.read(IOUtil.java:181)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)

This occurs when running a large proprietory grid application that is extensively using NIO. From looking at the code is appears that
the problem is in sun.io.ch.IOUtil line 172/174. Line 174 should be outside of the try block. If Util.getTemporaryBuffer() fails (e.g. due to an OOM, then the finally block is executed which would cause this exception.

We are unable to verify that this is the cause of the issue. This diagnosis is by the code inspection. We have rolled the application back to 6.0.16 and have not experienced the issue again

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
We cannot generate a test case. This occurred on an operational system running 24/7 unter heavy IO load for several days, and this exception was noted.

Due to this we cannot repoduce this locally

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception should be thrown
ACTUAL -
exception reported was thrown

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
        at sun.nio.ch.Util.free(Util.java:199)
        at sun.nio.ch.Util.offerFirstTemporaryDirectBuffer(Util.java:176)
        at sun.nio.ch.IOUtil.read(IOUtil.java:181)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)


REPRODUCIBILITY :
This bug can be reproduced occasionally.

CUSTOMER SUBMITTED WORKAROUND :
revert to 1.6.16

Due to the sporadic nature of this issue we cannot be sure that this is a fix, or if it affects some other side effects that do not manifest the problem, but we have not seen this issue for a couple of weeks now, when is was occurring once every few days on each node in a farm

                                    

Comments
EVALUATION

The description is correct and NPE will be thrown if a temporary buffer cannot be allocated, thus masking the OutOfMemoryError.
                                     
2011-04-06



Hardware and Software, Engineered to Work Together