-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.5.1
Name: sdC67446 Date: 05/27/99
The two methods of class java.awt.datatransfer.DataFlavorRegistry
unregisterFlavorClass(String flavorClassName) and
unregisterMimeType(String mimeTypeString)
differ on input null parameter.
In detail:
unregisterMimeType(null) throws NPE,
unregisterFlavorClass(null) doesn't.
This is inconsistency.
The JDK javadoc comment says:
--------------------------------------------------
/**
* Registers a DataFlavor subclass to represent the given
* MIME type. Only the MIME type and subtype are inspected,
* and any parameters are ignored during registration.
* <p>
* The primary MIME type must be provided, but the subtype may
* be ommitted. For instance, some valid types are <code>text</code>,
* <code>text/plain</code>, and <code>image/gif</code>. If a
* flavor is already registered for this type/subtype, that
* flavor is unregistered.
* </p>
* <p>
* When doing a lookup, the most factory registered for the most
* specific type is used.
* </p>
*
* @throws IllegalArgumentException if the mimeType is empty
* @see #getFlavorForMimeType
*
*/
public void registerFlavorClass(String mimeType, String flavorClassName)
throws MimeTypeParseException
/**
* Unregisters this DataFlavor class for all MIME types.
* If necessary, the class name of a loaded class can be
* found by using <code>flavor.getClass().getName()</code>. The
* <code>datatransfer</code> package prefers String class
* names, rather than class objects in order to avoid
* unnecessarily loading classes.
*/
public void unregisterFlavorClass(String flavorClassName)
/**
* unregisters the flavor class for one mime type or type/subtype.
* Note that a wildcard only removes the registration for one
* entry, and other matching entries are not unregistered. For
* example, unregistering <code>text/*</code> will not unregister
* <code>text/plain</code> or <code>text/html</code>.
*/
public void unregisterMimeType(String mimeTypeString)
throws MimeTypeParseException
The test demonstrating the bug:
-----------------Test.java------------------------
import java.awt.datatransfer.*;
public class Test {
public static void main(String[] args) {
DataFlavorRegistry dfr = new DataFlavorRegistry();
System.out.println("<<unregisterMimeType>>");
try {
dfr.unregisterMimeType(null);
} catch (MimeTypeParseException e) {
e.printStackTrace();
} catch (NullPointerException e1) {
e1.printStackTrace();
}
System.out.println("<<unregisterFlavorClass>>");
dfr.unregisterFlavorClass(null);
};
}
---------Output-----------------------------------
<<unregisterMimeType>>
java.lang.NullPointerException
at java.awt.datatransfer.MimeType.parse(MimeType.java, Compiled Code)
at java.awt.datatransfer.MimeType.<init>(MimeType.java, Compiled Code)
at java.awt.datatransfer.DataFlavorRegistry.unregisterMimeType(DataFlavorRegistry.java, Compiled Code)
at Test.main(Test.java, Compiled Code)
<<unregisterFlavorClass>>
--------------------------------------------------
======================================================================