JDK-8023258 : Logger.getLogger() after ImageIO.read() returns different logger instance
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 7u25
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • Submitted: 2013-08-19
  • Updated: 2013-09-16
  • Resolved: 2013-08-19
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
No specific configuration

A DESCRIPTION OF THE PROBLEM :
Repeated calls of java.util.logging.Logger.getLogger( " a.b " ) creates a new logger instance after ImageIO.read() was called if a security manager is installed.

Additionally, the logger hierarchy is broken, which means that the parent of logger  " a.b "  is no longer logger  " a " . This has the effect that file handlers added to the parent logger  " a "  are not considered by the new logger instance for  " a.b " .

We investigated ImageIO.read() and found out that the critical code line must be
IIORegistry.getDefaultInstance()
which is called during initialization of ImageIO.

REGRESSION.  Last worked in version 7u21

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new Java file with the source code given below and execute it one with JDK 1.7.0_25 and JDK 1.7.0_21.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output with jdk1.7.0_21 and before, e. g. jdk1.6.0_45

 " myLogger1.getParent() == parentLogger? --> true
myLogger1 == myLogger2 --> true
myLogger2.getParent() == parentLogger? --> true " 
ACTUAL -
Output with jdk1.7.0_25:

 " myLogger1.getParent() == parentLogger? --> true
myLogger1 == myLogger2 --> false
myLogger2.getParent() == parentLogger? --> false " 

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.rmi.RMISecurityManager;
import java.util.logging.Logger;

import javax.imageio.ImageIO;

public class LoggingTest {

    public static void main(String[] args) throws IOException {
        Logger parentLogger = Logger.getLogger( " a " );
        Logger mylogger1 = Logger.getLogger( " a.b " );
        System.out.println( " myLogger1.getParent() == parentLogger? -->  "  + (mylogger1.getParent() == parentLogger));
        
        System.setSecurityManager(new RMISecurityManager());// we are in an RMI environment, so we need the RMISecurityManager

        ByteArrayInputStream is = new ByteArrayInputStream(new byte[] { 0, 1 });
        ImageIO.read(is);
        
        Logger mylogger2 = Logger.getLogger( " a.b " );
        System.out.println( " myLogger1 == myLogger2 -->  "  + (mylogger1 == mylogger2));
        System.out.println( " myLogger2.getParent() == parentLogger? -->  "  + (mylogger2.getParent() == parentLogger));
    }
}

---------- END SOURCE ----------
Comments
This will be fixed by JDK-8019853
19-08-2013