Mercurial > hg > openjdk > lambda > jdk
changeset 9509:fce446b29577
8011038: sourceObj validation during desereliazation of RelationNotification should be relaxed
Summary: sourceObj could be set to null by setSource() relax a validation of deserialized object.
Reviewed-by: sjiang, skoivu, dfuchs
author | dsamersoff |
---|---|
date | Tue, 06 Aug 2013 14:04:49 +0400 |
parents | 31759750ff63 |
children | 6773af0dda02 |
files | src/share/classes/javax/management/relation/RelationNotification.java |
diffstat | 1 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/javax/management/relation/RelationNotification.java Mon Aug 05 19:12:33 2013 -0700 +++ b/src/share/classes/javax/management/relation/RelationNotification.java Tue Aug 06 14:04:49 2013 +0400 @@ -260,7 +260,7 @@ super(notifType, sourceObj, sequence, timeStamp, message); - if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidCreate(notifType)) { + if (!isValidBasicStrict(notifType,sourceObj,id,typeName) || !isValidCreate(notifType)) { throw new IllegalArgumentException("Invalid parameter."); } @@ -310,7 +310,7 @@ super(notifType, sourceObj, sequence, timeStamp, message); - if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidUpdate(notifType,name,newValue,oldValue)) { + if (!isValidBasicStrict(notifType,sourceObj,id,typeName) || !isValidUpdate(notifType,name,newValue,oldValue)) { throw new IllegalArgumentException("Invalid parameter."); } @@ -457,14 +457,26 @@ // - no role old value (for role update) // - no role new value (for role update) + // Despite the fact, that validation in constructor of RelationNotification prohibit + // creation of the class instance with null sourceObj its possible to set it to null later + // by public setSource() method. + // So we should relax validation rules to preserve serialization behavior compatibility. + + private boolean isValidBasicStrict(String notifType, Object sourceObj, String id, String typeName){ + if (sourceObj == null) { + return false; + } + return isValidBasic(notifType,sourceObj,id,typeName); + } + private boolean isValidBasic(String notifType, Object sourceObj, String id, String typeName){ - if (notifType == null || sourceObj == null || - id == null || typeName == null) { + if (notifType == null || id == null || typeName == null) { return false; } - if (!(sourceObj instanceof RelationService) && - !(sourceObj instanceof ObjectName)) { + if (sourceObj != null && ( + !(sourceObj instanceof RelationService) && + !(sourceObj instanceof ObjectName))) { return false; }