8252354: Properties :: storeToXML method does not throw ClassCastException when supplied non strings

Reviewed-by: lancea, naoto
This commit is contained in:
Joe Wang 2020-09-02 21:32:48 +00:00
parent c61204b3f3
commit 38cd5d0936
2 changed files with 71 additions and 1 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -118,6 +118,9 @@ public class PropertiesDefaultHandler extends DefaultHandler {
writer.writeAttribute(ATTR_KEY, (String)k);
writer.writeCharacters((String)v);
writer.writeEndElement();
} else {
throw new ClassCastException(
"Keys and values in Properties must be Strings");
}
}
}