harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r433900 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src: main/java/java/util/logging/ test/java/org/apache/harmony/logging/tests/java/util/logging/
Date Wed, 23 Aug 2006 04:53:46 GMT
Author: pyang
Date: Tue Aug 22 21:53:45 2006
New Revision: 433900

URL: http://svn.apache.org/viewvc?rev=433900&view=rev
Log:
Patch applied for HARMONY-1255 ( [classlib][logging]compatibility: java.util.logging.Handler.isLoggable(null) doesn't throw NPE while RI throws.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/StreamHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java?rev=433900&r1=433899&r2=433900&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java Tue Aug 22 21:53:45 2006
@@ -1,412 +1,412 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package java.util.logging;
-
-import java.nio.charset.Charset;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-import java.io.UnsupportedEncodingException;
-
-/**
- * A <code>Handler</code> object accepts a logging request and exports the
- * desired messages to a target, for example, a file, the console, etc. It can
- * be disabled by setting its logging level to <code>Level.OFF</code>.
- * 
- */
-public abstract class Handler {
-
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-    private static final Level DEFAULT_LEVEL = Level.ALL;
-
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
-
-    // the error manager to report errors during logging
-    private ErrorManager errorMan;
-
-    // the character encoding used by this handler
-    private String encoding;
-
-    // the logging level
-    private Level level;
-
-    // the formatter used to export messages
-    private Formatter formatter;
-
-    // the filter used to filter undesired messages
-    private Filter filter;
-
-    // class name, used for property reading
-    private String prefix;
-
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * Constructs a <code>Handler</code> object with a default error manager,
-     * the default encoding, and the default logging level
-     * <code>Level.ALL</code>. It has no filter and no formatter.
-     */
-    protected Handler() {
-        this.errorMan = new ErrorManager();
-        this.level = DEFAULT_LEVEL;
-        this.encoding = null;
-        this.filter = null;
-        this.formatter = null;
-        this.prefix = this.getClass().getName();
-    }
-
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
-    // get a instance from given class name, using Class.forName()
-    private Object getDefaultInstance(String className) {
-        Object result = null;
-        if (null == className) {
-            return result;
-        }
-        try {
-            result = Class.forName(className).newInstance();
-        } catch (Exception e) {
-            //ignore
-        }
-        return result;
-    }
-
-    // get a instance from given class name, using context classloader
-    private Object getCustomizeInstance(final String className)
-            throws Exception {
-        Class<?> c = AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
-                    public Class<?> run() throws Exception {
-                        ClassLoader loader = Thread.currentThread()
-                                .getContextClassLoader();
-                        if (null == loader) {
-                            loader = ClassLoader.getSystemClassLoader();
-                        }
-                        return loader.loadClass(className);
-                    }
-                });
-        return c.newInstance();
-    }
-
-    // print error message in some format
-    void printInvalidPropMessage(String key, String value, Exception e) {
-        String msg = new StringBuffer().append("Invalid property value for ") //$NON-NLS-1$
-                .append(prefix).append(".").append(key).append(":").append( //$NON-NLS-1$//$NON-NLS-2$
-                        value).toString();
-        errorMan.error(msg, e, ErrorManager.GENERIC_FAILURE);
-    }
-
-    /*
-     * init the common properties, including filter, level, formatter, and
-     * encoding
-     */
-    void initProperties(String defaultLevel, String defaultFilter,
-            String defaultFormatter, String defaultEncoding) {
-        LogManager manager = LogManager.getLogManager();
-
-        //set filter
-        final String filterName = manager.getProperty(prefix + ".filter"); //$NON-NLS-1$
-        if (null != filterName) {
-            try {
-                filter = (Filter) getCustomizeInstance(filterName);
-            } catch (Exception e1) {
-                printInvalidPropMessage("filter", filterName, e1); //$NON-NLS-1$
-                filter = (Filter) getDefaultInstance(defaultFilter);
-            }
-        } else {
-            filter = (Filter) getDefaultInstance(defaultFilter);
-        }
-
-        //set level
-        String levelName = manager.getProperty(prefix + ".level"); //$NON-NLS-1$
-        if (null != levelName) {
-            try {
-                level = Level.parse(levelName);
-            } catch (Exception e) {
-                printInvalidPropMessage("level", levelName, e); //$NON-NLS-1$
-                level = Level.parse(defaultLevel);
-            }
-        } else {
-            level = Level.parse(defaultLevel);
-        }
-
-        //set formatter
-        final String formatterName = manager.getProperty(prefix + ".formatter"); //$NON-NLS-1$
-        if (null != formatterName) {
-            try {
-                formatter = (Formatter) getCustomizeInstance(formatterName);
-            } catch (Exception e) {
-                printInvalidPropMessage("formatter", formatterName, e); //$NON-NLS-1$
-                formatter = (Formatter) getDefaultInstance(defaultFormatter);
-            }
-        } else {
-            formatter = (Formatter) getDefaultInstance(defaultFormatter);
-        }
-
-        //set encoding
-        final String encodingName = manager.getProperty(prefix + ".encoding"); //$NON-NLS-1$
-        try {
-            internalSetEncoding(encodingName);
-        } catch (UnsupportedEncodingException e) {
-            printInvalidPropMessage("encoding", encodingName, e); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * Closes this handler. A flush operation will usually be performed and all
-     * the associated resources will be freed. Client applications should not
-     * use a handler after closing it.
-     * 
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public abstract void close();
-
-    /**
-     * Flushes any buffered output.
-     */
-    public abstract void flush();
-
-    /**
-     * Accepts an actual logging request.
-     * 
-     * @param record
-     *            the log record to be logged
-     */
-    public abstract void publish(LogRecord record);
-
-    /**
-     * Gets the character encoding used by this handler.
-     * 
-     * @return the character encoding used by this handler
-     */
-    public String getEncoding() {
-        return this.encoding;
-    }
-
-    /**
-     * Gets the error manager used by this handler to report errors during
-     * logging.
-     * 
-     * @return the error manager used by this handler
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public ErrorManager getErrorManager() {
-        LogManager.getLogManager().checkAccess();
-        return this.errorMan;
-    }
-
-    /**
-     * Gets the filter used by this handler.
-     * 
-     * @return the filter used by this handler
-     */
-    public Filter getFilter() {
-        return this.filter;
-    }
-
-    /**
-     * Gets the formatter used by this handler to format the logging messages.
-     * 
-     * @return the formatter used by this handler
-     */
-    public Formatter getFormatter() {
-        return this.formatter;
-    }
-
-    /**
-     * Gets the logging level of this handler.
-     * 
-     * @return the logging level of this handler
-     */
-    public Level getLevel() {
-        return this.level;
-    }
-
-    /**
-     * Determines whether the supplied log record need to be logged. The logging
-     * levels will be checked as well as the filter.
-     * 
-     * @param record
-     *            the log record to be checked
-     * @return <code>true</code> if the supplied log record need to be logged,
-     *         otherwise <code>false</code>
-     */
-    public boolean isLoggable(LogRecord record) {
-        if (null == record) {
-            return false;
-        }
-        if (this.level.intValue() == Level.OFF.intValue()) {
-            return false;
-        } else if (record.getLevel().intValue() >= this.level.intValue()) {
-            return null == this.filter || this.filter.isLoggable(record);
-        }
-        return false;
-    }
-
-    /**
-     * Report an error to the error manager associated with this handler.
-     * 
-     * @param msg
-     *            the error message
-     * @param ex
-     *            the associated exception
-     * @param code
-     *            the error code
-     */
-    protected void reportError(String msg, Exception ex, int code) {
-        this.errorMan.error(msg, ex, code);
-    }
-
-    /**
-     * Sets the character encoding used by this handler. A <code>null</code>
-     * value indicates the using of the default encoding. This internal method
-     * does not check security.
-     * 
-     * @param newEncoding
-     *            the character encoding to set
-     * @throws UnsupportedEncodingException
-     *             If the specified encoding is not supported by the runtime.
-     */
-    void internalSetEncoding(String newEncoding)
-            throws UnsupportedEncodingException {
-        // accepts "null" because it indicates using default encoding
-        if (null == newEncoding) {
-            this.encoding = null;
-        } else {
-            if (Charset.isSupported(newEncoding)) {
-                this.encoding = newEncoding;
-            } else {
-                throw new UnsupportedEncodingException("The encoding \"" //$NON-NLS-1$
-                        + newEncoding + "\" is not supported."); //$NON-NLS-1$
-            }
-
-        }
-    }
-
-    /**
-     * Sets the character encoding used by this handler. A <code>null</code>
-     * value indicates the using of the default encoding.
-     * 
-     * @param encoding
-     *            the character encoding to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     * @throws UnsupportedEncodingException
-     *             If the specified encoding is not supported by the runtime.
-     */
-    public void setEncoding(String encoding) throws SecurityException,
-            UnsupportedEncodingException {
-        LogManager.getLogManager().checkAccess();
-        internalSetEncoding(encoding);
-    }
-
-    /**
-     * Sets the error manager for this handler.
-     * 
-     * @param em
-     *            the error manager to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public void setErrorManager(ErrorManager em) {
-        LogManager.getLogManager().checkAccess();
-        if (null == em) {
-            throw new NullPointerException();
-        }
-        this.errorMan = em;
-    }
-
-    /**
-     * Sets the filter to be used by this handler.
-     * 
-     * @param newFilter
-     *            the filter to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public void setFilter(Filter newFilter) {
-        LogManager.getLogManager().checkAccess();
-        this.filter = newFilter;
-    }
-
-    /**
-     * Sets the formatter to be used by this handler. This internal method does
-     * not check security.
-     * 
-     * @param newFormatter
-     *            the formatter to set
-     */
-    void internalSetFormatter(Formatter newFormatter) {
-        if (null == newFormatter) {
-            throw new NullPointerException();
-        }
-        this.formatter = newFormatter;
-    }
-
-    /**
-     * Sets the formatter to be used by this handler.
-     * 
-     * @param newFormatter
-     *            the formatter to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public void setFormatter(Formatter newFormatter) {
-        LogManager.getLogManager().checkAccess();
-        internalSetFormatter(newFormatter);
-    }
-
-    /**
-     * Sets the logging level of this handler.
-     * 
-     * @param newLevel
-     *            the logging level to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public void setLevel(Level newLevel) {
-        if (null == newLevel) {
-            throw new NullPointerException();
-        }
-        LogManager.getLogManager().checkAccess();
-        this.level = newLevel;
-    }
-}
-
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package java.util.logging;
+
+import java.nio.charset.Charset;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * A <code>Handler</code> object accepts a logging request and exports the
+ * desired messages to a target, for example, a file, the console, etc. It can
+ * be disabled by setting its logging level to <code>Level.OFF</code>.
+ * 
+ */
+public abstract class Handler {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+    private static final Level DEFAULT_LEVEL = Level.ALL;
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    // the error manager to report errors during logging
+    private ErrorManager errorMan;
+
+    // the character encoding used by this handler
+    private String encoding;
+
+    // the logging level
+    private Level level;
+
+    // the formatter used to export messages
+    private Formatter formatter;
+
+    // the filter used to filter undesired messages
+    private Filter filter;
+
+    // class name, used for property reading
+    private String prefix;
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs a <code>Handler</code> object with a default error manager,
+     * the default encoding, and the default logging level
+     * <code>Level.ALL</code>. It has no filter and no formatter.
+     */
+    protected Handler() {
+        this.errorMan = new ErrorManager();
+        this.level = DEFAULT_LEVEL;
+        this.encoding = null;
+        this.filter = null;
+        this.formatter = null;
+        this.prefix = this.getClass().getName();
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    // get a instance from given class name, using Class.forName()
+    private Object getDefaultInstance(String className) {
+        Object result = null;
+        if (null == className) {
+            return result;
+        }
+        try {
+            result = Class.forName(className).newInstance();
+        } catch (Exception e) {
+            //ignore
+        }
+        return result;
+    }
+
+    // get a instance from given class name, using context classloader
+    private Object getCustomizeInstance(final String className)
+            throws Exception {
+        Class<?> c = AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+                    public Class<?> run() throws Exception {
+                        ClassLoader loader = Thread.currentThread()
+                                .getContextClassLoader();
+                        if (null == loader) {
+                            loader = ClassLoader.getSystemClassLoader();
+                        }
+                        return loader.loadClass(className);
+                    }
+                });
+        return c.newInstance();
+    }
+
+    // print error message in some format
+    void printInvalidPropMessage(String key, String value, Exception e) {
+        String msg = new StringBuffer().append("Invalid property value for ") //$NON-NLS-1$
+                .append(prefix).append(".").append(key).append(":").append( //$NON-NLS-1$//$NON-NLS-2$
+                        value).toString();
+        errorMan.error(msg, e, ErrorManager.GENERIC_FAILURE);
+    }
+
+    /*
+     * init the common properties, including filter, level, formatter, and
+     * encoding
+     */
+    void initProperties(String defaultLevel, String defaultFilter,
+            String defaultFormatter, String defaultEncoding) {
+        LogManager manager = LogManager.getLogManager();
+
+        //set filter
+        final String filterName = manager.getProperty(prefix + ".filter"); //$NON-NLS-1$
+        if (null != filterName) {
+            try {
+                filter = (Filter) getCustomizeInstance(filterName);
+            } catch (Exception e1) {
+                printInvalidPropMessage("filter", filterName, e1); //$NON-NLS-1$
+                filter = (Filter) getDefaultInstance(defaultFilter);
+            }
+        } else {
+            filter = (Filter) getDefaultInstance(defaultFilter);
+        }
+
+        //set level
+        String levelName = manager.getProperty(prefix + ".level"); //$NON-NLS-1$
+        if (null != levelName) {
+            try {
+                level = Level.parse(levelName);
+            } catch (Exception e) {
+                printInvalidPropMessage("level", levelName, e); //$NON-NLS-1$
+                level = Level.parse(defaultLevel);
+            }
+        } else {
+            level = Level.parse(defaultLevel);
+        }
+
+        //set formatter
+        final String formatterName = manager.getProperty(prefix + ".formatter"); //$NON-NLS-1$
+        if (null != formatterName) {
+            try {
+                formatter = (Formatter) getCustomizeInstance(formatterName);
+            } catch (Exception e) {
+                printInvalidPropMessage("formatter", formatterName, e); //$NON-NLS-1$
+                formatter = (Formatter) getDefaultInstance(defaultFormatter);
+            }
+        } else {
+            formatter = (Formatter) getDefaultInstance(defaultFormatter);
+        }
+
+        //set encoding
+        final String encodingName = manager.getProperty(prefix + ".encoding"); //$NON-NLS-1$
+        try {
+            internalSetEncoding(encodingName);
+        } catch (UnsupportedEncodingException e) {
+            printInvalidPropMessage("encoding", encodingName, e); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Closes this handler. A flush operation will usually be performed and all
+     * the associated resources will be freed. Client applications should not
+     * use a handler after closing it.
+     * 
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public abstract void close();
+
+    /**
+     * Flushes any buffered output.
+     */
+    public abstract void flush();
+
+    /**
+     * Accepts an actual logging request.
+     * 
+     * @param record
+     *            the log record to be logged
+     */
+    public abstract void publish(LogRecord record);
+
+    /**
+     * Gets the character encoding used by this handler.
+     * 
+     * @return the character encoding used by this handler
+     */
+    public String getEncoding() {
+        return this.encoding;
+    }
+
+    /**
+     * Gets the error manager used by this handler to report errors during
+     * logging.
+     * 
+     * @return the error manager used by this handler
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public ErrorManager getErrorManager() {
+        LogManager.getLogManager().checkAccess();
+        return this.errorMan;
+    }
+
+    /**
+     * Gets the filter used by this handler.
+     * 
+     * @return the filter used by this handler
+     */
+    public Filter getFilter() {
+        return this.filter;
+    }
+
+    /**
+     * Gets the formatter used by this handler to format the logging messages.
+     * 
+     * @return the formatter used by this handler
+     */
+    public Formatter getFormatter() {
+        return this.formatter;
+    }
+
+    /**
+     * Gets the logging level of this handler.
+     * 
+     * @return the logging level of this handler
+     */
+    public Level getLevel() {
+        return this.level;
+    }
+
+    /**
+     * Determines whether the supplied log record need to be logged. The logging
+     * levels will be checked as well as the filter.
+     * 
+     * @param record
+     *            the log record to be checked
+     * @return <code>true</code> if the supplied log record need to be logged,
+     *         otherwise <code>false</code>
+     */
+    public boolean isLoggable(LogRecord record) {
+        if (null == record) {
+            throw new NullPointerException();
+        }
+        if (this.level.intValue() == Level.OFF.intValue()) {
+            return false;
+        } else if (record.getLevel().intValue() >= this.level.intValue()) {
+            return null == this.filter || this.filter.isLoggable(record);
+        }
+        return false;
+    }
+
+    /**
+     * Report an error to the error manager associated with this handler.
+     * 
+     * @param msg
+     *            the error message
+     * @param ex
+     *            the associated exception
+     * @param code
+     *            the error code
+     */
+    protected void reportError(String msg, Exception ex, int code) {
+        this.errorMan.error(msg, ex, code);
+    }
+
+    /**
+     * Sets the character encoding used by this handler. A <code>null</code>
+     * value indicates the using of the default encoding. This internal method
+     * does not check security.
+     * 
+     * @param newEncoding
+     *            the character encoding to set
+     * @throws UnsupportedEncodingException
+     *             If the specified encoding is not supported by the runtime.
+     */
+    void internalSetEncoding(String newEncoding)
+            throws UnsupportedEncodingException {
+        // accepts "null" because it indicates using default encoding
+        if (null == newEncoding) {
+            this.encoding = null;
+        } else {
+            if (Charset.isSupported(newEncoding)) {
+                this.encoding = newEncoding;
+            } else {
+                throw new UnsupportedEncodingException("The encoding \"" //$NON-NLS-1$
+                        + newEncoding + "\" is not supported."); //$NON-NLS-1$
+            }
+
+        }
+    }
+
+    /**
+     * Sets the character encoding used by this handler. A <code>null</code>
+     * value indicates the using of the default encoding.
+     * 
+     * @param encoding
+     *            the character encoding to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     * @throws UnsupportedEncodingException
+     *             If the specified encoding is not supported by the runtime.
+     */
+    public void setEncoding(String encoding) throws SecurityException,
+            UnsupportedEncodingException {
+        LogManager.getLogManager().checkAccess();
+        internalSetEncoding(encoding);
+    }
+
+    /**
+     * Sets the error manager for this handler.
+     * 
+     * @param em
+     *            the error manager to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public void setErrorManager(ErrorManager em) {
+        LogManager.getLogManager().checkAccess();
+        if (null == em) {
+            throw new NullPointerException();
+        }
+        this.errorMan = em;
+    }
+
+    /**
+     * Sets the filter to be used by this handler.
+     * 
+     * @param newFilter
+     *            the filter to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public void setFilter(Filter newFilter) {
+        LogManager.getLogManager().checkAccess();
+        this.filter = newFilter;
+    }
+
+    /**
+     * Sets the formatter to be used by this handler. This internal method does
+     * not check security.
+     * 
+     * @param newFormatter
+     *            the formatter to set
+     */
+    void internalSetFormatter(Formatter newFormatter) {
+        if (null == newFormatter) {
+            throw new NullPointerException();
+        }
+        this.formatter = newFormatter;
+    }
+
+    /**
+     * Sets the formatter to be used by this handler.
+     * 
+     * @param newFormatter
+     *            the formatter to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public void setFormatter(Formatter newFormatter) {
+        LogManager.getLogManager().checkAccess();
+        internalSetFormatter(newFormatter);
+    }
+
+    /**
+     * Sets the logging level of this handler.
+     * 
+     * @param newLevel
+     *            the logging level to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public void setLevel(Level newLevel) {
+        if (null == newLevel) {
+            throw new NullPointerException();
+        }
+        LogManager.getLogManager().checkAccess();
+        this.level = newLevel;
+    }
+}
+

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/StreamHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/StreamHandler.java?rev=433900&r1=433899&r2=433900&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/StreamHandler.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/StreamHandler.java Tue Aug 22 21:53:45 2006
@@ -1,357 +1,360 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package java.util.logging;
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-
-/**
- * A <code>StreamHandler</code> object writes log messages to an output
- * stream, that is, objects of the class <code>java.io.OutputStream</code>.
- * <p>
- * A <code>StreamHandler</code> object reads the following properties from the
- * log manager to initialize itself:
- * <ul>
- * <li>java.util.logging.StreamHandler.level specifies the logging level,
- * defaults to <code>Level.INFO</code> if this property is not found or has an
- * invalid value;
- * <li>java.util.logging.StreamHandler.filter specifies the name of the filter
- * class to be associated with this handler, defaults to <code>null</code> if
- * this property is not found or has an invalid value;
- * <li>java.util.logging.StreamHandler.formatter specifies the name of the
- * formatter class to be associated with this handler, defaults to
- * <code>java.util.logging.SimpleFormatter</code> if this property is not
- * found or has an invalid value;
- * <li>java.util.logging.StreamHandler.encoding specifies the encoding this
- * handler will use to encode log messages, defaults to <code>null</code> if
- * this property is not found or has an invalid value.
- * </ul>
- * </p>
- * <p>
- * This class is not thread-safe.
- * </p>
- * 
- */
-public class StreamHandler extends Handler {
-
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
-
-    // the output stream this handler writes to
-    private OutputStream os;
-
-    // the writer that writes to the output stream
-    private Writer writer;
-
-    // the flag indicating whether the writer has been initialized
-    private boolean writerNotInitialized;
-
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * Constructs a <code>StreamHandler</code> object. The new stream handler
-     * does not have an associated output stream.
-     */
-    public StreamHandler() {
-        initProperties("INFO", null, "java.util.logging.SimpleFormatter",  //$NON-NLS-1$//$NON-NLS-2$
-                null);
-        this.os = null;
-        this.writer = null;
-        this.writerNotInitialized = true;
-    }
-
-    /**
-     * Constructs a <code>StreamHandler</code> object with the supplied output
-     * stream. Default properties are read.
-     * 
-     * @param os
-     *            the output stream this handler writes to
-     */
-    StreamHandler(OutputStream os) {
-        this();
-        this.os = os;
-    }
-
-    /*
-     * Constructs a <code>StreamHandler</code> object. Specified default
-     * values will be used if the corresponding properties are found in log
-     * manager's properties.
-     */
-    StreamHandler(String defaultLevel, String defaultFilter,
-            String defaultFormatter, String defaultEncoding) {
-        initProperties(defaultLevel, defaultFilter, defaultFormatter,
-                defaultEncoding);
-        this.os = null;
-        this.writer = null;
-        this.writerNotInitialized = true;
-    }
-
-    /**
-     * Constructs a <code>StreamHandler</code> object with the supplied output
-     * stream and formatter.
-     * 
-     * @param os
-     *            the output stream this handler writes to
-     * @param formatter
-     *            the formatter this handler uses to format the output
-     */
-    public StreamHandler(OutputStream os, Formatter formatter) {
-        this();
-        if (os == null) {
-            throw new NullPointerException("The OutputStream parameter is null");
-        }
-        if (formatter == null) {
-            throw new NullPointerException("The Formatter parameter is null.");
-        }
-        this.os = os;
-        internalSetFormatter(formatter);
-    }
-
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
-    // initialize the writer
-    private void initializeWritter() {
-        this.writerNotInitialized = false;
-        if (null == getEncoding()) {
-            this.writer = new OutputStreamWriter(this.os);
-        } else {
-            try {
-                this.writer = new OutputStreamWriter(this.os, getEncoding());
-            } catch (UnsupportedEncodingException e) {
-                /*
-                 * Should not happen because it's checked in
-                 * super.initProperties().
-                 */
-            }
-        }
-        write(getFormatter().getHead(this));
-    }
-
-    // Write a string to the output stream.
-    private void write(String s) {
-        try {
-            this.writer.write(s);
-        } catch (Exception e) {
-            getErrorManager().error(
-                    "Exception occurred when writing to the output stream.", e, //$NON-NLS-1$
-                    ErrorManager.WRITE_FAILURE);
-        }
-    }
-
-    /**
-     * Sets the output stream this handler writes to. Note it does nothing else.
-     * 
-     * @param newOs
-     *            the new output stream
-     */
-    void internalSetOutputStream(OutputStream newOs) {
-        this.os = newOs;
-    }
-
-	
-    /**
-     * Sets the output stream this handler writes to. If there's an existing
-     * output stream, the tail string of the associated formatter will be
-     * written to it. Then it will be flushed and closed.
-     * 
-     * @param os
-     *            the new output stream
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    protected void setOutputStream(OutputStream os) {
-        if (null == os) {
-            throw new NullPointerException();
-        }
-        LogManager.getLogManager().checkAccess();
-        close(true);
-        this.writer = null;
-        this.os = os;
-        this.writerNotInitialized = true;
-    }
-
-    /**
-     * Sets the character encoding used by this handler. A <code>null</code>
-     * value indicates the using of the default encoding.
-     * 
-     * @param encoding
-     *            the character encoding to set
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     * @throws UnsupportedEncodingException
-     *             If the specified encoding is not supported by the runtime.
-     */
-    public void setEncoding(String encoding) throws SecurityException,
-            UnsupportedEncodingException {
-		//flush first before set new encoding
-		this.flush();
-        super.setEncoding(encoding);
-        // renew writer only if the writer exists
-        if (null != this.writer) {
-            if (null == getEncoding()) {
-                this.writer = new OutputStreamWriter(this.os);
-            } else {
-                try {
-                    this.writer = new OutputStreamWriter(this.os, getEncoding());
-                } catch (UnsupportedEncodingException e) {
-                    /*
-                     * Should not happen because it's checked in
-                     * super.initProperties().
-                     */
-                }
-            }
-        }
-    }
-
-    /**
-     * Closes this handler, but the underlying output stream is only closed when
-     * <code>closeStream</code> is <code>true</code>. Security is not checked.
-     * 
-     * @param closeStream
-     *            whether to close the underlying output stream
-     */
-    void close(boolean closeStream) {
-        if (null != this.os) {
-            if (this.writerNotInitialized) {
-                initializeWritter();
-            }
-            write(getFormatter().getTail(this));
-            try {
-                this.writer.flush();
-                if (closeStream) {
-                    this.writer.close();
-					this.writer = null;
-	                this.os = null;
-                }
-            } catch (Exception e) {
-                getErrorManager().error(
-                        "Exception occurred when closing the output stream.", e, //$NON-NLS-1$
-                        ErrorManager.CLOSE_FAILURE);
-            }
-        }
-    }
-
-    /**
-     * Closes this handler. The tail string of the formatter associated with
-     * this handler will be written out. A flush operation a subsequent close
-     * operation will then be performed upon the outputstream. Client
-     * applications should not use a handler after closing it.
-     * 
-     * @throws SecurityException
-     *             If a security manager determines that the caller does not
-     *             have the required permission.
-     */
-    public void close() {
-        LogManager.getLogManager().checkAccess();
-        close(true);
-    }
-
-    /**
-     * Flushes any buffered output.
-     */
-    public void flush() {
-        if (null != this.os) {
-            try {
-                if (null != this.writer) {
-                    this.writer.flush();
-                } else {
-                    this.os.flush();
-                }
-            } catch (Exception e) {
-                getErrorManager().error(
-                        "Exception occurred while flushing the output stream.", //$NON-NLS-1$
-                        e, ErrorManager.FLUSH_FAILURE);
-            }
-        }
-    }
-
-    /**
-     * Accepts an actual logging request. The log record will be formatted and
-     * written to the output stream if the following three conditions are met:
-     * <ul>
-     * <li>the supplied log record has at least the required logging level;
-     * <li>the supplied log record passes the filter associated with this
-     * handler if any;
-     * <li>the output stream associated with this handler is not
-     * <code>null</code>.
-     * </ul>
-     * If it is the first time a log record need to be written out, the head
-     * string of the formatter associated with this handler will be written out
-     * first.
-     * 
-     * @param record
-     *            the log record to be logged
-     */
-    public void publish(LogRecord record) {
-        try {
-            if (this.isLoggable(record)) {
-                if (this.writerNotInitialized) {
-                    initializeWritter();
-                }
-                String msg = null;
-                try {
-                    msg = getFormatter().format(record);
-                } catch (Exception e) {
-                    getErrorManager()
-                            .error(
-                                    "Exception occurred while formatting the log record.", //$NON-NLS-1$
-                                    e, ErrorManager.FORMAT_FAILURE);
-                }
-                write(msg);
-            }
-        } catch (Exception e) {
-            getErrorManager().error(
-                    "Exception occurred while logging the record.", e, //$NON-NLS-1$
-                    ErrorManager.GENERIC_FAILURE);
-        }
-    }
-
-    /**
-     * Determines whether the supplied log record need to be logged. The logging
-     * levels will be checked as well as the filter. The output stream of this
-     * handler is also checked. If it's null, this method returns false.
-     * 
-     * @param record
-     *            the log record to be checked
-     * @return <code>true</code> if the supplied log record need to be logged,
-     *         otherwise <code>false</code>
-     */
-    public boolean isLoggable(LogRecord record) {
-        if (super.isLoggable(record) && null != this.os) {
-            return true;
-        }
-        return false;
-    }
-
-}
-
-
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package java.util.logging;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+/**
+ * A <code>StreamHandler</code> object writes log messages to an output
+ * stream, that is, objects of the class <code>java.io.OutputStream</code>.
+ * <p>
+ * A <code>StreamHandler</code> object reads the following properties from the
+ * log manager to initialize itself:
+ * <ul>
+ * <li>java.util.logging.StreamHandler.level specifies the logging level,
+ * defaults to <code>Level.INFO</code> if this property is not found or has an
+ * invalid value;
+ * <li>java.util.logging.StreamHandler.filter specifies the name of the filter
+ * class to be associated with this handler, defaults to <code>null</code> if
+ * this property is not found or has an invalid value;
+ * <li>java.util.logging.StreamHandler.formatter specifies the name of the
+ * formatter class to be associated with this handler, defaults to
+ * <code>java.util.logging.SimpleFormatter</code> if this property is not
+ * found or has an invalid value;
+ * <li>java.util.logging.StreamHandler.encoding specifies the encoding this
+ * handler will use to encode log messages, defaults to <code>null</code> if
+ * this property is not found or has an invalid value.
+ * </ul>
+ * </p>
+ * <p>
+ * This class is not thread-safe.
+ * </p>
+ * 
+ */
+public class StreamHandler extends Handler {
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    // the output stream this handler writes to
+    private OutputStream os;
+
+    // the writer that writes to the output stream
+    private Writer writer;
+
+    // the flag indicating whether the writer has been initialized
+    private boolean writerNotInitialized;
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs a <code>StreamHandler</code> object. The new stream handler
+     * does not have an associated output stream.
+     */
+    public StreamHandler() {
+        initProperties("INFO", null, "java.util.logging.SimpleFormatter",  //$NON-NLS-1$//$NON-NLS-2$
+                null);
+        this.os = null;
+        this.writer = null;
+        this.writerNotInitialized = true;
+    }
+
+    /**
+     * Constructs a <code>StreamHandler</code> object with the supplied output
+     * stream. Default properties are read.
+     * 
+     * @param os
+     *            the output stream this handler writes to
+     */
+    StreamHandler(OutputStream os) {
+        this();
+        this.os = os;
+    }
+
+    /*
+     * Constructs a <code>StreamHandler</code> object. Specified default
+     * values will be used if the corresponding properties are found in log
+     * manager's properties.
+     */
+    StreamHandler(String defaultLevel, String defaultFilter,
+            String defaultFormatter, String defaultEncoding) {
+        initProperties(defaultLevel, defaultFilter, defaultFormatter,
+                defaultEncoding);
+        this.os = null;
+        this.writer = null;
+        this.writerNotInitialized = true;
+    }
+
+    /**
+     * Constructs a <code>StreamHandler</code> object with the supplied output
+     * stream and formatter.
+     * 
+     * @param os
+     *            the output stream this handler writes to
+     * @param formatter
+     *            the formatter this handler uses to format the output
+     */
+    public StreamHandler(OutputStream os, Formatter formatter) {
+        this();
+        if (os == null) {
+            throw new NullPointerException("The OutputStream parameter is null");
+        }
+        if (formatter == null) {
+            throw new NullPointerException("The Formatter parameter is null.");
+        }
+        this.os = os;
+        internalSetFormatter(formatter);
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    // initialize the writer
+    private void initializeWritter() {
+        this.writerNotInitialized = false;
+        if (null == getEncoding()) {
+            this.writer = new OutputStreamWriter(this.os);
+        } else {
+            try {
+                this.writer = new OutputStreamWriter(this.os, getEncoding());
+            } catch (UnsupportedEncodingException e) {
+                /*
+                 * Should not happen because it's checked in
+                 * super.initProperties().
+                 */
+            }
+        }
+        write(getFormatter().getHead(this));
+    }
+
+    // Write a string to the output stream.
+    private void write(String s) {
+        try {
+            this.writer.write(s);
+        } catch (Exception e) {
+            getErrorManager().error(
+                    "Exception occurred when writing to the output stream.", e, //$NON-NLS-1$
+                    ErrorManager.WRITE_FAILURE);
+        }
+    }
+
+    /**
+     * Sets the output stream this handler writes to. Note it does nothing else.
+     * 
+     * @param newOs
+     *            the new output stream
+     */
+    void internalSetOutputStream(OutputStream newOs) {
+        this.os = newOs;
+    }
+
+	
+    /**
+     * Sets the output stream this handler writes to. If there's an existing
+     * output stream, the tail string of the associated formatter will be
+     * written to it. Then it will be flushed and closed.
+     * 
+     * @param os
+     *            the new output stream
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    protected void setOutputStream(OutputStream os) {
+        if (null == os) {
+            throw new NullPointerException();
+        }
+        LogManager.getLogManager().checkAccess();
+        close(true);
+        this.writer = null;
+        this.os = os;
+        this.writerNotInitialized = true;
+    }
+
+    /**
+     * Sets the character encoding used by this handler. A <code>null</code>
+     * value indicates the using of the default encoding.
+     * 
+     * @param encoding
+     *            the character encoding to set
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     * @throws UnsupportedEncodingException
+     *             If the specified encoding is not supported by the runtime.
+     */
+    public void setEncoding(String encoding) throws SecurityException,
+            UnsupportedEncodingException {
+		//flush first before set new encoding
+		this.flush();
+        super.setEncoding(encoding);
+        // renew writer only if the writer exists
+        if (null != this.writer) {
+            if (null == getEncoding()) {
+                this.writer = new OutputStreamWriter(this.os);
+            } else {
+                try {
+                    this.writer = new OutputStreamWriter(this.os, getEncoding());
+                } catch (UnsupportedEncodingException e) {
+                    /*
+                     * Should not happen because it's checked in
+                     * super.initProperties().
+                     */
+                }
+            }
+        }
+    }
+
+    /**
+     * Closes this handler, but the underlying output stream is only closed when
+     * <code>closeStream</code> is <code>true</code>. Security is not checked.
+     * 
+     * @param closeStream
+     *            whether to close the underlying output stream
+     */
+    void close(boolean closeStream) {
+        if (null != this.os) {
+            if (this.writerNotInitialized) {
+                initializeWritter();
+            }
+            write(getFormatter().getTail(this));
+            try {
+                this.writer.flush();
+                if (closeStream) {
+                    this.writer.close();
+					this.writer = null;
+	                this.os = null;
+                }
+            } catch (Exception e) {
+                getErrorManager().error(
+                        "Exception occurred when closing the output stream.", e, //$NON-NLS-1$
+                        ErrorManager.CLOSE_FAILURE);
+            }
+        }
+    }
+
+    /**
+     * Closes this handler. The tail string of the formatter associated with
+     * this handler will be written out. A flush operation a subsequent close
+     * operation will then be performed upon the outputstream. Client
+     * applications should not use a handler after closing it.
+     * 
+     * @throws SecurityException
+     *             If a security manager determines that the caller does not
+     *             have the required permission.
+     */
+    public void close() {
+        LogManager.getLogManager().checkAccess();
+        close(true);
+    }
+
+    /**
+     * Flushes any buffered output.
+     */
+    public void flush() {
+        if (null != this.os) {
+            try {
+                if (null != this.writer) {
+                    this.writer.flush();
+                } else {
+                    this.os.flush();
+                }
+            } catch (Exception e) {
+                getErrorManager().error(
+                        "Exception occurred while flushing the output stream.", //$NON-NLS-1$
+                        e, ErrorManager.FLUSH_FAILURE);
+            }
+        }
+    }
+
+    /**
+     * Accepts an actual logging request. The log record will be formatted and
+     * written to the output stream if the following three conditions are met:
+     * <ul>
+     * <li>the supplied log record has at least the required logging level;
+     * <li>the supplied log record passes the filter associated with this
+     * handler if any;
+     * <li>the output stream associated with this handler is not
+     * <code>null</code>.
+     * </ul>
+     * If it is the first time a log record need to be written out, the head
+     * string of the formatter associated with this handler will be written out
+     * first.
+     * 
+     * @param record
+     *            the log record to be logged
+     */
+    public void publish(LogRecord record) {
+        try {
+            if (this.isLoggable(record)) {
+                if (this.writerNotInitialized) {
+                    initializeWritter();
+                }
+                String msg = null;
+                try {
+                    msg = getFormatter().format(record);
+                } catch (Exception e) {
+                    getErrorManager()
+                            .error(
+                                    "Exception occurred while formatting the log record.", //$NON-NLS-1$
+                                    e, ErrorManager.FORMAT_FAILURE);
+                }
+                write(msg);
+            }
+        } catch (Exception e) {
+            getErrorManager().error(
+                    "Exception occurred while logging the record.", e, //$NON-NLS-1$
+                    ErrorManager.GENERIC_FAILURE);
+        }
+    }
+
+    /**
+     * Determines whether the supplied log record need to be logged. The logging
+     * levels will be checked as well as the filter. The output stream of this
+     * handler is also checked. If it's null, this method returns false.
+     * 
+     * @param record
+     *            the log record to be checked
+     * @return <code>true</code> if the supplied log record need to be logged,
+     *         otherwise <code>false</code>
+     */
+    public boolean isLoggable(LogRecord record) {
+    	if (null == record) {
+			return false;
+		}
+        if (super.isLoggable(record) && null != this.os) {
+            return true;
+        }
+        return false;
+    }
+
+}
+
+

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java?rev=433900&r1=433899&r2=433900&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java Tue Aug 22 21:53:45 2006
@@ -473,13 +473,17 @@
 		assertSame(r, CallVerificationStack.getInstance().pop());
 	}
 
-	/*
-	 * Null log record, handler should call ErrorManager to handle
-	 * exceptional case
+	/**
+	 * @tests java.util.logging.Handler#isLoggable(LogRecord)
 	 */
 	public void testIsLoggable_Null() {
 		MockHandler h = new MockHandler();
-		h.isLoggable(null);
+		try {
+			h.isLoggable(null);
+			fail("should throw NullPointerException");
+		} catch (NullPointerException e) {
+			// expected
+		}
 	}
 
 	/*

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java?rev=433900&r1=433899&r2=433900&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java Tue Aug 22 21:53:45 2006
@@ -161,7 +161,9 @@
 	public void testIsLoggable() {
 		try {
 			handler.isLoggable(null);
+			fail("should throw NullPointerException");
 		} catch (NullPointerException e) {
+			// expected
 		}
 		LogRecord record = new LogRecord(Level.FINER, "MSG1");
 		assertFalse(handler.isLoggable(record));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java?rev=433900&r1=433899&r2=433900&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java Tue Aug 22 21:53:45 2006
@@ -496,7 +496,7 @@
 	public void testIsLoggable_Null() {
 		StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
 				new SimpleFormatter());
-		h.isLoggable(null);
+		assertFalse(h.isLoggable(null));
 	}
 
 	/*
@@ -504,7 +504,7 @@
 	 */
 	public void testIsLoggable_Null_NoOutputStream() {
 		StreamHandler h = new StreamHandler();
-		h.isLoggable(null);
+		assertFalse(h.isLoggable(null));
 	}
 
 	/*



Mime
View raw message