Menu

#4253 [HHQ-4153] Inappropriate exception thrown from ApplicationMa

Bug
open
None
1
2012-10-09
2010-07-21
No

http://jira.hyperic.com/browse/HHQ-4153
The code below throws an ApplicationNotFoundException for any ObjectNotFoundException that occurs. Problem is, an ObjectNotFoundException might be thrown if the appServiceId passed in isn't valid, in which case re-throwing an ApplicationNotFoundException is not helpful.



    public void removeAppService(AuthzSubject caller, Integer appId, Integer appServiceId)


        throws ApplicationException, ApplicationNotFoundException, PermissionException {


        try {


            Application app = applicationDAO.findById(appId);


            permissionManager.checkModifyPermission(caller, app.getEntityId());



            AppService appSvcLoc = appServiceDAO.findById(appServiceId);


            app.removeService(appSvcLoc); // if THIS LINE throws ObjectNotFoundException.....


            appServiceDAO.remove(appSvcLoc);


        } catch (ObjectNotFoundException e) {


            throw new ApplicationNotFoundException(appId); // then this exception isn't the right one to throw


        }


    }

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.