Issue Details (XML | Word | Printable)

Key: VALIDATOR-195
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Niall Pemberton
Reporter: Vijay Pandey
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Validator

Lodaing of Digester Rules for classes extending ValidatorResources does not work

Created: 28/Jun/06 09:35 PM   Updated: 12/Nov/07 07:25 PM
Return to search
Component/s: Framework
Affects Version/s: 1.2.0 Release, 1.3.0 Release
Fix Version/s: 1.3.1 Release

Time Tracking:
Not Specified

Environment: Windows/Unix

Resolution Date: 22/Nov/06 11:56 PM


 Description  « Hide
If we extend the class "ValidatorResources", then the loading of the digester rules does not work properly.

--------------------------------ValidatorResources--------------------------------------------------------
private Digester initDigester() {
URL rulesUrl = this.getClass().getResource("digester-rules.xml");
-----------------------------------------------------------------------------------------------------------------------
The above line tries to find the "digester-rules.xml" from the path of extending class and hence to make this work we need to
copy the digester rules xml file in the same pacakge as the extending class.

I think a better way might be is to accept a InputStream or URL for the digester rules in the constructor if someone wants to
have their custom digester rules, and by default if it's not provided it should always take from the ValidatorResources path
by changing the code

this.getClass().getResource("digester-rules.xml");

to

ValidatorResources.class.getResource("digester-rules.xml");

Thanks
Vijay



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Niall Pemberton made changes - 19/Jul/06 01:22 PM
Field Original Value New Value
Component/s Framework [ 12311271 ]
Repository Revision Date User Message
ASF #478392 Wed Nov 22 23:51:09 UTC 2006 niallp VALIDATOR-195 - Fix loading of Digester rules for custom ValidatorResources implementations - thanks to Vijay Pandey
Files Changed
MODIFY /jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorResources.java
ADD /jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/custom/CustomValidatorResources.java
MODIFY /jakarta/commons/proper/validator/trunk/xdocs/changes.xml
ADD /jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/custom
ADD /jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CustomValidatorResourcesTest.java

Niall Pemberton added a comment - 22/Nov/06 11:56 PM
Changing ValidatorResources to always load the digester rules from the "org.apache.commons.validator" package could break behaviour for someone relying on this (i.e. if they're plugging in their own custom Digester rules) - so I don't want to make the change you requested.

I have however modified ValidatorResources to use the digester rules in the "org.apache.commons.validator" package if no rules are found in the default package for the class - this should resolve your issue and retain backwards compatibility:

http://svn.apache.org/viewvc?view=rev&revision=478392

Thanks for reporting this

Niall


Niall Pemberton made changes - 22/Nov/06 11:56 PM
Assignee Niall Pemberton [ niallp ]
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 1.3.1 [ 12311934 ]
Henri Yandell made changes - 12/Nov/07 07:25 PM
Status Resolved [ 5 ] Closed [ 6 ]