Skip to content

DOMInputCapsule.readIntSavableMap does not check exceptions #2039

Open
@tohidemyname

Description

@tohidemyname

The code is as follows:

public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal) throws IOException {
...

                                if (n instanceof Element && n.getNodeName().equals("MapEntry")) {
                                        Element elem = (Element) n;
                                        currentElem = elem;
                                        int key = Integer.parseInt(currentElem.getAttribute("key"));
                                        Savable val = readSavable("Savable", null);
                                        ret.put(key, val);
                                }                  
         ...
    }

Here Integer.parseInt(currentElem.getAttribute("key")) can throw NumberFormatException. The other methods of this class catch and rethrow IOException. An example is as follows:

public byte[] readByteArray(String name, byte[] defVal) throws IOException {
  try {...
      for (int i = 0; i < strings.length; i++) {
              tmp[i] = Byte.parseByte(strings[i]);
       }...
  }catch (IOException ioe) {
            throw ioe;
        } catch (NumberFormatException nfe) {

            IOException io = new IOException(nfe.toString());
            io.initCause(nfe);
            throw io;

        } catch (DOMException de) {
            IOException io = new IOException(de.toString());
            io.initCause(de);
            throw io;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSomething that is supposed to work, but doesn't. Less severe than a "bug"

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions